clk.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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. IMX_PLLV3_SYS_VF610,
  30. IMX_PLLV3_DDR_IMX7,
  31. };
  32. struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
  33. const char *parent_name, void __iomem *base, u32 div_mask);
  34. struct clk *clk_register_gate2(struct device *dev, const char *name,
  35. const char *parent_name, unsigned long flags,
  36. void __iomem *reg, u8 bit_idx, u8 cgr_val,
  37. u8 clk_gate_flags, spinlock_t *lock,
  38. unsigned int *share_count);
  39. struct clk * imx_obtain_fixed_clock(
  40. const char *name, unsigned long rate);
  41. struct clk *imx_clk_gate_exclusive(const char *name, const char *parent,
  42. void __iomem *reg, u8 shift, u32 exclusive_mask);
  43. struct clk *imx_clk_pfd(const char *name, const char *parent_name,
  44. void __iomem *reg, u8 idx);
  45. struct clk *imx_clk_busy_divider(const char *name, const char *parent_name,
  46. void __iomem *reg, u8 shift, u8 width,
  47. void __iomem *busy_reg, u8 busy_shift);
  48. struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift,
  49. u8 width, void __iomem *busy_reg, u8 busy_shift,
  50. const char **parent_names, int num_parents);
  51. struct clk *imx_clk_fixup_divider(const char *name, const char *parent,
  52. void __iomem *reg, u8 shift, u8 width,
  53. void (*fixup)(u32 *val));
  54. struct clk *imx_clk_fixup_mux(const char *name, void __iomem *reg,
  55. u8 shift, u8 width, const char **parents,
  56. int num_parents, void (*fixup)(u32 *val));
  57. static inline struct clk *imx_clk_fixed(const char *name, int rate)
  58. {
  59. return clk_register_fixed_rate(NULL, name, NULL, 0, rate);
  60. }
  61. static inline struct clk *imx_clk_mux_ldb(const char *name, void __iomem *reg,
  62. u8 shift, u8 width, const char **parents, int num_parents)
  63. {
  64. return clk_register_mux(NULL, name, parents, num_parents,
  65. CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, reg,
  66. shift, width, CLK_MUX_READ_ONLY, &imx_ccm_lock);
  67. }
  68. static inline struct clk *imx_clk_fixed_factor(const char *name,
  69. const char *parent, unsigned int mult, unsigned int div)
  70. {
  71. return clk_register_fixed_factor(NULL, name, parent,
  72. CLK_SET_RATE_PARENT, mult, div);
  73. }
  74. static inline struct clk *imx_clk_divider(const char *name, const char *parent,
  75. void __iomem *reg, u8 shift, u8 width)
  76. {
  77. return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
  78. reg, shift, width, 0, &imx_ccm_lock);
  79. }
  80. static inline struct clk *imx_clk_divider_flags(const char *name,
  81. const char *parent, void __iomem *reg, u8 shift, u8 width,
  82. unsigned long flags)
  83. {
  84. return clk_register_divider(NULL, name, parent, flags,
  85. reg, shift, width, 0, &imx_ccm_lock);
  86. }
  87. static inline struct clk *imx_clk_divider2(const char *name, const char *parent,
  88. void __iomem *reg, u8 shift, u8 width)
  89. {
  90. return clk_register_divider(NULL, name, parent,
  91. CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
  92. reg, shift, width, 0, &imx_ccm_lock);
  93. }
  94. static inline struct clk *imx_clk_gate(const char *name, const char *parent,
  95. void __iomem *reg, u8 shift)
  96. {
  97. return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  98. shift, 0, &imx_ccm_lock);
  99. }
  100. static inline struct clk *imx_clk_gate_dis(const char *name, const char *parent,
  101. void __iomem *reg, u8 shift)
  102. {
  103. return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  104. shift, CLK_GATE_SET_TO_DISABLE, &imx_ccm_lock);
  105. }
  106. static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
  107. void __iomem *reg, u8 shift)
  108. {
  109. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  110. shift, 0x3, 0, &imx_ccm_lock, NULL);
  111. }
  112. static inline struct clk *imx_clk_gate2_shared(const char *name,
  113. const char *parent, void __iomem *reg, u8 shift,
  114. unsigned int *share_count)
  115. {
  116. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  117. shift, 0x3, 0, &imx_ccm_lock, share_count);
  118. }
  119. static inline struct clk *imx_clk_gate2_shared2(const char *name,
  120. const char *parent, void __iomem *reg, u8 shift,
  121. unsigned int *share_count)
  122. {
  123. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT |
  124. CLK_OPS_PARENT_ENABLE, reg, shift, 0x3, 0,
  125. &imx_ccm_lock, share_count);
  126. }
  127. static inline struct clk *imx_clk_gate2_cgr(const char *name,
  128. const char *parent, void __iomem *reg, u8 shift, u8 cgr_val)
  129. {
  130. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  131. shift, cgr_val, 0, &imx_ccm_lock, NULL);
  132. }
  133. static inline struct clk *imx_clk_gate3(const char *name, const char *parent,
  134. void __iomem *reg, u8 shift)
  135. {
  136. return clk_register_gate(NULL, name, parent,
  137. CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
  138. reg, shift, 0, &imx_ccm_lock);
  139. }
  140. static inline struct clk *imx_clk_gate4(const char *name, const char *parent,
  141. void __iomem *reg, u8 shift)
  142. {
  143. return clk_register_gate2(NULL, name, parent,
  144. CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
  145. reg, shift, 0x3, 0, &imx_ccm_lock, NULL);
  146. }
  147. static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
  148. u8 shift, u8 width, const char **parents, int num_parents)
  149. {
  150. return clk_register_mux(NULL, name, parents, num_parents,
  151. CLK_SET_RATE_NO_REPARENT, reg, shift,
  152. width, 0, &imx_ccm_lock);
  153. }
  154. static inline struct clk *imx_clk_mux2(const char *name, void __iomem *reg,
  155. u8 shift, u8 width, const char **parents, int num_parents)
  156. {
  157. return clk_register_mux(NULL, name, parents, num_parents,
  158. CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE,
  159. reg, shift, width, 0, &imx_ccm_lock);
  160. }
  161. static inline struct clk *imx_clk_mux_flags(const char *name,
  162. void __iomem *reg, u8 shift, u8 width, const char **parents,
  163. int num_parents, unsigned long flags)
  164. {
  165. return clk_register_mux(NULL, name, parents, num_parents,
  166. flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0,
  167. &imx_ccm_lock);
  168. }
  169. struct clk *imx_clk_cpu(const char *name, const char *parent_name,
  170. struct clk *div, struct clk *mux, struct clk *pll,
  171. struct clk *step);
  172. #endif