clk.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. struct clk * imx_obtain_fixed_clock(
  25. const char *name, unsigned long rate);
  26. static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
  27. void __iomem *reg, u8 shift)
  28. {
  29. return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  30. shift, 0, &imx_ccm_lock);
  31. }
  32. struct clk *imx_clk_pfd(const char *name, const char *parent_name,
  33. void __iomem *reg, u8 idx);
  34. struct clk *imx_clk_busy_divider(const char *name, const char *parent_name,
  35. void __iomem *reg, u8 shift, u8 width,
  36. void __iomem *busy_reg, u8 busy_shift);
  37. struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift,
  38. u8 width, void __iomem *busy_reg, u8 busy_shift,
  39. const char **parent_names, int num_parents);
  40. struct clk *imx_clk_fixup_divider(const char *name, const char *parent,
  41. void __iomem *reg, u8 shift, u8 width,
  42. void (*fixup)(u32 *val));
  43. struct clk *imx_clk_fixup_mux(const char *name, void __iomem *reg,
  44. u8 shift, u8 width, const char **parents,
  45. int num_parents, void (*fixup)(u32 *val));
  46. static inline struct clk *imx_clk_fixed(const char *name, int rate)
  47. {
  48. return clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
  49. }
  50. static inline struct clk *imx_clk_divider(const char *name, const char *parent,
  51. void __iomem *reg, u8 shift, u8 width)
  52. {
  53. return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
  54. reg, shift, width, 0, &imx_ccm_lock);
  55. }
  56. static inline struct clk *imx_clk_divider_flags(const char *name,
  57. const char *parent, void __iomem *reg, u8 shift, u8 width,
  58. unsigned long flags)
  59. {
  60. return clk_register_divider(NULL, name, parent, flags,
  61. reg, shift, width, 0, &imx_ccm_lock);
  62. }
  63. static inline struct clk *imx_clk_gate(const char *name, const char *parent,
  64. void __iomem *reg, u8 shift)
  65. {
  66. return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
  67. shift, 0, &imx_ccm_lock);
  68. }
  69. static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
  70. u8 shift, u8 width, const char **parents, int num_parents)
  71. {
  72. return clk_register_mux(NULL, name, parents, num_parents,
  73. CLK_SET_RATE_NO_REPARENT, reg, shift,
  74. width, 0, &imx_ccm_lock);
  75. }
  76. static inline struct clk *imx_clk_mux_flags(const char *name,
  77. void __iomem *reg, u8 shift, u8 width, const char **parents,
  78. int num_parents, unsigned long flags)
  79. {
  80. return clk_register_mux(NULL, name, parents, num_parents,
  81. flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0,
  82. &imx_ccm_lock);
  83. }
  84. static inline struct clk *imx_clk_fixed_factor(const char *name,
  85. const char *parent, unsigned int mult, unsigned int div)
  86. {
  87. return clk_register_fixed_factor(NULL, name, parent,
  88. CLK_SET_RATE_PARENT, mult, div);
  89. }
  90. #endif