xref: /linux/arch/arm/mach-omap2/clock.h (revision 12706c542574ea0127a13815efe59ca9ba6d88d7)
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 
19*12706c54SPaul Walmsley #include <linux/kernel.h>
20*12706c54SPaul Walmsley 
21ce491cf8STony Lindgren #include <plat/clock.h>
22543d9378SPaul Walmsley 
23c0bf3132SRussell King /* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */
24c0bf3132SRussell King #define CORE_CLK_SRC_32K		0x0
25c0bf3132SRussell King #define CORE_CLK_SRC_DPLL		0x1
26c0bf3132SRussell King #define CORE_CLK_SRC_DPLL_X2		0x2
27c0bf3132SRussell King 
28c0bf3132SRussell King /* OMAP2xxx CM_CLKEN_PLL.EN_DPLL bits - for omap2_get_dpll_rate() */
29c0bf3132SRussell King #define OMAP2XXX_EN_DPLL_LPBYPASS		0x1
30c0bf3132SRussell King #define OMAP2XXX_EN_DPLL_FRBYPASS		0x2
31c0bf3132SRussell King #define OMAP2XXX_EN_DPLL_LOCKED			0x3
32c0bf3132SRussell King 
33c0bf3132SRussell King /* OMAP3xxx CM_CLKEN_PLL*.EN_*_DPLL bits - for omap2_get_dpll_rate() */
34c0bf3132SRussell King #define OMAP3XXX_EN_DPLL_LPBYPASS		0x5
35c0bf3132SRussell King #define OMAP3XXX_EN_DPLL_FRBYPASS		0x6
36c0bf3132SRussell King #define OMAP3XXX_EN_DPLL_LOCKED			0x7
37c0bf3132SRussell King 
3816975a79SRajendra Nayak /* OMAP4xxx CM_CLKMODE_DPLL*.EN_*_DPLL bits - for omap2_get_dpll_rate() */
3916975a79SRajendra Nayak #define OMAP4XXX_EN_DPLL_MNBYPASS		0x4
4016975a79SRajendra Nayak #define OMAP4XXX_EN_DPLL_LPBYPASS		0x5
4116975a79SRajendra Nayak #define OMAP4XXX_EN_DPLL_FRBYPASS		0x6
4216975a79SRajendra Nayak #define OMAP4XXX_EN_DPLL_LOCKED			0x7
4316975a79SRajendra Nayak 
44a1391d27SRajendra Nayak /* CM_CLKEN_PLL*.EN* bit values - not all are available for every DPLL */
45a1391d27SRajendra Nayak #define DPLL_LOW_POWER_STOP	0x1
46a1391d27SRajendra Nayak #define DPLL_LOW_POWER_BYPASS	0x5
47a1391d27SRajendra Nayak #define DPLL_LOCKED		0x7
48a1391d27SRajendra Nayak 
49358965d7SRichard Woodruff /* DPLL Type and DCO Selection Flags */
50358965d7SRichard Woodruff #define DPLL_J_TYPE		0x1
51358965d7SRichard Woodruff 
52543d9378SPaul Walmsley int omap2_clk_enable(struct clk *clk);
53543d9378SPaul Walmsley void omap2_clk_disable(struct clk *clk);
54543d9378SPaul Walmsley long omap2_clk_round_rate(struct clk *clk, unsigned long rate);
55543d9378SPaul Walmsley int omap2_clk_set_rate(struct clk *clk, unsigned long rate);
56543d9378SPaul Walmsley int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent);
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);
6697f67898SRajendra Nayak int omap4_dpllmx_gatectrl_read(struct clk *clk);
6797f67898SRajendra Nayak void omap4_dpllmx_allow_gatectrl(struct clk *clk);
6897f67898SRajendra Nayak void omap4_dpllmx_deny_gatectrl(struct clk *clk);
69543d9378SPaul Walmsley 
70543d9378SPaul Walmsley #ifdef CONFIG_OMAP_RESET_CLOCKS
71543d9378SPaul Walmsley void omap2_clk_disable_unused(struct clk *clk);
72543d9378SPaul Walmsley #else
73543d9378SPaul Walmsley #define omap2_clk_disable_unused	NULL
74543d9378SPaul Walmsley #endif
75543d9378SPaul Walmsley 
76333943baSPaul Walmsley void omap2_init_clk_clkdm(struct clk *clk);
77*12706c54SPaul Walmsley void __init omap2_clk_disable_clkdm_control(void);
78435699dbSPaul Walmsley 
79435699dbSPaul Walmsley /* clkt_clksel.c public functions */
80543d9378SPaul Walmsley u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate,
81543d9378SPaul Walmsley 				u32 *new_div);
82435699dbSPaul Walmsley void omap2_init_clksel_parent(struct clk *clk);
83435699dbSPaul Walmsley unsigned long omap2_clksel_recalc(struct clk *clk);
84543d9378SPaul Walmsley long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate);
85543d9378SPaul Walmsley int omap2_clksel_set_rate(struct clk *clk, unsigned long rate);
86df791b3eSPaul Walmsley int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent);
87435699dbSPaul Walmsley 
88530e544fSPaul Walmsley /* clkt_iclk.c public functions */
89530e544fSPaul Walmsley extern void omap2_clkt_iclk_allow_idle(struct clk *clk);
90530e544fSPaul Walmsley extern void omap2_clkt_iclk_deny_idle(struct clk *clk);
91530e544fSPaul Walmsley 
92543d9378SPaul Walmsley u32 omap2_get_dpll_rate(struct clk *clk);
93911bd739SRajendra Nayak void omap2_init_dpll_parent(struct clk *clk);
94435699dbSPaul Walmsley 
95543d9378SPaul Walmsley int omap2_wait_clock_ready(void __iomem *reg, u32 cval, const char *name);
9656213ca4STony Lindgren 
9756213ca4STony Lindgren 
9856213ca4STony Lindgren #ifdef CONFIG_ARCH_OMAP2
9956213ca4STony Lindgren void omap2xxx_clk_prepare_for_reboot(void);
10056213ca4STony Lindgren #else
10156213ca4STony Lindgren static inline void omap2xxx_clk_prepare_for_reboot(void)
10256213ca4STony Lindgren {
10356213ca4STony Lindgren }
10456213ca4STony Lindgren #endif
10556213ca4STony Lindgren 
10656213ca4STony Lindgren #ifdef CONFIG_ARCH_OMAP3
10756213ca4STony Lindgren void omap3_clk_prepare_for_reboot(void);
10856213ca4STony Lindgren #else
10956213ca4STony Lindgren static inline void omap3_clk_prepare_for_reboot(void)
11056213ca4STony Lindgren {
11156213ca4STony Lindgren }
11256213ca4STony Lindgren #endif
11356213ca4STony Lindgren 
11456213ca4STony Lindgren #ifdef CONFIG_ARCH_OMAP4
11556213ca4STony Lindgren void omap4_clk_prepare_for_reboot(void);
11656213ca4STony Lindgren #else
11756213ca4STony Lindgren static inline void omap4_clk_prepare_for_reboot(void)
11856213ca4STony Lindgren {
11956213ca4STony Lindgren }
12056213ca4STony Lindgren #endif
12156213ca4STony Lindgren 
12272350b29SPaul Walmsley int omap2_dflt_clk_enable(struct clk *clk);
12372350b29SPaul Walmsley void omap2_dflt_clk_disable(struct clk *clk);
12472350b29SPaul Walmsley void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg,
12572350b29SPaul Walmsley 				   u8 *other_bit);
12672350b29SPaul Walmsley void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg,
127419cc97dSRanjith Lohithakshan 				u8 *idlest_bit, u8 *idlest_val);
1284d30e82cSPaul Walmsley int omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name);
1294d30e82cSPaul Walmsley void omap2_clk_print_new_rates(const char *hfclkin_ck_name,
1304d30e82cSPaul Walmsley 			       const char *core_ck_name,
1314d30e82cSPaul Walmsley 			       const char *mpu_ck_name);
132543d9378SPaul Walmsley 
133d8a94458SPaul Walmsley extern u8 cpu_mask;
134d8a94458SPaul Walmsley 
135b36ee724SRussell King extern const struct clkops clkops_omap2_dflt_wait;
1367c43d547SSantosh Shilimkar extern const struct clkops clkops_dummy;
137bc51da4eSRussell King extern const struct clkops clkops_omap2_dflt;
138b36ee724SRussell King 
13982e9bd58SPaul Walmsley extern struct clk_functions omap2_clk_functions;
140d8a94458SPaul Walmsley extern struct clk *vclk, *sclk;
14182e9bd58SPaul Walmsley 
142d8a94458SPaul Walmsley extern const struct clksel_rate gpt_32k_rates[];
143d8a94458SPaul Walmsley extern const struct clksel_rate gpt_sys_rates[];
144d8a94458SPaul Walmsley extern const struct clksel_rate gfx_l3_rates[];
14522411396SPaul Walmsley extern const struct clksel_rate dsp_ick_rates[];
146543d9378SPaul Walmsley 
147088ef950STony Lindgren #if defined(CONFIG_ARCH_OMAP2) && defined(CONFIG_CPU_FREQ)
14869ecefcaSPaul Walmsley extern void omap2_clk_init_cpufreq_table(struct cpufreq_frequency_table **table);
14969ecefcaSPaul Walmsley extern void omap2_clk_exit_cpufreq_table(struct cpufreq_frequency_table **table);
15069ecefcaSPaul Walmsley #else
15169ecefcaSPaul Walmsley #define omap2_clk_init_cpufreq_table	0
15269ecefcaSPaul Walmsley #define omap2_clk_exit_cpufreq_table	0
15369ecefcaSPaul Walmsley #endif
154543d9378SPaul Walmsley 
155530e544fSPaul Walmsley extern const struct clkops clkops_omap2_iclk_dflt_wait;
156530e544fSPaul Walmsley extern const struct clkops clkops_omap2_iclk_dflt;
157530e544fSPaul Walmsley extern const struct clkops clkops_omap2_iclk_idle_only;
158e892b252SPaul Walmsley extern const struct clkops clkops_omap2_mdmclk_dflt_wait;
1590fd0c21bSPaul Walmsley extern const struct clkops clkops_omap2xxx_dpll_ops;
160657ebfadSPaul Walmsley extern const struct clkops clkops_omap3_noncore_dpll_ops;
1616c6f5a74SRajendra Nayak extern const struct clkops clkops_omap3_core_dpll_ops;
16270db8a62SRajendra Nayak extern const struct clkops clkops_omap4_dpllmx_ops;
163657ebfadSPaul Walmsley 
164543d9378SPaul Walmsley #endif
165