1 #ifndef __MACH_IMX_CLK_H
2 #define __MACH_IMX_CLK_H
4 #include <linux/spinlock.h>
5 #include <linux/clk-provider.h>
7 extern spinlock_t imx_ccm_lock;
10 * This is a stop-gap solution for clock drivers like imx1/imx21 which call
11 * mxc_timer_init() to initialize timer for non-DT boot. It can be removed
12 * when these legacy non-DT support is converted or dropped.
14 void mxc_timer_init(unsigned long pbase, int irq);
16 void imx_check_clocks(struct clk *clks[], unsigned int count);
18 extern void imx_cscmr1_fixup(u32 *val);
29 struct clk *imx_clk_pllv1(enum imx_pllv1_type type, const char *name,
30 const char *parent, void __iomem *base);
32 struct clk *imx_clk_pllv2(const char *name, const char *parent,
44 struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
45 const char *parent_name, void __iomem *base, u32 div_mask);
47 struct clk *clk_register_gate2(struct device *dev, const char *name,
48 const char *parent_name, unsigned long flags,
49 void __iomem *reg, u8 bit_idx,
50 u8 clk_gate_flags, spinlock_t *lock,
51 unsigned int *share_count);
53 struct clk * imx_obtain_fixed_clock(
54 const char *name, unsigned long rate);
56 struct clk *imx_clk_gate_exclusive(const char *name, const char *parent,
57 void __iomem *reg, u8 shift, u32 exclusive_mask);
59 static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
60 void __iomem *reg, u8 shift)
62 return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
63 shift, 0, &imx_ccm_lock, NULL);
66 static inline struct clk *imx_clk_gate2_shared(const char *name,
67 const char *parent, void __iomem *reg, u8 shift,
68 unsigned int *share_count)
70 return clk_register_gate2(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
71 shift, 0, &imx_ccm_lock, share_count);
74 struct clk *imx_clk_pfd(const char *name, const char *parent_name,
75 void __iomem *reg, u8 idx);
77 struct clk *imx_clk_busy_divider(const char *name, const char *parent_name,
78 void __iomem *reg, u8 shift, u8 width,
79 void __iomem *busy_reg, u8 busy_shift);
81 struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift,
82 u8 width, void __iomem *busy_reg, u8 busy_shift,
83 const char **parent_names, int num_parents);
85 struct clk *imx_clk_fixup_divider(const char *name, const char *parent,
86 void __iomem *reg, u8 shift, u8 width,
87 void (*fixup)(u32 *val));
89 struct clk *imx_clk_fixup_mux(const char *name, void __iomem *reg,
90 u8 shift, u8 width, const char **parents,
91 int num_parents, void (*fixup)(u32 *val));
93 static inline struct clk *imx_clk_fixed(const char *name, int rate)
95 return clk_register_fixed_rate(NULL, name, NULL, CLK_IS_ROOT, rate);
98 static inline struct clk *imx_clk_divider(const char *name, const char *parent,
99 void __iomem *reg, u8 shift, u8 width)
101 return clk_register_divider(NULL, name, parent, CLK_SET_RATE_PARENT,
102 reg, shift, width, 0, &imx_ccm_lock);
105 static inline struct clk *imx_clk_divider_flags(const char *name,
106 const char *parent, void __iomem *reg, u8 shift, u8 width,
109 return clk_register_divider(NULL, name, parent, flags,
110 reg, shift, width, 0, &imx_ccm_lock);
113 static inline struct clk *imx_clk_gate(const char *name, const char *parent,
114 void __iomem *reg, u8 shift)
116 return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
117 shift, 0, &imx_ccm_lock);
120 static inline struct clk *imx_clk_gate_dis(const char *name, const char *parent,
121 void __iomem *reg, u8 shift)
123 return clk_register_gate(NULL, name, parent, CLK_SET_RATE_PARENT, reg,
124 shift, CLK_GATE_SET_TO_DISABLE, &imx_ccm_lock);
127 static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
128 u8 shift, u8 width, const char **parents, int num_parents)
130 return clk_register_mux(NULL, name, parents, num_parents,
131 CLK_SET_RATE_NO_REPARENT, reg, shift,
132 width, 0, &imx_ccm_lock);
135 static inline struct clk *imx_clk_mux_flags(const char *name,
136 void __iomem *reg, u8 shift, u8 width, const char **parents,
137 int num_parents, unsigned long flags)
139 return clk_register_mux(NULL, name, parents, num_parents,
140 flags | CLK_SET_RATE_NO_REPARENT, reg, shift, width, 0,
144 static inline struct clk *imx_clk_fixed_factor(const char *name,
145 const char *parent, unsigned int mult, unsigned int div)
147 return clk_register_fixed_factor(NULL, name, parent,
148 CLK_SET_RATE_PARENT, mult, div);
151 struct clk *imx_clk_cpu(const char *name, const char *parent_name,
152 struct clk *div, struct clk *mux, struct clk *pll,