clk.h 6.4 KB

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