clk.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. struct clk *imx_clk_gate_exclusive(const char *name, const char *parent,
  29. void __iomem *reg, u8 shift, u32 exclusive_mask);
  30. static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
  31. void __iomem *reg, u8 shift)
  32. {
  33. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  34. shift, 0, &imx_ccm_lock, NULL);
  35. }
  36. static inline struct clk *imx_clk_gate2_shared(const char *name,
  37. const char *parent, void __iomem *reg, u8 shift,
  38. unsigned int *share_count)
  39. {
  40. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  41. shift, 0, &imx_ccm_lock, share_count);
  42. }
  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, CLK_IS_ROOT, rate);
  60. }
  61. static inline struct clk *imx_clk_divider(const char *name, const char *parent,
  62. void __iomem *reg, u8 shift, u8 width)
  63. {
  64. return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
  65. reg, shift, width, 0, &imx_ccm_lock);
  66. }
  67. static inline struct clk *imx_clk_divider_flags(const char *name,
  68. const char *parent, void __iomem *reg, u8 shift, u8 width,
  69. unsigned long flags)
  70. {
  71. return clk_register_divider(NULL, name, parent, flags,
  72. reg, shift, width, 0, &imx_ccm_lock);
  73. }
  74. static inline struct clk *imx_clk_gate(const char *name, const char *parent,
  75. void __iomem *reg, u8 shift)
  76. {
  77. return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  78. shift, 0, &imx_ccm_lock);
  79. }
  80. static inline struct clk *imx_clk_gate_dis(const char *name, const char *parent,
  81. void __iomem *reg, u8 shift)
  82. {
  83. return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  84. shift, CLK_GATE_SET_TO_DISABLE, &imx_ccm_lock);
  85. }
  86. static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
  87. u8 shift, u8 width, const char **parents, int num_parents)
  88. {
  89. return clk_register_mux(NULL, name, parents, num_parents,
  90. CLK_SET_RATE_NO_REPARENT, reg, shift,
  91. width, 0, &imx_ccm_lock);
  92. }
  93. static inline struct clk *imx_clk_mux_flags(const char *name,
  94. void __iomem *reg, u8 shift, u8 width, const char **parents,
  95. int num_parents, unsigned long flags)
  96. {
  97. return clk_register_mux(NULL, name, parents, num_parents,
  98. flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0,
  99. &imx_ccm_lock);
  100. }
  101. static inline struct clk *imx_clk_fixed_factor(const char *name,
  102. const char *parent, unsigned int mult, unsigned int div)
  103. {
  104. return clk_register_fixed_factor(NULL, name, parent,
  105. CLK_SET_RATE_PARENT, mult, div);
  106. }
  107. #endif