clk.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. extern void imx_cscmr1_fixup(u32 *val);
  8. enum imx_pllv1_type {
  9. IMX_PLLV1_IMX1,
  10. IMX_PLLV1_IMX21,
  11. IMX_PLLV1_IMX25,
  12. IMX_PLLV1_IMX27,
  13. IMX_PLLV1_IMX31,
  14. IMX_PLLV1_IMX35,
  15. };
  16. struct clk *imx_clk_pllv1(enum imx_pllv1_type type, const char *name,
  17. const char *parent, void __iomem *base);
  18. struct clk *imx_clk_pllv2(const char *name, const char *parent,
  19. void __iomem *base);
  20. enum imx_pllv3_type {
  21. IMX_PLLV3_GENERIC,
  22. IMX_PLLV3_SYS,
  23. IMX_PLLV3_USB,
  24. IMX_PLLV3_USB_VF610,
  25. IMX_PLLV3_AV,
  26. IMX_PLLV3_ENET,
  27. IMX_PLLV3_ENET_IMX7,
  28. };
  29. struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
  30. const char *parent_name, void __iomem *base, u32 div_mask);
  31. struct clk *clk_register_gate2(struct device *dev, const char *name,
  32. const char *parent_name, unsigned long flags,
  33. void __iomem *reg, u8 bit_idx,
  34. u8 clk_gate_flags, spinlock_t *lock,
  35. unsigned int *share_count);
  36. struct clk * imx_obtain_fixed_clock(
  37. const char *name, unsigned long rate);
  38. struct clk *imx_clk_gate_exclusive(const char *name, const char *parent,
  39. void __iomem *reg, u8 shift, u32 exclusive_mask);
  40. static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
  41. void __iomem *reg, u8 shift)
  42. {
  43. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  44. shift, 0, &imx_ccm_lock, NULL);
  45. }
  46. static inline struct clk *imx_clk_gate2_shared(const char *name,
  47. const char *parent, void __iomem *reg, u8 shift,
  48. unsigned int *share_count)
  49. {
  50. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  51. shift, 0, &imx_ccm_lock, share_count);
  52. }
  53. struct clk *imx_clk_pfd(const char *name, const char *parent_name,
  54. void __iomem *reg, u8 idx);
  55. struct clk *imx_clk_busy_divider(const char *name, const char *parent_name,
  56. void __iomem *reg, u8 shift, u8 width,
  57. void __iomem *busy_reg, u8 busy_shift);
  58. struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift,
  59. u8 width, void __iomem *busy_reg, u8 busy_shift,
  60. const char **parent_names, int num_parents);
  61. struct clk *imx_clk_fixup_divider(const char *name, const char *parent,
  62. void __iomem *reg, u8 shift, u8 width,
  63. void (*fixup)(u32 *val));
  64. struct clk *imx_clk_fixup_mux(const char *name, void __iomem *reg,
  65. u8 shift, u8 width, const char **parents,
  66. int num_parents, void (*fixup)(u32 *val));
  67. static inline struct clk *imx_clk_fixed(const char *name, int rate)
  68. {
  69. return clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
  70. }
  71. static inline struct clk *imx_clk_divider(const char *name, const char *parent,
  72. void __iomem *reg, u8 shift, u8 width)
  73. {
  74. return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
  75. reg, shift, width, 0, &imx_ccm_lock);
  76. }
  77. static inline struct clk *imx_clk_divider_flags(const char *name,
  78. const char *parent, void __iomem *reg, u8 shift, u8 width,
  79. unsigned long flags)
  80. {
  81. return clk_register_divider(NULL, name, parent, flags,
  82. reg, shift, width, 0, &imx_ccm_lock);
  83. }
  84. static inline struct clk *imx_clk_gate(const char *name, const char *parent,
  85. void __iomem *reg, u8 shift)
  86. {
  87. return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  88. shift, 0, &imx_ccm_lock);
  89. }
  90. static inline struct clk *imx_clk_gate_dis(const char *name, const char *parent,
  91. void __iomem *reg, u8 shift)
  92. {
  93. return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  94. shift, CLK_GATE_SET_TO_DISABLE, &imx_ccm_lock);
  95. }
  96. static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
  97. u8 shift, u8 width, const char **parents, int num_parents)
  98. {
  99. return clk_register_mux(NULL, name, parents, num_parents,
  100. CLK_SET_RATE_NO_REPARENT, reg, shift,
  101. width, 0, &imx_ccm_lock);
  102. }
  103. static inline struct clk *imx_clk_mux_flags(const char *name,
  104. void __iomem *reg, u8 shift, u8 width, const char **parents,
  105. int num_parents, unsigned long flags)
  106. {
  107. return clk_register_mux(NULL, name, parents, num_parents,
  108. flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0,
  109. &imx_ccm_lock);
  110. }
  111. static inline struct clk *imx_clk_fixed_factor(const char *name,
  112. const char *parent, unsigned int mult, unsigned int div)
  113. {
  114. return clk_register_fixed_factor(NULL, name, parent,
  115. CLK_SET_RATE_PARENT, mult, div);
  116. }
  117. struct clk *imx_clk_cpu(const char *name, const char *parent_name,
  118. struct clk *div, struct clk *mux, struct clk *pll,
  119. struct clk *step);
  120. #endif