diff options
Diffstat (limited to 'arch/arm/mach-omap2/clock34xx.c')
-rw-r--r-- | arch/arm/mach-omap2/clock34xx.c | 123 |
1 files changed, 14 insertions, 109 deletions
diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c index ae9e2c82eb6a..6febd5f11e85 100644 --- a/arch/arm/mach-omap2/clock34xx.c +++ b/arch/arm/mach-omap2/clock34xx.c | |||
@@ -8,7 +8,8 @@ | |||
8 | * Jouni Högander | 8 | * Jouni Högander |
9 | * | 9 | * |
10 | * Parts of this code are based on code written by | 10 | * Parts of this code are based on code written by |
11 | * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu | 11 | * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu, |
12 | * Russell King | ||
12 | * | 13 | * |
13 | * This program is free software; you can redistribute it and/or modify | 14 | * This program is free software; you can redistribute it and/or modify |
14 | * it under the terms of the GNU General Public License version 2 as | 15 | * it under the terms of the GNU General Public License version 2 as |
@@ -17,36 +18,22 @@ | |||
17 | #undef DEBUG | 18 | #undef DEBUG |
18 | 19 | ||
19 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
20 | #include <linux/errno.h> | ||
21 | #include <linux/delay.h> | ||
22 | #include <linux/clk.h> | 21 | #include <linux/clk.h> |
23 | #include <linux/io.h> | 22 | #include <linux/io.h> |
24 | 23 | ||
25 | #include <plat/cpu.h> | ||
26 | #include <plat/clock.h> | 24 | #include <plat/clock.h> |
27 | 25 | ||
28 | #include "clock.h" | 26 | #include "clock.h" |
29 | #include "clock34xx.h" | 27 | #include "clock34xx.h" |
30 | #include "prm.h" | ||
31 | #include "prm-regbits-34xx.h" | ||
32 | #include "cm.h" | 28 | #include "cm.h" |
33 | #include "cm-regbits-34xx.h" | 29 | #include "cm-regbits-34xx.h" |
34 | 30 | ||
35 | /* | ||
36 | * DPLL5_FREQ_FOR_USBHOST: USBHOST and USBTLL are the only clocks | ||
37 | * that are sourced by DPLL5, and both of these require this clock | ||
38 | * to be at 120 MHz for proper operation. | ||
39 | */ | ||
40 | #define DPLL5_FREQ_FOR_USBHOST 120000000 | ||
41 | |||
42 | /* needed by omap3_core_dpll_m2_set_rate() */ | ||
43 | struct clk *sdrc_ick_p, *arm_fck_p; | ||
44 | |||
45 | /** | 31 | /** |
46 | * omap3430es2_clk_ssi_find_idlest - return CM_IDLEST info for SSI | 32 | * omap3430es2_clk_ssi_find_idlest - return CM_IDLEST info for SSI |
47 | * @clk: struct clk * being enabled | 33 | * @clk: struct clk * being enabled |
48 | * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into | 34 | * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into |
49 | * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into | 35 | * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into |
36 | * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator | ||
50 | * | 37 | * |
51 | * The OMAP3430ES2 SSI target CM_IDLEST bit is at a different shift | 38 | * The OMAP3430ES2 SSI target CM_IDLEST bit is at a different shift |
52 | * from the CM_{I,F}CLKEN bit. Pass back the correct info via | 39 | * from the CM_{I,F}CLKEN bit. Pass back the correct info via |
@@ -54,13 +41,15 @@ struct clk *sdrc_ick_p, *arm_fck_p; | |||
54 | */ | 41 | */ |
55 | static void omap3430es2_clk_ssi_find_idlest(struct clk *clk, | 42 | static void omap3430es2_clk_ssi_find_idlest(struct clk *clk, |
56 | void __iomem **idlest_reg, | 43 | void __iomem **idlest_reg, |
57 | u8 *idlest_bit) | 44 | u8 *idlest_bit, |
45 | u8 *idlest_val) | ||
58 | { | 46 | { |
59 | u32 r; | 47 | u32 r; |
60 | 48 | ||
61 | r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); | 49 | r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); |
62 | *idlest_reg = (__force void __iomem *)r; | 50 | *idlest_reg = (__force void __iomem *)r; |
63 | *idlest_bit = OMAP3430ES2_ST_SSI_IDLE_SHIFT; | 51 | *idlest_bit = OMAP3430ES2_ST_SSI_IDLE_SHIFT; |
52 | *idlest_val = OMAP34XX_CM_IDLEST_VAL; | ||
64 | } | 53 | } |
65 | 54 | ||
66 | const struct clkops clkops_omap3430es2_ssi_wait = { | 55 | const struct clkops clkops_omap3430es2_ssi_wait = { |
@@ -75,6 +64,7 @@ const struct clkops clkops_omap3430es2_ssi_wait = { | |||
75 | * @clk: struct clk * being enabled | 64 | * @clk: struct clk * being enabled |
76 | * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into | 65 | * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into |
77 | * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into | 66 | * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into |
67 | * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator | ||
78 | * | 68 | * |
79 | * Some OMAP modules on OMAP3 ES2+ chips have both initiator and | 69 | * Some OMAP modules on OMAP3 ES2+ chips have both initiator and |
80 | * target IDLEST bits. For our purposes, we are concerned with the | 70 | * target IDLEST bits. For our purposes, we are concerned with the |
@@ -85,7 +75,8 @@ const struct clkops clkops_omap3430es2_ssi_wait = { | |||
85 | */ | 75 | */ |
86 | static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk *clk, | 76 | static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk *clk, |
87 | void __iomem **idlest_reg, | 77 | void __iomem **idlest_reg, |
88 | u8 *idlest_bit) | 78 | u8 *idlest_bit, |
79 | u8 *idlest_val) | ||
89 | { | 80 | { |
90 | u32 r; | 81 | u32 r; |
91 | 82 | ||
@@ -93,6 +84,7 @@ static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk *clk, | |||
93 | *idlest_reg = (__force void __iomem *)r; | 84 | *idlest_reg = (__force void __iomem *)r; |
94 | /* USBHOST_IDLE has same shift */ | 85 | /* USBHOST_IDLE has same shift */ |
95 | *idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT; | 86 | *idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT; |
87 | *idlest_val = OMAP34XX_CM_IDLEST_VAL; | ||
96 | } | 88 | } |
97 | 89 | ||
98 | const struct clkops clkops_omap3430es2_dss_usbhost_wait = { | 90 | const struct clkops clkops_omap3430es2_dss_usbhost_wait = { |
@@ -107,6 +99,7 @@ const struct clkops clkops_omap3430es2_dss_usbhost_wait = { | |||
107 | * @clk: struct clk * being enabled | 99 | * @clk: struct clk * being enabled |
108 | * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into | 100 | * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into |
109 | * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into | 101 | * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into |
102 | * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator | ||
110 | * | 103 | * |
111 | * The OMAP3430ES2 HSOTGUSB target CM_IDLEST bit is at a different | 104 | * The OMAP3430ES2 HSOTGUSB target CM_IDLEST bit is at a different |
112 | * shift from the CM_{I,F}CLKEN bit. Pass back the correct info via | 105 | * shift from the CM_{I,F}CLKEN bit. Pass back the correct info via |
@@ -114,13 +107,15 @@ const struct clkops clkops_omap3430es2_dss_usbhost_wait = { | |||
114 | */ | 107 | */ |
115 | static void omap3430es2_clk_hsotgusb_find_idlest(struct clk *clk, | 108 | static void omap3430es2_clk_hsotgusb_find_idlest(struct clk *clk, |
116 | void __iomem **idlest_reg, | 109 | void __iomem **idlest_reg, |
117 | u8 *idlest_bit) | 110 | u8 *idlest_bit, |
111 | u8 *idlest_val) | ||
118 | { | 112 | { |
119 | u32 r; | 113 | u32 r; |
120 | 114 | ||
121 | r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); | 115 | r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20); |
122 | *idlest_reg = (__force void __iomem *)r; | 116 | *idlest_reg = (__force void __iomem *)r; |
123 | *idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT; | 117 | *idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT; |
118 | *idlest_val = OMAP34XX_CM_IDLEST_VAL; | ||
124 | } | 119 | } |
125 | 120 | ||
126 | const struct clkops clkops_omap3430es2_hsotgusb_wait = { | 121 | const struct clkops clkops_omap3430es2_hsotgusb_wait = { |
@@ -129,93 +124,3 @@ const struct clkops clkops_omap3430es2_hsotgusb_wait = { | |||
129 | .find_idlest = omap3430es2_clk_hsotgusb_find_idlest, | 124 | .find_idlest = omap3430es2_clk_hsotgusb_find_idlest, |
130 | .find_companion = omap2_clk_dflt_find_companion, | 125 | .find_companion = omap2_clk_dflt_find_companion, |
131 | }; | 126 | }; |
132 | |||
133 | const struct clkops omap3_clkops_noncore_dpll_ops = { | ||
134 | .enable = omap3_noncore_dpll_enable, | ||
135 | .disable = omap3_noncore_dpll_disable, | ||
136 | }; | ||
137 | |||
138 | int omap3_dpll4_set_rate(struct clk *clk, unsigned long rate) | ||
139 | { | ||
140 | /* | ||
141 | * According to the 12-5 CDP code from TI, "Limitation 2.5" | ||
142 | * on 3430ES1 prevents us from changing DPLL multipliers or dividers | ||
143 | * on DPLL4. | ||
144 | */ | ||
145 | if (omap_rev() == OMAP3430_REV_ES1_0) { | ||
146 | printk(KERN_ERR "clock: DPLL4 cannot change rate due to " | ||
147 | "silicon 'Limitation 2.5' on 3430ES1.\n"); | ||
148 | return -EINVAL; | ||
149 | } | ||
150 | return omap3_noncore_dpll_set_rate(clk, rate); | ||
151 | } | ||
152 | |||
153 | void __init omap3_clk_lock_dpll5(void) | ||
154 | { | ||
155 | struct clk *dpll5_clk; | ||
156 | struct clk *dpll5_m2_clk; | ||
157 | |||
158 | dpll5_clk = clk_get(NULL, "dpll5_ck"); | ||
159 | clk_set_rate(dpll5_clk, DPLL5_FREQ_FOR_USBHOST); | ||
160 | clk_enable(dpll5_clk); | ||
161 | |||
162 | /* Enable autoidle to allow it to enter low power bypass */ | ||
163 | omap3_dpll_allow_idle(dpll5_clk); | ||
164 | |||
165 | /* Program dpll5_m2_clk divider for no division */ | ||
166 | dpll5_m2_clk = clk_get(NULL, "dpll5_m2_ck"); | ||
167 | clk_enable(dpll5_m2_clk); | ||
168 | clk_set_rate(dpll5_m2_clk, DPLL5_FREQ_FOR_USBHOST); | ||
169 | |||
170 | clk_disable(dpll5_m2_clk); | ||
171 | clk_disable(dpll5_clk); | ||
172 | return; | ||
173 | } | ||
174 | |||
175 | /* Common clock code */ | ||
176 | |||
177 | /* REVISIT: Move this init stuff out into clock.c */ | ||
178 | |||
179 | /* | ||
180 | * Switch the MPU rate if specified on cmdline. | ||
181 | * We cannot do this early until cmdline is parsed. | ||
182 | */ | ||
183 | static int __init omap3xxx_clk_arch_init(void) | ||
184 | { | ||
185 | struct clk *osc_sys_ck, *dpll1_ck, *arm_fck, *core_ck; | ||
186 | unsigned long osc_sys_rate; | ||
187 | |||
188 | if (!cpu_is_omap34xx()) | ||
189 | return 0; | ||
190 | |||
191 | if (!mpurate) | ||
192 | return -EINVAL; | ||
193 | |||
194 | /* XXX test these for success */ | ||
195 | dpll1_ck = clk_get(NULL, "dpll1_ck"); | ||
196 | arm_fck = clk_get(NULL, "arm_fck"); | ||
197 | core_ck = clk_get(NULL, "core_ck"); | ||
198 | osc_sys_ck = clk_get(NULL, "osc_sys_ck"); | ||
199 | |||
200 | /* REVISIT: not yet ready for 343x */ | ||
201 | if (clk_set_rate(dpll1_ck, mpurate)) | ||
202 | printk(KERN_ERR "*** Unable to set MPU rate\n"); | ||
203 | |||
204 | recalculate_root_clocks(); | ||
205 | |||
206 | osc_sys_rate = clk_get_rate(osc_sys_ck); | ||
207 | |||
208 | pr_info("Switched to new clocking rate (Crystal/Core/MPU): " | ||
209 | "%ld.%01ld/%ld/%ld MHz\n", | ||
210 | (osc_sys_rate / 1000000), | ||
211 | ((osc_sys_rate / 100000) % 10), | ||
212 | (clk_get_rate(core_ck) / 1000000), | ||
213 | (clk_get_rate(arm_fck) / 1000000)); | ||
214 | |||
215 | calibrate_delay(); | ||
216 | |||
217 | return 0; | ||
218 | } | ||
219 | arch_initcall(omap3xxx_clk_arch_init); | ||
220 | |||
221 | |||