1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef __LINUX_CLK_TI_H__
16#define __LINUX_CLK_TI_H__
17
18#include <linux/clk-provider.h>
19#include <linux/clkdev.h>
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68struct dpll_data {
69 void __iomem *mult_div1_reg;
70 u32 mult_mask;
71 u32 div1_mask;
72 struct clk *clk_bypass;
73 struct clk *clk_ref;
74 void __iomem *control_reg;
75 u32 enable_mask;
76 unsigned long last_rounded_rate;
77 u16 last_rounded_m;
78 u8 last_rounded_m4xen;
79 u8 last_rounded_lpmode;
80 u16 max_multiplier;
81 u8 last_rounded_n;
82 u8 min_divider;
83 u16 max_divider;
84 u8 modes;
85 void __iomem *autoidle_reg;
86 void __iomem *idlest_reg;
87 u32 autoidle_mask;
88 u32 freqsel_mask;
89 u32 idlest_mask;
90 u32 dco_mask;
91 u32 sddiv_mask;
92 u32 dcc_mask;
93 unsigned long dcc_rate;
94 u32 lpmode_mask;
95 u32 m4xen_mask;
96 u8 auto_recal_bit;
97 u8 recal_en_bit;
98 u8 recal_st_bit;
99 u8 flags;
100};
101
102struct clk_hw_omap;
103
104
105
106
107
108
109
110
111
112struct clk_hw_omap_ops {
113 void (*find_idlest)(struct clk_hw_omap *oclk,
114 void __iomem **idlest_reg,
115 u8 *idlest_bit, u8 *idlest_val);
116 void (*find_companion)(struct clk_hw_omap *oclk,
117 void __iomem **other_reg,
118 u8 *other_bit);
119 void (*allow_idle)(struct clk_hw_omap *oclk);
120 void (*deny_idle)(struct clk_hw_omap *oclk);
121};
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137struct clk_hw_omap {
138 struct clk_hw hw;
139 struct list_head node;
140 unsigned long fixed_rate;
141 u8 fixed_div;
142 void __iomem *enable_reg;
143 u8 enable_bit;
144 u8 flags;
145 void __iomem *clksel_reg;
146 u32 clksel_mask;
147 const struct clksel *clksel;
148 struct dpll_data *dpll_data;
149 const char *clkdm_name;
150 struct clockdomain *clkdm;
151 const struct clk_hw_omap_ops *ops;
152};
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175#define ENABLE_REG_32BIT (1 << 0)
176#define CLOCK_IDLE_CONTROL (1 << 1)
177#define CLOCK_NO_IDLE_PARENT (1 << 2)
178#define ENABLE_ON_INIT (1 << 3)
179#define INVERT_ENABLE (1 << 4)
180#define CLOCK_CLKOUTX2 (1 << 5)
181#define MEMMAP_ADDRESSING (1 << 6)
182
183
184#define DPLL_LOW_POWER_STOP 0x1
185#define DPLL_LOW_POWER_BYPASS 0x5
186#define DPLL_LOCKED 0x7
187
188
189#define DPLL_J_TYPE 0x1
190
191
192enum {
193 CLK_COMPONENT_TYPE_GATE = 0,
194 CLK_COMPONENT_TYPE_DIVIDER,
195 CLK_COMPONENT_TYPE_MUX,
196 CLK_COMPONENT_TYPE_MAX,
197};
198
199
200
201
202
203
204struct ti_dt_clk {
205 struct clk_lookup lk;
206 char *node_name;
207};
208
209#define DT_CLK(dev, con, name) \
210 { \
211 .lk = { \
212 .dev_id = dev, \
213 .con_id = con, \
214 }, \
215 .node_name = name, \
216 }
217
218
219enum {
220 TI_CLKM_CM = 0,
221 TI_CLKM_CM2,
222 TI_CLKM_PRM,
223 TI_CLKM_SCRM,
224 TI_CLKM_CTRL,
225 CLK_MAX_MEMMAPS
226};
227
228typedef void (*ti_of_clk_init_cb_t)(struct clk_hw *, struct device_node *);
229
230
231
232
233
234
235struct clk_omap_reg {
236 u16 offset;
237 u16 index;
238};
239
240
241
242
243
244
245
246
247
248
249
250struct ti_clk_ll_ops {
251 u32 (*clk_readl)(void __iomem *reg);
252 void (*clk_writel)(u32 val, void __iomem *reg);
253};
254
255extern struct ti_clk_ll_ops *ti_clk_ll_ops;
256
257extern const struct clk_ops ti_clk_divider_ops;
258extern const struct clk_ops ti_clk_mux_ops;
259
260#define to_clk_hw_omap(_hw) container_of(_hw, struct clk_hw_omap, hw)
261
262void omap2_init_clk_hw_omap_clocks(struct clk *clk);
263int omap3_noncore_dpll_enable(struct clk_hw *hw);
264void omap3_noncore_dpll_disable(struct clk_hw *hw);
265int omap3_noncore_dpll_set_parent(struct clk_hw *hw, u8 index);
266int omap3_noncore_dpll_set_rate(struct clk_hw *hw, unsigned long rate,
267 unsigned long parent_rate);
268int omap3_noncore_dpll_set_rate_and_parent(struct clk_hw *hw,
269 unsigned long rate,
270 unsigned long parent_rate,
271 u8 index);
272long omap3_noncore_dpll_determine_rate(struct clk_hw *hw,
273 unsigned long rate,
274 unsigned long min_rate,
275 unsigned long max_rate,
276 unsigned long *best_parent_rate,
277 struct clk_hw **best_parent_clk);
278unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw,
279 unsigned long parent_rate);
280long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw,
281 unsigned long target_rate,
282 unsigned long *parent_rate);
283long omap4_dpll_regm4xen_determine_rate(struct clk_hw *hw,
284 unsigned long rate,
285 unsigned long min_rate,
286 unsigned long max_rate,
287 unsigned long *best_parent_rate,
288 struct clk_hw **best_parent_clk);
289u8 omap2_init_dpll_parent(struct clk_hw *hw);
290unsigned long omap3_dpll_recalc(struct clk_hw *hw, unsigned long parent_rate);
291long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
292 unsigned long *parent_rate);
293void omap2_init_clk_clkdm(struct clk_hw *clk);
294unsigned long omap3_clkoutx2_recalc(struct clk_hw *hw,
295 unsigned long parent_rate);
296int omap3_clkoutx2_set_rate(struct clk_hw *hw, unsigned long rate,
297 unsigned long parent_rate);
298long omap3_clkoutx2_round_rate(struct clk_hw *hw, unsigned long rate,
299 unsigned long *prate);
300int omap2_clkops_enable_clkdm(struct clk_hw *hw);
301void omap2_clkops_disable_clkdm(struct clk_hw *hw);
302int omap2_clk_disable_autoidle_all(void);
303void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks);
304int omap3_dpll4_set_rate(struct clk_hw *clk, unsigned long rate,
305 unsigned long parent_rate);
306int omap3_dpll4_set_rate_and_parent(struct clk_hw *hw, unsigned long rate,
307 unsigned long parent_rate, u8 index);
308int omap2_dflt_clk_enable(struct clk_hw *hw);
309void omap2_dflt_clk_disable(struct clk_hw *hw);
310int omap2_dflt_clk_is_enabled(struct clk_hw *hw);
311void omap3_clk_lock_dpll5(void);
312unsigned long omap2_dpllcore_recalc(struct clk_hw *hw,
313 unsigned long parent_rate);
314int omap2_reprogram_dpllcore(struct clk_hw *clk, unsigned long rate,
315 unsigned long parent_rate);
316void omap2xxx_clkt_dpllcore_init(struct clk_hw *hw);
317void omap2xxx_clkt_vps_init(void);
318
319void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index);
320void ti_dt_clocks_register(struct ti_dt_clk *oclks);
321void ti_dt_clk_init_provider(struct device_node *np, int index);
322void ti_dt_clk_init_retry_clks(void);
323void ti_dt_clockdomains_setup(void);
324int ti_clk_retry_init(struct device_node *node, struct clk_hw *hw,
325 ti_of_clk_init_cb_t func);
326int of_ti_clk_autoidle_setup(struct device_node *node);
327int ti_clk_add_component(struct device_node *node, struct clk_hw *hw, int type);
328
329int omap3430_dt_clk_init(void);
330int omap3630_dt_clk_init(void);
331int am35xx_dt_clk_init(void);
332int ti81xx_dt_clk_init(void);
333int omap4xxx_dt_clk_init(void);
334int omap5xxx_dt_clk_init(void);
335int dra7xx_dt_clk_init(void);
336int am33xx_dt_clk_init(void);
337int am43xx_dt_clk_init(void);
338int omap2420_dt_clk_init(void);
339int omap2430_dt_clk_init(void);
340
341#ifdef CONFIG_OF
342void of_ti_clk_allow_autoidle_all(void);
343void of_ti_clk_deny_autoidle_all(void);
344#else
345static inline void of_ti_clk_allow_autoidle_all(void) { }
346static inline void of_ti_clk_deny_autoidle_all(void) { }
347#endif
348
349extern const struct clk_hw_omap_ops clkhwops_omap2xxx_dpll;
350extern const struct clk_hw_omap_ops clkhwops_omap2430_i2chs_wait;
351extern const struct clk_hw_omap_ops clkhwops_omap3_dpll;
352extern const struct clk_hw_omap_ops clkhwops_omap4_dpllmx;
353extern const struct clk_hw_omap_ops clkhwops_wait;
354extern const struct clk_hw_omap_ops clkhwops_omap3430es2_dss_usbhost_wait;
355extern const struct clk_hw_omap_ops clkhwops_am35xx_ipss_module_wait;
356extern const struct clk_hw_omap_ops clkhwops_am35xx_ipss_wait;
357extern const struct clk_hw_omap_ops clkhwops_iclk;
358extern const struct clk_hw_omap_ops clkhwops_iclk_wait;
359extern const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_ssi_wait;
360extern const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_dss_usbhost_wait;
361extern const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_hsotgusb_wait;
362
363#ifdef CONFIG_ATAGS
364int omap3430_clk_legacy_init(void);
365int omap3430es1_clk_legacy_init(void);
366int omap36xx_clk_legacy_init(void);
367int am35xx_clk_legacy_init(void);
368#else
369static inline int omap3430_clk_legacy_init(void) { return -ENXIO; }
370static inline int omap3430es1_clk_legacy_init(void) { return -ENXIO; }
371static inline int omap36xx_clk_legacy_init(void) { return -ENXIO; }
372static inline int am35xx_clk_legacy_init(void) { return -ENXIO; }
373#endif
374
375
376#endif
377