clk.h 3.7 KB

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