clk.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. struct clk *imx_clk_pllv1(const char *name, const char *parent,
  9. void __iomem *base);
  10. struct clk *imx_clk_pllv2(const char *name, const char *parent,
  11. void __iomem *base);
  12. enum imx_pllv3_type {
  13. IMX_PLLV3_GENERIC,
  14. IMX_PLLV3_SYS,
  15. IMX_PLLV3_USB,
  16. IMX_PLLV3_AV,
  17. IMX_PLLV3_ENET,
  18. };
  19. struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
  20. const char *parent_name, void __iomem *base, u32 div_mask);
  21. struct clk *clk_register_gate2(struct device *dev, const char *name,
  22. const char *parent_name, unsigned long flags,
  23. void __iomem *reg, u8 bit_idx,
  24. u8 clk_gate_flags, spinlock_t *lock,
  25. unsigned int *share_count);
  26. struct clk * imx_obtain_fixed_clock(
  27. const char *name, unsigned long rate);
  28. static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
  29. void __iomem *reg, u8 shift)
  30. {
  31. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  32. shift, 0, &imx_ccm_lock, NULL);
  33. }
  34. static inline struct clk *imx_clk_gate2_shared(const char *name,
  35. const char *parent, void __iomem *reg, u8 shift,
  36. unsigned int *share_count)
  37. {
  38. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  39. shift, 0, &imx_ccm_lock, share_count);
  40. }
  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, CLK_IS_ROOT, rate);
  58. }
  59. static inline struct clk *imx_clk_divider(const char *name, const char *parent,
  60. void __iomem *reg, u8 shift, u8 width)
  61. {
  62. return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
  63. reg, shift, width, 0, &imx_ccm_lock);
  64. }
  65. static inline struct clk *imx_clk_divider_flags(const char *name,
  66. const char *parent, void __iomem *reg, u8 shift, u8 width,
  67. unsigned long flags)
  68. {
  69. return clk_register_divider(NULL, name, parent, flags,
  70. reg, shift, width, 0, &imx_ccm_lock);
  71. }
  72. static inline struct clk *imx_clk_gate(const char *name, const char *parent,
  73. void __iomem *reg, u8 shift)
  74. {
  75. return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  76. shift, 0, &imx_ccm_lock);
  77. }
  78. static inline struct clk *imx_clk_gate_dis(const char *name, const char *parent,
  79. void __iomem *reg, u8 shift)
  80. {
  81. return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  82. shift, CLK_GATE_SET_TO_DISABLE, &imx_ccm_lock);
  83. }
  84. static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
  85. u8 shift, u8 width, const char **parents, int num_parents)
  86. {
  87. return clk_register_mux(NULL, name, parents, num_parents,
  88. CLK_SET_RATE_NO_REPARENT, reg, shift,
  89. width, 0, &imx_ccm_lock);
  90. }
  91. static inline struct clk *imx_clk_mux_flags(const char *name,
  92. void __iomem *reg, u8 shift, u8 width, const char **parents,
  93. int num_parents, unsigned long flags)
  94. {
  95. return clk_register_mux(NULL, name, parents, num_parents,
  96. flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0,
  97. &imx_ccm_lock);
  98. }
  99. static inline struct clk *imx_clk_fixed_factor(const char *name,
  100. const char *parent, unsigned int mult, unsigned int div)
  101. {
  102. return clk_register_fixed_factor(NULL, name, parent,
  103. CLK_SET_RATE_PARENT, mult, div);
  104. }
  105. #endif