xref: /linux/arch/arm/mach-omap2/clock.h (revision a135eaae524acba1509a3b19c97fae556e4da7cd)
1543d9378SPaul Walmsley /*
2543d9378SPaul Walmsley  *  linux/arch/arm/mach-omap2/clock.h
3543d9378SPaul Walmsley  *
4d8a94458SPaul Walmsley  *  Copyright (C) 2005-2009 Texas Instruments, Inc.
5530e544fSPaul Walmsley  *  Copyright (C) 2004-2011 Nokia Corporation
6a16e9703STony Lindgren  *
7a16e9703STony Lindgren  *  Contacts:
8543d9378SPaul Walmsley  *  Richard Woodruff <r-woodruff2@ti.com>
9543d9378SPaul Walmsley  *  Paul Walmsley
10543d9378SPaul Walmsley  *
11543d9378SPaul Walmsley  * This program is free software; you can redistribute it and/or modify
12543d9378SPaul Walmsley  * it under the terms of the GNU General Public License version 2 as
13543d9378SPaul Walmsley  * published by the Free Software Foundation.
14543d9378SPaul Walmsley  */
15543d9378SPaul Walmsley 
16543d9378SPaul Walmsley #ifndef __ARCH_ARM_MACH_OMAP2_CLOCK_H
17543d9378SPaul Walmsley #define __ARCH_ARM_MACH_OMAP2_CLOCK_H
18543d9378SPaul Walmsley 
1912706c54SPaul Walmsley #include <linux/kernel.h>
20*a135eaaeSPaul Walmsley #include <linux/list.h>
2112706c54SPaul Walmsley 
22*a135eaaeSPaul Walmsley struct module;
23*a135eaaeSPaul Walmsley struct clk;
24*a135eaaeSPaul Walmsley struct clockdomain;
25*a135eaaeSPaul Walmsley 
26*a135eaaeSPaul Walmsley /* Temporary, needed during the common clock framework conversion */
27*a135eaaeSPaul Walmsley #define __clk_get_name(clk)	(clk->name)
28*a135eaaeSPaul Walmsley #define __clk_get_parent(clk)	(clk->parent)
29*a135eaaeSPaul Walmsley #define __clk_get_rate(clk)	(clk->rate)
30*a135eaaeSPaul Walmsley 
31*a135eaaeSPaul Walmsley /**
32*a135eaaeSPaul Walmsley  * struct clkops - some clock function pointers
33*a135eaaeSPaul Walmsley  * @enable: fn ptr that enables the current clock in hardware
34*a135eaaeSPaul Walmsley  * @disable: fn ptr that enables the current clock in hardware
35*a135eaaeSPaul Walmsley  * @find_idlest: function returning the IDLEST register for the clock's IP blk
36*a135eaaeSPaul Walmsley  * @find_companion: function returning the "companion" clk reg for the clock
37*a135eaaeSPaul Walmsley  * @allow_idle: fn ptr that enables autoidle for the current clock in hardware
38*a135eaaeSPaul Walmsley  * @deny_idle: fn ptr that disables autoidle for the current clock in hardware
39*a135eaaeSPaul Walmsley  *
40*a135eaaeSPaul Walmsley  * A "companion" clk is an accompanying clock to the one being queried
41*a135eaaeSPaul Walmsley  * that must be enabled for the IP module connected to the clock to
42*a135eaaeSPaul Walmsley  * become accessible by the hardware.  Neither @find_idlest nor
43*a135eaaeSPaul Walmsley  * @find_companion should be needed; that information is IP
44*a135eaaeSPaul Walmsley  * block-specific; the hwmod code has been created to handle this, but
45*a135eaaeSPaul Walmsley  * until hwmod data is ready and drivers have been converted to use PM
46*a135eaaeSPaul Walmsley  * runtime calls in place of clk_enable()/clk_disable(), @find_idlest and
47*a135eaaeSPaul Walmsley  * @find_companion must, unfortunately, remain.
48*a135eaaeSPaul Walmsley  */
49*a135eaaeSPaul Walmsley struct clkops {
50*a135eaaeSPaul Walmsley 	int			(*enable)(struct clk *);
51*a135eaaeSPaul Walmsley 	void			(*disable)(struct clk *);
52*a135eaaeSPaul Walmsley 	void			(*find_idlest)(struct clk *, void __iomem **,
53*a135eaaeSPaul Walmsley 					       u8 *, u8 *);
54*a135eaaeSPaul Walmsley 	void			(*find_companion)(struct clk *, void __iomem **,
55*a135eaaeSPaul Walmsley 						  u8 *);
56*a135eaaeSPaul Walmsley 	void			(*allow_idle)(struct clk *);
57*a135eaaeSPaul Walmsley 	void			(*deny_idle)(struct clk *);
58*a135eaaeSPaul Walmsley };
59*a135eaaeSPaul Walmsley 
60*a135eaaeSPaul Walmsley /* struct clksel_rate.flags possibilities */
61*a135eaaeSPaul Walmsley #define RATE_IN_242X		(1 << 0)
62*a135eaaeSPaul Walmsley #define RATE_IN_243X		(1 << 1)
63*a135eaaeSPaul Walmsley #define RATE_IN_3430ES1		(1 << 2)	/* 3430ES1 rates only */
64*a135eaaeSPaul Walmsley #define RATE_IN_3430ES2PLUS	(1 << 3)	/* 3430 ES >= 2 rates only */
65*a135eaaeSPaul Walmsley #define RATE_IN_36XX		(1 << 4)
66*a135eaaeSPaul Walmsley #define RATE_IN_4430		(1 << 5)
67*a135eaaeSPaul Walmsley #define RATE_IN_TI816X		(1 << 6)
68*a135eaaeSPaul Walmsley #define RATE_IN_4460		(1 << 7)
69*a135eaaeSPaul Walmsley #define RATE_IN_AM33XX		(1 << 8)
70*a135eaaeSPaul Walmsley #define RATE_IN_TI814X		(1 << 9)
71*a135eaaeSPaul Walmsley 
72*a135eaaeSPaul Walmsley #define RATE_IN_24XX		(RATE_IN_242X | RATE_IN_243X)
73*a135eaaeSPaul Walmsley #define RATE_IN_34XX		(RATE_IN_3430ES1 | RATE_IN_3430ES2PLUS)
74*a135eaaeSPaul Walmsley #define RATE_IN_3XXX		(RATE_IN_34XX | RATE_IN_36XX)
75*a135eaaeSPaul Walmsley #define RATE_IN_44XX		(RATE_IN_4430 | RATE_IN_4460)
76*a135eaaeSPaul Walmsley 
77*a135eaaeSPaul Walmsley /* RATE_IN_3430ES2PLUS_36XX includes 34xx/35xx with ES >=2, and all 36xx/37xx */
78*a135eaaeSPaul Walmsley #define RATE_IN_3430ES2PLUS_36XX	(RATE_IN_3430ES2PLUS | RATE_IN_36XX)
79*a135eaaeSPaul Walmsley 
80*a135eaaeSPaul Walmsley 
81*a135eaaeSPaul Walmsley /**
82*a135eaaeSPaul Walmsley  * struct clksel_rate - register bitfield values corresponding to clk divisors
83*a135eaaeSPaul Walmsley  * @val: register bitfield value (shifted to bit 0)
84*a135eaaeSPaul Walmsley  * @div: clock divisor corresponding to @val
85*a135eaaeSPaul Walmsley  * @flags: (see "struct clksel_rate.flags possibilities" above)
86*a135eaaeSPaul Walmsley  *
87*a135eaaeSPaul Walmsley  * @val should match the value of a read from struct clk.clksel_reg
88*a135eaaeSPaul Walmsley  * AND'ed with struct clk.clksel_mask, shifted right to bit 0.
89*a135eaaeSPaul Walmsley  *
90*a135eaaeSPaul Walmsley  * @div is the divisor that should be applied to the parent clock's rate
91*a135eaaeSPaul Walmsley  * to produce the current clock's rate.
92*a135eaaeSPaul Walmsley  */
93*a135eaaeSPaul Walmsley struct clksel_rate {
94*a135eaaeSPaul Walmsley 	u32			val;
95*a135eaaeSPaul Walmsley 	u8			div;
96*a135eaaeSPaul Walmsley 	u16			flags;
97*a135eaaeSPaul Walmsley };
98*a135eaaeSPaul Walmsley 
99*a135eaaeSPaul Walmsley /**
100*a135eaaeSPaul Walmsley  * struct clksel - available parent clocks, and a pointer to their divisors
101*a135eaaeSPaul Walmsley  * @parent: struct clk * to a possible parent clock
102*a135eaaeSPaul Walmsley  * @rates: available divisors for this parent clock
103*a135eaaeSPaul Walmsley  *
104*a135eaaeSPaul Walmsley  * A struct clksel is always associated with one or more struct clks
105*a135eaaeSPaul Walmsley  * and one or more struct clksel_rates.
106*a135eaaeSPaul Walmsley  */
107*a135eaaeSPaul Walmsley struct clksel {
108*a135eaaeSPaul Walmsley 	struct clk		 *parent;
109*a135eaaeSPaul Walmsley 	const struct clksel_rate *rates;
110*a135eaaeSPaul Walmsley };
111*a135eaaeSPaul Walmsley 
112*a135eaaeSPaul Walmsley /**
113*a135eaaeSPaul Walmsley  * struct dpll_data - DPLL registers and integration data
114*a135eaaeSPaul Walmsley  * @mult_div1_reg: register containing the DPLL M and N bitfields
115*a135eaaeSPaul Walmsley  * @mult_mask: mask of the DPLL M bitfield in @mult_div1_reg
116*a135eaaeSPaul Walmsley  * @div1_mask: mask of the DPLL N bitfield in @mult_div1_reg
117*a135eaaeSPaul Walmsley  * @clk_bypass: struct clk pointer to the clock's bypass clock input
118*a135eaaeSPaul Walmsley  * @clk_ref: struct clk pointer to the clock's reference clock input
119*a135eaaeSPaul Walmsley  * @control_reg: register containing the DPLL mode bitfield
120*a135eaaeSPaul Walmsley  * @enable_mask: mask of the DPLL mode bitfield in @control_reg
121*a135eaaeSPaul Walmsley  * @last_rounded_rate: cache of the last rate result of omap2_dpll_round_rate()
122*a135eaaeSPaul Walmsley  * @last_rounded_m: cache of the last M result of omap2_dpll_round_rate()
123*a135eaaeSPaul Walmsley  * @max_multiplier: maximum valid non-bypass multiplier value (actual)
124*a135eaaeSPaul Walmsley  * @last_rounded_n: cache of the last N result of omap2_dpll_round_rate()
125*a135eaaeSPaul Walmsley  * @min_divider: minimum valid non-bypass divider value (actual)
126*a135eaaeSPaul Walmsley  * @max_divider: maximum valid non-bypass divider value (actual)
127*a135eaaeSPaul Walmsley  * @modes: possible values of @enable_mask
128*a135eaaeSPaul Walmsley  * @autoidle_reg: register containing the DPLL autoidle mode bitfield
129*a135eaaeSPaul Walmsley  * @idlest_reg: register containing the DPLL idle status bitfield
130*a135eaaeSPaul Walmsley  * @autoidle_mask: mask of the DPLL autoidle mode bitfield in @autoidle_reg
131*a135eaaeSPaul Walmsley  * @freqsel_mask: mask of the DPLL jitter correction bitfield in @control_reg
132*a135eaaeSPaul Walmsley  * @idlest_mask: mask of the DPLL idle status bitfield in @idlest_reg
133*a135eaaeSPaul Walmsley  * @auto_recal_bit: bitshift of the driftguard enable bit in @control_reg
134*a135eaaeSPaul Walmsley  * @recal_en_bit: bitshift of the PRM_IRQENABLE_* bit for recalibration IRQs
135*a135eaaeSPaul Walmsley  * @recal_st_bit: bitshift of the PRM_IRQSTATUS_* bit for recalibration IRQs
136*a135eaaeSPaul Walmsley  * @flags: DPLL type/features (see below)
137*a135eaaeSPaul Walmsley  *
138*a135eaaeSPaul Walmsley  * Possible values for @flags:
139*a135eaaeSPaul Walmsley  * DPLL_J_TYPE: "J-type DPLL" (only some 36xx, 4xxx DPLLs)
140*a135eaaeSPaul Walmsley  *
141*a135eaaeSPaul Walmsley  * @freqsel_mask is only used on the OMAP34xx family and AM35xx.
142*a135eaaeSPaul Walmsley  *
143*a135eaaeSPaul Walmsley  * XXX Some DPLLs have multiple bypass inputs, so it's not technically
144*a135eaaeSPaul Walmsley  * correct to only have one @clk_bypass pointer.
145*a135eaaeSPaul Walmsley  *
146*a135eaaeSPaul Walmsley  * XXX The runtime-variable fields (@last_rounded_rate, @last_rounded_m,
147*a135eaaeSPaul Walmsley  * @last_rounded_n) should be separated from the runtime-fixed fields
148*a135eaaeSPaul Walmsley  * and placed into a different structure, so that the runtime-fixed data
149*a135eaaeSPaul Walmsley  * can be placed into read-only space.
150*a135eaaeSPaul Walmsley  */
151*a135eaaeSPaul Walmsley struct dpll_data {
152*a135eaaeSPaul Walmsley 	void __iomem		*mult_div1_reg;
153*a135eaaeSPaul Walmsley 	u32			mult_mask;
154*a135eaaeSPaul Walmsley 	u32			div1_mask;
155*a135eaaeSPaul Walmsley 	struct clk		*clk_bypass;
156*a135eaaeSPaul Walmsley 	struct clk		*clk_ref;
157*a135eaaeSPaul Walmsley 	void __iomem		*control_reg;
158*a135eaaeSPaul Walmsley 	u32			enable_mask;
159*a135eaaeSPaul Walmsley 	unsigned long		last_rounded_rate;
160*a135eaaeSPaul Walmsley 	u16			last_rounded_m;
161*a135eaaeSPaul Walmsley 	u16			max_multiplier;
162*a135eaaeSPaul Walmsley 	u8			last_rounded_n;
163*a135eaaeSPaul Walmsley 	u8			min_divider;
164*a135eaaeSPaul Walmsley 	u16			max_divider;
165*a135eaaeSPaul Walmsley 	u8			modes;
166*a135eaaeSPaul Walmsley 	void __iomem		*autoidle_reg;
167*a135eaaeSPaul Walmsley 	void __iomem		*idlest_reg;
168*a135eaaeSPaul Walmsley 	u32			autoidle_mask;
169*a135eaaeSPaul Walmsley 	u32			freqsel_mask;
170*a135eaaeSPaul Walmsley 	u32			idlest_mask;
171*a135eaaeSPaul Walmsley 	u32			dco_mask;
172*a135eaaeSPaul Walmsley 	u32			sddiv_mask;
173*a135eaaeSPaul Walmsley 	u8			auto_recal_bit;
174*a135eaaeSPaul Walmsley 	u8			recal_en_bit;
175*a135eaaeSPaul Walmsley 	u8			recal_st_bit;
176*a135eaaeSPaul Walmsley 	u8			flags;
177*a135eaaeSPaul Walmsley };
178*a135eaaeSPaul Walmsley 
179*a135eaaeSPaul Walmsley /*
180*a135eaaeSPaul Walmsley  * struct clk.flags possibilities
181*a135eaaeSPaul Walmsley  *
182*a135eaaeSPaul Walmsley  * XXX document the rest of the clock flags here
183*a135eaaeSPaul Walmsley  *
184*a135eaaeSPaul Walmsley  * CLOCK_CLKOUTX2: (OMAP4 only) DPLL CLKOUT and CLKOUTX2 GATE_CTRL
185*a135eaaeSPaul Walmsley  *     bits share the same register.  This flag allows the
186*a135eaaeSPaul Walmsley  *     omap4_dpllmx*() code to determine which GATE_CTRL bit field
187*a135eaaeSPaul Walmsley  *     should be used.  This is a temporary solution - a better approach
188*a135eaaeSPaul Walmsley  *     would be to associate clock type-specific data with the clock,
189*a135eaaeSPaul Walmsley  *     similar to the struct dpll_data approach.
190*a135eaaeSPaul Walmsley  */
191*a135eaaeSPaul Walmsley #define ENABLE_REG_32BIT	(1 << 0)	/* Use 32-bit access */
192*a135eaaeSPaul Walmsley #define CLOCK_IDLE_CONTROL	(1 << 1)
193*a135eaaeSPaul Walmsley #define CLOCK_NO_IDLE_PARENT	(1 << 2)
194*a135eaaeSPaul Walmsley #define ENABLE_ON_INIT		(1 << 3)	/* Enable upon framework init */
195*a135eaaeSPaul Walmsley #define INVERT_ENABLE		(1 << 4)	/* 0 enables, 1 disables */
196*a135eaaeSPaul Walmsley #define CLOCK_CLKOUTX2		(1 << 5)
197*a135eaaeSPaul Walmsley 
198*a135eaaeSPaul Walmsley /**
199*a135eaaeSPaul Walmsley  * struct clk - OMAP struct clk
200*a135eaaeSPaul Walmsley  * @node: list_head connecting this clock into the full clock list
201*a135eaaeSPaul Walmsley  * @ops: struct clkops * for this clock
202*a135eaaeSPaul Walmsley  * @name: the name of the clock in the hardware (used in hwmod data and debug)
203*a135eaaeSPaul Walmsley  * @parent: pointer to this clock's parent struct clk
204*a135eaaeSPaul Walmsley  * @children: list_head connecting to the child clks' @sibling list_heads
205*a135eaaeSPaul Walmsley  * @sibling: list_head connecting this clk to its parent clk's @children
206*a135eaaeSPaul Walmsley  * @rate: current clock rate
207*a135eaaeSPaul Walmsley  * @enable_reg: register to write to enable the clock (see @enable_bit)
208*a135eaaeSPaul Walmsley  * @recalc: fn ptr that returns the clock's current rate
209*a135eaaeSPaul Walmsley  * @set_rate: fn ptr that can change the clock's current rate
210*a135eaaeSPaul Walmsley  * @round_rate: fn ptr that can round the clock's current rate
211*a135eaaeSPaul Walmsley  * @init: fn ptr to do clock-specific initialization
212*a135eaaeSPaul Walmsley  * @enable_bit: bitshift to write to enable/disable the clock (see @enable_reg)
213*a135eaaeSPaul Walmsley  * @usecount: number of users that have requested this clock to be enabled
214*a135eaaeSPaul Walmsley  * @fixed_div: when > 0, this clock's rate is its parent's rate / @fixed_div
215*a135eaaeSPaul Walmsley  * @flags: see "struct clk.flags possibilities" above
216*a135eaaeSPaul Walmsley  * @clksel_reg: for clksel clks, register va containing src/divisor select
217*a135eaaeSPaul Walmsley  * @clksel_mask: bitmask in @clksel_reg for the src/divisor selector
218*a135eaaeSPaul Walmsley  * @clksel: for clksel clks, pointer to struct clksel for this clock
219*a135eaaeSPaul Walmsley  * @dpll_data: for DPLLs, pointer to struct dpll_data for this clock
220*a135eaaeSPaul Walmsley  * @clkdm_name: clockdomain name that this clock is contained in
221*a135eaaeSPaul Walmsley  * @clkdm: pointer to struct clockdomain, resolved from @clkdm_name at runtime
222*a135eaaeSPaul Walmsley  * @rate_offset: bitshift for rate selection bitfield (OMAP1 only)
223*a135eaaeSPaul Walmsley  * @src_offset: bitshift for source selection bitfield (OMAP1 only)
224*a135eaaeSPaul Walmsley  *
225*a135eaaeSPaul Walmsley  * XXX @rate_offset, @src_offset should probably be removed and OMAP1
226*a135eaaeSPaul Walmsley  * clock code converted to use clksel.
227*a135eaaeSPaul Walmsley  *
228*a135eaaeSPaul Walmsley  * XXX @usecount is poorly named.  It should be "enable_count" or
229*a135eaaeSPaul Walmsley  * something similar.  "users" in the description refers to kernel
230*a135eaaeSPaul Walmsley  * code (core code or drivers) that have called clk_enable() and not
231*a135eaaeSPaul Walmsley  * yet called clk_disable(); the usecount of parent clocks is also
232*a135eaaeSPaul Walmsley  * incremented by the clock code when clk_enable() is called on child
233*a135eaaeSPaul Walmsley  * clocks and decremented by the clock code when clk_disable() is
234*a135eaaeSPaul Walmsley  * called on child clocks.
235*a135eaaeSPaul Walmsley  *
236*a135eaaeSPaul Walmsley  * XXX @clkdm, @usecount, @children, @sibling should be marked for
237*a135eaaeSPaul Walmsley  * internal use only.
238*a135eaaeSPaul Walmsley  *
239*a135eaaeSPaul Walmsley  * @children and @sibling are used to optimize parent-to-child clock
240*a135eaaeSPaul Walmsley  * tree traversals.  (child-to-parent traversals use @parent.)
241*a135eaaeSPaul Walmsley  *
242*a135eaaeSPaul Walmsley  * XXX The notion of the clock's current rate probably needs to be
243*a135eaaeSPaul Walmsley  * separated from the clock's target rate.
244*a135eaaeSPaul Walmsley  */
245*a135eaaeSPaul Walmsley struct clk {
246*a135eaaeSPaul Walmsley 	struct list_head	node;
247*a135eaaeSPaul Walmsley 	const struct clkops	*ops;
248*a135eaaeSPaul Walmsley 	const char		*name;
249*a135eaaeSPaul Walmsley 	struct clk		*parent;
250*a135eaaeSPaul Walmsley 	struct list_head	children;
251*a135eaaeSPaul Walmsley 	struct list_head	sibling;	/* node for children */
252*a135eaaeSPaul Walmsley 	unsigned long		rate;
253*a135eaaeSPaul Walmsley 	void __iomem		*enable_reg;
254*a135eaaeSPaul Walmsley 	unsigned long		(*recalc)(struct clk *);
255*a135eaaeSPaul Walmsley 	int			(*set_rate)(struct clk *, unsigned long);
256*a135eaaeSPaul Walmsley 	long			(*round_rate)(struct clk *, unsigned long);
257*a135eaaeSPaul Walmsley 	void			(*init)(struct clk *);
258*a135eaaeSPaul Walmsley 	u8			enable_bit;
259*a135eaaeSPaul Walmsley 	s8			usecount;
260*a135eaaeSPaul Walmsley 	u8			fixed_div;
261*a135eaaeSPaul Walmsley 	u8			flags;
262*a135eaaeSPaul Walmsley 	void __iomem		*clksel_reg;
263*a135eaaeSPaul Walmsley 	u32			clksel_mask;
264*a135eaaeSPaul Walmsley 	const struct clksel	*clksel;
265*a135eaaeSPaul Walmsley 	struct dpll_data	*dpll_data;
266*a135eaaeSPaul Walmsley 	const char		*clkdm_name;
267*a135eaaeSPaul Walmsley 	struct clockdomain	*clkdm;
268*a135eaaeSPaul Walmsley #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
269*a135eaaeSPaul Walmsley 	struct dentry		*dent;	/* For visible tree hierarchy */
270*a135eaaeSPaul Walmsley #endif
271*a135eaaeSPaul Walmsley };
272*a135eaaeSPaul Walmsley 
273*a135eaaeSPaul Walmsley struct clk_functions {
274*a135eaaeSPaul Walmsley 	int		(*clk_enable)(struct clk *clk);
275*a135eaaeSPaul Walmsley 	void		(*clk_disable)(struct clk *clk);
276*a135eaaeSPaul Walmsley 	long		(*clk_round_rate)(struct clk *clk, unsigned long rate);
277*a135eaaeSPaul Walmsley 	int		(*clk_set_rate)(struct clk *clk, unsigned long rate);
278*a135eaaeSPaul Walmsley 	int		(*clk_set_parent)(struct clk *clk, struct clk *parent);
279*a135eaaeSPaul Walmsley 	void		(*clk_allow_idle)(struct clk *clk);
280*a135eaaeSPaul Walmsley 	void		(*clk_deny_idle)(struct clk *clk);
281*a135eaaeSPaul Walmsley 	void		(*clk_disable_unused)(struct clk *clk);
282*a135eaaeSPaul Walmsley };
283*a135eaaeSPaul Walmsley 
284*a135eaaeSPaul Walmsley extern int mpurate;
285*a135eaaeSPaul Walmsley 
286*a135eaaeSPaul Walmsley extern int clk_init(struct clk_functions *custom_clocks);
287*a135eaaeSPaul Walmsley extern void clk_preinit(struct clk *clk);
288*a135eaaeSPaul Walmsley extern int clk_register(struct clk *clk);
289*a135eaaeSPaul Walmsley extern void clk_reparent(struct clk *child, struct clk *parent);
290*a135eaaeSPaul Walmsley extern void clk_unregister(struct clk *clk);
291*a135eaaeSPaul Walmsley extern void propagate_rate(struct clk *clk);
292*a135eaaeSPaul Walmsley extern void recalculate_root_clocks(void);
293*a135eaaeSPaul Walmsley extern unsigned long followparent_recalc(struct clk *clk);
294*a135eaaeSPaul Walmsley extern void clk_enable_init_clocks(void);
295*a135eaaeSPaul Walmsley unsigned long omap_fixed_divisor_recalc(struct clk *clk);
296*a135eaaeSPaul Walmsley extern struct clk *omap_clk_get_by_name(const char *name);
297*a135eaaeSPaul Walmsley extern int omap_clk_enable_autoidle_all(void);
298*a135eaaeSPaul Walmsley extern int omap_clk_disable_autoidle_all(void);
299*a135eaaeSPaul Walmsley 
300*a135eaaeSPaul Walmsley extern const struct clkops clkops_null;
301*a135eaaeSPaul Walmsley 
302*a135eaaeSPaul Walmsley extern struct clk dummy_ck;
303*a135eaaeSPaul Walmsley 
304543d9378SPaul Walmsley 
305c0bf3132SRussell King /* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */
306c0bf3132SRussell King #define CORE_CLK_SRC_32K		0x0
307c0bf3132SRussell King #define CORE_CLK_SRC_DPLL		0x1
308c0bf3132SRussell King #define CORE_CLK_SRC_DPLL_X2		0x2
309c0bf3132SRussell King 
310c0bf3132SRussell King /* OMAP2xxx CM_CLKEN_PLL.EN_DPLL bits - for omap2_get_dpll_rate() */
311c0bf3132SRussell King #define OMAP2XXX_EN_DPLL_LPBYPASS		0x1
312c0bf3132SRussell King #define OMAP2XXX_EN_DPLL_FRBYPASS		0x2
313c0bf3132SRussell King #define OMAP2XXX_EN_DPLL_LOCKED			0x3
314c0bf3132SRussell King 
315c0bf3132SRussell King /* OMAP3xxx CM_CLKEN_PLL*.EN_*_DPLL bits - for omap2_get_dpll_rate() */
316c0bf3132SRussell King #define OMAP3XXX_EN_DPLL_LPBYPASS		0x5
317c0bf3132SRussell King #define OMAP3XXX_EN_DPLL_FRBYPASS		0x6
318c0bf3132SRussell King #define OMAP3XXX_EN_DPLL_LOCKED			0x7
319c0bf3132SRussell King 
32016975a79SRajendra Nayak /* OMAP4xxx CM_CLKMODE_DPLL*.EN_*_DPLL bits - for omap2_get_dpll_rate() */
32116975a79SRajendra Nayak #define OMAP4XXX_EN_DPLL_MNBYPASS		0x4
32216975a79SRajendra Nayak #define OMAP4XXX_EN_DPLL_LPBYPASS		0x5
32316975a79SRajendra Nayak #define OMAP4XXX_EN_DPLL_FRBYPASS		0x6
32416975a79SRajendra Nayak #define OMAP4XXX_EN_DPLL_LOCKED			0x7
32516975a79SRajendra Nayak 
326a1391d27SRajendra Nayak /* CM_CLKEN_PLL*.EN* bit values - not all are available for every DPLL */
327a1391d27SRajendra Nayak #define DPLL_LOW_POWER_STOP	0x1
328a1391d27SRajendra Nayak #define DPLL_LOW_POWER_BYPASS	0x5
329a1391d27SRajendra Nayak #define DPLL_LOCKED		0x7
330a1391d27SRajendra Nayak 
331358965d7SRichard Woodruff /* DPLL Type and DCO Selection Flags */
332358965d7SRichard Woodruff #define DPLL_J_TYPE		0x1
333358965d7SRichard Woodruff 
334543d9378SPaul Walmsley int omap2_clk_enable(struct clk *clk);
335543d9378SPaul Walmsley void omap2_clk_disable(struct clk *clk);
336543d9378SPaul Walmsley long omap2_clk_round_rate(struct clk *clk, unsigned long rate);
337543d9378SPaul Walmsley int omap2_clk_set_rate(struct clk *clk, unsigned long rate);
338543d9378SPaul Walmsley int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent);
33988b8ba90SPaul Walmsley long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate);
340a1391d27SRajendra Nayak unsigned long omap3_dpll_recalc(struct clk *clk);
341a1391d27SRajendra Nayak unsigned long omap3_clkoutx2_recalc(struct clk *clk);
342a1391d27SRajendra Nayak void omap3_dpll_allow_idle(struct clk *clk);
343a1391d27SRajendra Nayak void omap3_dpll_deny_idle(struct clk *clk);
344a1391d27SRajendra Nayak u32 omap3_dpll_autoidle_read(struct clk *clk);
345a1391d27SRajendra Nayak int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate);
346a1391d27SRajendra Nayak int omap3_noncore_dpll_enable(struct clk *clk);
347a1391d27SRajendra Nayak void omap3_noncore_dpll_disable(struct clk *clk);
34897f67898SRajendra Nayak int omap4_dpllmx_gatectrl_read(struct clk *clk);
34997f67898SRajendra Nayak void omap4_dpllmx_allow_gatectrl(struct clk *clk);
35097f67898SRajendra Nayak void omap4_dpllmx_deny_gatectrl(struct clk *clk);
351a1900f2eSMike Turquette long omap4_dpll_regm4xen_round_rate(struct clk *clk, unsigned long target_rate);
352a1900f2eSMike Turquette unsigned long omap4_dpll_regm4xen_recalc(struct clk *clk);
353543d9378SPaul Walmsley 
354543d9378SPaul Walmsley #ifdef CONFIG_OMAP_RESET_CLOCKS
355543d9378SPaul Walmsley void omap2_clk_disable_unused(struct clk *clk);
356543d9378SPaul Walmsley #else
357543d9378SPaul Walmsley #define omap2_clk_disable_unused	NULL
358543d9378SPaul Walmsley #endif
359543d9378SPaul Walmsley 
360333943baSPaul Walmsley void omap2_init_clk_clkdm(struct clk *clk);
36112706c54SPaul Walmsley void __init omap2_clk_disable_clkdm_control(void);
362435699dbSPaul Walmsley 
363435699dbSPaul Walmsley /* clkt_clksel.c public functions */
364543d9378SPaul Walmsley u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate,
365543d9378SPaul Walmsley 				u32 *new_div);
366435699dbSPaul Walmsley void omap2_init_clksel_parent(struct clk *clk);
367435699dbSPaul Walmsley unsigned long omap2_clksel_recalc(struct clk *clk);
368543d9378SPaul Walmsley long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate);
369543d9378SPaul Walmsley int omap2_clksel_set_rate(struct clk *clk, unsigned long rate);
370df791b3eSPaul Walmsley int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent);
371435699dbSPaul Walmsley 
372530e544fSPaul Walmsley /* clkt_iclk.c public functions */
373530e544fSPaul Walmsley extern void omap2_clkt_iclk_allow_idle(struct clk *clk);
374530e544fSPaul Walmsley extern void omap2_clkt_iclk_deny_idle(struct clk *clk);
375530e544fSPaul Walmsley 
376543d9378SPaul Walmsley u32 omap2_get_dpll_rate(struct clk *clk);
377911bd739SRajendra Nayak void omap2_init_dpll_parent(struct clk *clk);
378435699dbSPaul Walmsley 
379543d9378SPaul Walmsley int omap2_wait_clock_ready(void __iomem *reg, u32 cval, const char *name);
38056213ca4STony Lindgren 
38156213ca4STony Lindgren 
38256213ca4STony Lindgren #ifdef CONFIG_ARCH_OMAP2
38356213ca4STony Lindgren void omap2xxx_clk_prepare_for_reboot(void);
38456213ca4STony Lindgren #else
38556213ca4STony Lindgren static inline void omap2xxx_clk_prepare_for_reboot(void)
38656213ca4STony Lindgren {
38756213ca4STony Lindgren }
38856213ca4STony Lindgren #endif
38956213ca4STony Lindgren 
39056213ca4STony Lindgren #ifdef CONFIG_ARCH_OMAP3
39156213ca4STony Lindgren void omap3_clk_prepare_for_reboot(void);
39256213ca4STony Lindgren #else
39356213ca4STony Lindgren static inline void omap3_clk_prepare_for_reboot(void)
39456213ca4STony Lindgren {
39556213ca4STony Lindgren }
39656213ca4STony Lindgren #endif
39756213ca4STony Lindgren 
39856213ca4STony Lindgren #ifdef CONFIG_ARCH_OMAP4
39956213ca4STony Lindgren void omap4_clk_prepare_for_reboot(void);
40056213ca4STony Lindgren #else
40156213ca4STony Lindgren static inline void omap4_clk_prepare_for_reboot(void)
40256213ca4STony Lindgren {
40356213ca4STony Lindgren }
40456213ca4STony Lindgren #endif
40556213ca4STony Lindgren 
40672350b29SPaul Walmsley int omap2_dflt_clk_enable(struct clk *clk);
40772350b29SPaul Walmsley void omap2_dflt_clk_disable(struct clk *clk);
40872350b29SPaul Walmsley void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg,
40972350b29SPaul Walmsley 				   u8 *other_bit);
41072350b29SPaul Walmsley void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg,
411419cc97dSRanjith Lohithakshan 				u8 *idlest_bit, u8 *idlest_val);
4124d30e82cSPaul Walmsley int omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name);
4134d30e82cSPaul Walmsley void omap2_clk_print_new_rates(const char *hfclkin_ck_name,
4144d30e82cSPaul Walmsley 			       const char *core_ck_name,
4154d30e82cSPaul Walmsley 			       const char *mpu_ck_name);
416543d9378SPaul Walmsley 
41799541195SAfzal Mohammed extern u16 cpu_mask;
418d8a94458SPaul Walmsley 
419b36ee724SRussell King extern const struct clkops clkops_omap2_dflt_wait;
4207c43d547SSantosh Shilimkar extern const struct clkops clkops_dummy;
421bc51da4eSRussell King extern const struct clkops clkops_omap2_dflt;
422b36ee724SRussell King 
42382e9bd58SPaul Walmsley extern struct clk_functions omap2_clk_functions;
424d8a94458SPaul Walmsley extern struct clk *vclk, *sclk;
42582e9bd58SPaul Walmsley 
426d8a94458SPaul Walmsley extern const struct clksel_rate gpt_32k_rates[];
427d8a94458SPaul Walmsley extern const struct clksel_rate gpt_sys_rates[];
428d8a94458SPaul Walmsley extern const struct clksel_rate gfx_l3_rates[];
42922411396SPaul Walmsley extern const struct clksel_rate dsp_ick_rates[];
430543d9378SPaul Walmsley 
431530e544fSPaul Walmsley extern const struct clkops clkops_omap2_iclk_dflt_wait;
432530e544fSPaul Walmsley extern const struct clkops clkops_omap2_iclk_dflt;
433530e544fSPaul Walmsley extern const struct clkops clkops_omap2_iclk_idle_only;
434e892b252SPaul Walmsley extern const struct clkops clkops_omap2_mdmclk_dflt_wait;
4350fd0c21bSPaul Walmsley extern const struct clkops clkops_omap2xxx_dpll_ops;
436657ebfadSPaul Walmsley extern const struct clkops clkops_omap3_noncore_dpll_ops;
4376c6f5a74SRajendra Nayak extern const struct clkops clkops_omap3_core_dpll_ops;
43870db8a62SRajendra Nayak extern const struct clkops clkops_omap4_dpllmx_ops;
439657ebfadSPaul Walmsley 
440571efa0dSPaul Walmsley /* clksel_rate blocks shared between OMAP44xx and AM33xx */
441571efa0dSPaul Walmsley extern const struct clksel_rate div_1_0_rates[];
442571efa0dSPaul Walmsley extern const struct clksel_rate div_1_1_rates[];
443571efa0dSPaul Walmsley extern const struct clksel_rate div_1_2_rates[];
444571efa0dSPaul Walmsley extern const struct clksel_rate div_1_3_rates[];
445571efa0dSPaul Walmsley extern const struct clksel_rate div_1_4_rates[];
446571efa0dSPaul Walmsley extern const struct clksel_rate div31_1to31_rates[];
447571efa0dSPaul Walmsley 
448571efa0dSPaul Walmsley /* clocks shared between various OMAP SoCs */
449571efa0dSPaul Walmsley extern struct clk virt_19200000_ck;
450571efa0dSPaul Walmsley extern struct clk virt_26000000_ck;
451571efa0dSPaul Walmsley 
452e30384abSVaibhav Hiremath extern int am33xx_clk_init(void);
453e30384abSVaibhav Hiremath 
454543d9378SPaul Walmsley #endif
455