clk.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. #ifndef __MACH_IMX_CLK_H
  2. #define __MACH_IMX_CLK_H
  3. #include <linux/spinlock.h>
  4. #include <linux/clk-provider.h>
  5. extern spinlock_t imx_ccm_lock;
  6. void imx_check_clocks(struct clk *clks[], unsigned int count);
  7. void imx_register_uart_clocks(struct clk ** const clks[]);
  8. extern void imx_cscmr1_fixup(u32 *val);
  9. enum imx_pllv1_type {
  10. IMX_PLLV1_IMX1,
  11. IMX_PLLV1_IMX21,
  12. IMX_PLLV1_IMX25,
  13. IMX_PLLV1_IMX27,
  14. IMX_PLLV1_IMX31,
  15. IMX_PLLV1_IMX35,
  16. };
  17. struct clk *imx_clk_pllv1(enum imx_pllv1_type type, const char *name,
  18. const char *parent, void __iomem *base);
  19. struct clk *imx_clk_pllv2(const char *name, const char *parent,
  20. void __iomem *base);
  21. enum imx_pllv3_type {
  22. IMX_PLLV3_GENERIC,
  23. IMX_PLLV3_SYS,
  24. IMX_PLLV3_USB,
  25. IMX_PLLV3_USB_VF610,
  26. IMX_PLLV3_AV,
  27. IMX_PLLV3_ENET,
  28. IMX_PLLV3_ENET_IMX7,
  29. };
  30. struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
  31. const char *parent_name, void __iomem *base, u32 div_mask);
  32. struct clk *clk_register_gate2(struct device *dev, const char *name,
  33. const char *parent_name, unsigned long flags,
  34. void __iomem *reg, u8 bit_idx, u8 cgr_val,
  35. u8 clk_gate_flags, spinlock_t *lock,
  36. unsigned int *share_count);
  37. struct clk * imx_obtain_fixed_clock(
  38. const char *name, unsigned long rate);
  39. struct clk *imx_clk_gate_exclusive(const char *name, const char *parent,
  40. void __iomem *reg, u8 shift, u32 exclusive_mask);
  41. struct clk *imx_clk_pfd(const char *name, const char *parent_name,
  42. void __iomem *reg, u8 idx);
  43. struct clk *imx_clk_busy_divider(const char *name, const char *parent_name,
  44. void __iomem *reg, u8 shift, u8 width,
  45. void __iomem *busy_reg, u8 busy_shift);
  46. struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift,
  47. u8 width, void __iomem *busy_reg, u8 busy_shift,
  48. const char **parent_names, int num_parents);
  49. struct clk *imx_clk_fixup_divider(const char *name, const char *parent,
  50. void __iomem *reg, u8 shift, u8 width,
  51. void (*fixup)(u32 *val));
  52. struct clk *imx_clk_fixup_mux(const char *name, void __iomem *reg,
  53. u8 shift, u8 width, const char **parents,
  54. int num_parents, void (*fixup)(u32 *val));
  55. static inline struct clk *imx_clk_fixed(const char *name, int rate)
  56. {
  57. return clk_register_fixed_rate(NULL, name, NULL, 0, rate);
  58. }
  59. static inline struct clk *imx_clk_fixed_factor(const char *name,
  60. const char *parent, unsigned int mult, unsigned int div)
  61. {
  62. return clk_register_fixed_factor(NULL, name, parent,
  63. CLK_SET_RATE_PARENT, mult, div);
  64. }
  65. static inline struct clk *imx_clk_divider(const char *name, const char *parent,
  66. void __iomem *reg, u8 shift, u8 width)
  67. {
  68. return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
  69. reg, shift, width, 0, &imx_ccm_lock);
  70. }
  71. static inline struct clk *imx_clk_divider_flags(const char *name,
  72. const char *parent, void __iomem *reg, u8 shift, u8 width,
  73. unsigned long flags)
  74. {
  75. return clk_register_divider(NULL, name, parent, flags,
  76. reg, shift, width, 0, &imx_ccm_lock);
  77. }
  78. static inline struct clk *imx_clk_divider2(const char *name, const char *parent,
  79. void __iomem *reg, u8 shift, u8 width)
  80. {
  81. return clk_register_divider(NULL, name, parent,
  82. CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
  83. reg, shift, width, 0, &imx_ccm_lock);
  84. }
  85. static inline struct clk *imx_clk_gate(const char *name, const char *parent,
  86. void __iomem *reg, u8 shift)
  87. {
  88. return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  89. shift, 0, &imx_ccm_lock);
  90. }
  91. static inline struct clk *imx_clk_gate_dis(const char *name, const char *parent,
  92. void __iomem *reg, u8 shift)
  93. {
  94. return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  95. shift, CLK_GATE_SET_TO_DISABLE, &imx_ccm_lock);
  96. }
  97. static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
  98. void __iomem *reg, u8 shift)
  99. {
  100. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  101. shift, 0x3, 0, &imx_ccm_lock, NULL);
  102. }
  103. static inline struct clk *imx_clk_gate2_shared(const char *name,
  104. const char *parent, void __iomem *reg, u8 shift,
  105. unsigned int *share_count)
  106. {
  107. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  108. shift, 0x3, 0, &imx_ccm_lock, share_count);
  109. }
  110. static inline struct clk *imx_clk_gate2_shared2(const char *name,
  111. const char *parent, void __iomem *reg, u8 shift,
  112. unsigned int *share_count)
  113. {
  114. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT |
  115. CLK_OPS_PARENT_ENABLE, reg, shift, 0x3, 0,
  116. &imx_ccm_lock, share_count);
  117. }
  118. static inline struct clk *imx_clk_gate2_cgr(const char *name,
  119. const char *parent, void __iomem *reg, u8 shift, u8 cgr_val)
  120. {
  121. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  122. shift, cgr_val, 0, &imx_ccm_lock, NULL);
  123. }
  124. static inline struct clk *imx_clk_gate3(const char *name, const char *parent,
  125. void __iomem *reg, u8 shift)
  126. {
  127. return clk_register_gate(NULL, name, parent,
  128. CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
  129. reg, shift, 0, &imx_ccm_lock);
  130. }
  131. static inline struct clk *imx_clk_gate4(const char *name, const char *parent,
  132. void __iomem *reg, u8 shift)
  133. {
  134. return clk_register_gate2(NULL, name, parent,
  135. CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
  136. reg, shift, 0x3, 0, &imx_ccm_lock, NULL);
  137. }
  138. static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
  139. u8 shift, u8 width, const char **parents, int num_parents)
  140. {
  141. return clk_register_mux(NULL, name, parents, num_parents,
  142. CLK_SET_RATE_NO_REPARENT, reg, shift,
  143. width, 0, &imx_ccm_lock);
  144. }
  145. static inline struct clk *imx_clk_mux2(const char *name, void __iomem *reg,
  146. u8 shift, u8 width, const char **parents, int num_parents)
  147. {
  148. return clk_register_mux(NULL, name, parents, num_parents,
  149. CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE,
  150. reg, shift, width, 0, &imx_ccm_lock);
  151. }
  152. static inline struct clk *imx_clk_mux_flags(const char *name,
  153. void __iomem *reg, u8 shift, u8 width, const char **parents,
  154. int num_parents, unsigned long flags)
  155. {
  156. return clk_register_mux(NULL, name, parents, num_parents,
  157. flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0,
  158. &imx_ccm_lock);
  159. }
  160. struct clk *imx_clk_cpu(const char *name, const char *parent_name,
  161. struct clk *div, struct clk *mux, struct clk *pll,
  162. struct clk *step);
  163. #endif