clk.h 3.1 KB

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