xref: /linux/arch/arm/mach-omap2/clock.h (revision 16975a79c8e6ee424331f52649f2351d33c7b972)
1543d9378SPaul Walmsley /*
2543d9378SPaul Walmsley  *  linux/arch/arm/mach-omap2/clock.h
3543d9378SPaul Walmsley  *
4d8a94458SPaul Walmsley  *  Copyright (C) 2005-2009 Texas Instruments, Inc.
5d8a94458SPaul Walmsley  *  Copyright (C) 2004-2009 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 
19ce491cf8STony Lindgren #include <plat/clock.h>
20543d9378SPaul Walmsley 
2188b8ba90SPaul Walmsley /* The maximum error between a target DPLL rate and the rounded rate in Hz */
2288b8ba90SPaul Walmsley #define DEFAULT_DPLL_RATE_TOLERANCE	50000
2388b8ba90SPaul Walmsley 
24c0bf3132SRussell King /* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */
25c0bf3132SRussell King #define CORE_CLK_SRC_32K		0x0
26c0bf3132SRussell King #define CORE_CLK_SRC_DPLL		0x1
27c0bf3132SRussell King #define CORE_CLK_SRC_DPLL_X2		0x2
28c0bf3132SRussell King 
29c0bf3132SRussell King /* OMAP2xxx CM_CLKEN_PLL.EN_DPLL bits - for omap2_get_dpll_rate() */
30c0bf3132SRussell King #define OMAP2XXX_EN_DPLL_LPBYPASS		0x1
31c0bf3132SRussell King #define OMAP2XXX_EN_DPLL_FRBYPASS		0x2
32c0bf3132SRussell King #define OMAP2XXX_EN_DPLL_LOCKED			0x3
33c0bf3132SRussell King 
34c0bf3132SRussell King /* OMAP3xxx CM_CLKEN_PLL*.EN_*_DPLL bits - for omap2_get_dpll_rate() */
35c0bf3132SRussell King #define OMAP3XXX_EN_DPLL_LPBYPASS		0x5
36c0bf3132SRussell King #define OMAP3XXX_EN_DPLL_FRBYPASS		0x6
37c0bf3132SRussell King #define OMAP3XXX_EN_DPLL_LOCKED			0x7
38c0bf3132SRussell King 
39*16975a79SRajendra Nayak /* OMAP4xxx CM_CLKMODE_DPLL*.EN_*_DPLL bits - for omap2_get_dpll_rate() */
40*16975a79SRajendra Nayak #define OMAP4XXX_EN_DPLL_MNBYPASS		0x4
41*16975a79SRajendra Nayak #define OMAP4XXX_EN_DPLL_LPBYPASS		0x5
42*16975a79SRajendra Nayak #define OMAP4XXX_EN_DPLL_FRBYPASS		0x6
43*16975a79SRajendra Nayak #define OMAP4XXX_EN_DPLL_LOCKED			0x7
44*16975a79SRajendra Nayak 
45a1391d27SRajendra Nayak /* CM_CLKEN_PLL*.EN* bit values - not all are available for every DPLL */
46a1391d27SRajendra Nayak #define DPLL_LOW_POWER_STOP	0x1
47a1391d27SRajendra Nayak #define DPLL_LOW_POWER_BYPASS	0x5
48a1391d27SRajendra Nayak #define DPLL_LOCKED		0x7
49a1391d27SRajendra Nayak 
50646e3ed1STony Lindgren int omap2_clk_init(void);
51543d9378SPaul Walmsley int omap2_clk_enable(struct clk *clk);
52543d9378SPaul Walmsley void omap2_clk_disable(struct clk *clk);
53543d9378SPaul Walmsley long omap2_clk_round_rate(struct clk *clk, unsigned long rate);
54543d9378SPaul Walmsley int omap2_clk_set_rate(struct clk *clk, unsigned long rate);
55543d9378SPaul Walmsley int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent);
56fecb494bSPaul Walmsley int omap2_dpll_set_rate_tolerance(struct clk *clk, unsigned int tolerance);
5788b8ba90SPaul Walmsley long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate);
58a1391d27SRajendra Nayak unsigned long omap3_dpll_recalc(struct clk *clk);
59a1391d27SRajendra Nayak unsigned long omap3_clkoutx2_recalc(struct clk *clk);
60a1391d27SRajendra Nayak void omap3_dpll_allow_idle(struct clk *clk);
61a1391d27SRajendra Nayak void omap3_dpll_deny_idle(struct clk *clk);
62a1391d27SRajendra Nayak u32 omap3_dpll_autoidle_read(struct clk *clk);
63a1391d27SRajendra Nayak int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate);
64a1391d27SRajendra Nayak int omap3_noncore_dpll_enable(struct clk *clk);
65a1391d27SRajendra Nayak void omap3_noncore_dpll_disable(struct clk *clk);
66543d9378SPaul Walmsley 
67543d9378SPaul Walmsley #ifdef CONFIG_OMAP_RESET_CLOCKS
68543d9378SPaul Walmsley void omap2_clk_disable_unused(struct clk *clk);
69543d9378SPaul Walmsley #else
70543d9378SPaul Walmsley #define omap2_clk_disable_unused	NULL
71543d9378SPaul Walmsley #endif
72543d9378SPaul Walmsley 
738b9dbc16SRussell King unsigned long omap2_clksel_recalc(struct clk *clk);
74333943baSPaul Walmsley void omap2_init_clk_clkdm(struct clk *clk);
75543d9378SPaul Walmsley void omap2_init_clksel_parent(struct clk *clk);
76543d9378SPaul Walmsley u32 omap2_clksel_get_divisor(struct clk *clk);
77543d9378SPaul Walmsley u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate,
78543d9378SPaul Walmsley 				u32 *new_div);
79543d9378SPaul Walmsley u32 omap2_clksel_to_divisor(struct clk *clk, u32 field_val);
80543d9378SPaul Walmsley u32 omap2_divisor_to_clksel(struct clk *clk, u32 div);
818b9dbc16SRussell King unsigned long omap2_fixed_divisor_recalc(struct clk *clk);
82543d9378SPaul Walmsley long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate);
83543d9378SPaul Walmsley int omap2_clksel_set_rate(struct clk *clk, unsigned long rate);
84543d9378SPaul Walmsley u32 omap2_get_dpll_rate(struct clk *clk);
85543d9378SPaul Walmsley int omap2_wait_clock_ready(void __iomem *reg, u32 cval, const char *name);
86ff00fcc9STony Lindgren void omap2_clk_prepare_for_reboot(void);
8772350b29SPaul Walmsley int omap2_dflt_clk_enable(struct clk *clk);
8872350b29SPaul Walmsley void omap2_dflt_clk_disable(struct clk *clk);
8972350b29SPaul Walmsley void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg,
9072350b29SPaul Walmsley 				   u8 *other_bit);
9172350b29SPaul Walmsley void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg,
9272350b29SPaul Walmsley 				u8 *idlest_bit);
93543d9378SPaul Walmsley 
94d8a94458SPaul Walmsley extern u8 cpu_mask;
95d8a94458SPaul Walmsley 
96b36ee724SRussell King extern const struct clkops clkops_omap2_dflt_wait;
97bc51da4eSRussell King extern const struct clkops clkops_omap2_dflt;
98b36ee724SRussell King 
9982e9bd58SPaul Walmsley extern struct clk_functions omap2_clk_functions;
100d8a94458SPaul Walmsley extern struct clk *vclk, *sclk;
10182e9bd58SPaul Walmsley 
102d8a94458SPaul Walmsley extern const struct clksel_rate gpt_32k_rates[];
103d8a94458SPaul Walmsley extern const struct clksel_rate gpt_sys_rates[];
104d8a94458SPaul Walmsley extern const struct clksel_rate gfx_l3_rates[];
105543d9378SPaul Walmsley 
106543d9378SPaul Walmsley 
107543d9378SPaul Walmsley #endif
108