3 * Texas Instruments, <www.ti.com>
4 * Richard Woodruff <r-woodruff2@ti.com>
5 * Rajendra Nayak <rnayak@ti.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 #include <asm/arch/cpu.h>
26 #include <asm/arch/bits.h>
27 #include <asm/arch/clocks.h>
28 #include <asm/arch/mem.h>
29 #include <asm/arch/sys_proto.h>
30 #include <asm/arch/sys_info.h>
31 #include <asm/arch/clocks443x.h>
34 #define CONFIG_OMAP4_SDC 1
36 /* Used to index into DPLL parameter tables */
48 /* Tables having M,N,M2 et al values for different sys_clk speeds
49 * This table is generated only for OPP100
50 * The tables are organized as follows:
51 * Rows : 1 - 12M, 2 - 13M, 3 - 16.8M, 4 - 19.2M, 5 - 26M, 6 - 27M, 7 - 38.4M
55 struct dpll_param mpu_dpll_param[7] = {
57 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
59 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
61 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
63 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
65 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
67 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
70 /* RUN MPU @ 600 MHz */
71 {0x7d, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00},
73 {0x69, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00},
75 {0x1a, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00},
80 struct dpll_param iva_dpll_param[7] = {
82 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
84 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
86 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
88 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
90 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
92 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
94 #ifdef CONFIG_OMAP4_SDC
95 {0x61, 0x03, 0x00, 0x00, 0x04, 0x07, 0x00, 0x00},
97 {0x61, 0x03, 0x00, 0x00, 0x04, 0x07, 0x00, 0x00},
101 /* CORE parameters */
102 struct dpll_param core_dpll_param[7] = {
104 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
106 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
108 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
110 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
112 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
114 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
115 /* 38.4M values - DDR@200MHz*/
116 {0x7d, 0x05, 0x02, 0x05, 0x08, 0x04, 0x06, 0x05},
119 /* CORE parameters - ES2.1 */
120 struct dpll_param core_dpll_param_ddr400[7] = {
122 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
124 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
126 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
128 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
130 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
132 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
133 /* 38.4M values - DDR@400MHz*/
134 {0x7d, 0x05, 0x01, 0x05, 0x08, 0x04, 0x06, 0x05},
137 /* CORE parameters for L3 at 190 MHz - For ES1 only*/
138 struct dpll_param core_dpll_param_l3_190[7] = {
140 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
142 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
144 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
146 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
148 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
150 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
152 #ifdef CONFIG_OMAP4_SDC
154 {0x1f0, 0x18, 0x01, 0x05, 0x08, 0x04, 0x06, 0x05},
155 #else /* Default CORE @166MHz */
156 {0x1b0, 0x18, 0x01, 0x05, 0x08, 0x04, 0x06, 0x05},
159 {0x7d, 0x05, 0x01, 0x05, 0x08, 0x04, 0x06, 0x08},
164 struct dpll_param per_dpll_param[7] = {
166 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
168 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
170 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
172 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
174 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
176 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
180 {0x0a, 0x00, 0x04, 0x03, 0x06, 0x05, 0x02, 0x03},
182 {0x14, 0x00, 0x08, 0x06, 0x0c, 0x09, 0x04, 0x05},
186 struct dpll_param abe_dpll_param[7] = {
188 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
190 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
192 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
194 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
196 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
198 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
200 #ifdef CONFIG_OMAP4_SDC
201 {0x40, 0x18, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0},
203 {0x40, 0x18, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0},
208 struct dpll_param usb_dpll_param[7] = {
210 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
212 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
214 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
216 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
218 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
220 {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
222 #ifdef CONFIG_OMAP4_SDC
223 {0x32, 0x1, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0},
225 {0x32, 0x1, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0},
229 static void configure_mpu_dpll(u32 clk_index)
231 struct dpll_param *dpll_param_p;
233 /* Unlock the MPU dpll */
234 sr32(CM_CLKMODE_DPLL_MPU, 0, 3, PLL_MN_POWER_BYPASS);
235 wait_on_value(BIT0, 0, CM_IDLEST_DPLL_MPU, LDELAY);
237 /* Program MPU DPLL */
238 dpll_param_p = &mpu_dpll_param[clk_index];
240 sr32(CM_AUTOIDLE_DPLL_MPU, 0, 3, 0x0); /* Disable DPLL autoidle */
242 /* Set M,N,M2 values */
243 sr32(CM_CLKSEL_DPLL_MPU, 8, 11, dpll_param_p->m);
244 sr32(CM_CLKSEL_DPLL_MPU, 0, 6, dpll_param_p->n);
245 sr32(CM_DIV_M2_DPLL_MPU, 0, 5, dpll_param_p->m2);
246 sr32(CM_DIV_M2_DPLL_MPU, 8, 1, 0x1);
248 /* Lock the mpu dpll */
249 sr32(CM_CLKMODE_DPLL_MPU, 0, 3, PLL_LOCK | 0x10);
250 wait_on_value(BIT0, 1, CM_IDLEST_DPLL_MPU, LDELAY);
255 static void configure_iva_dpll(u32 clk_index)
257 struct dpll_param *dpll_param_p;
259 /* Unlock the IVA dpll */
260 sr32(CM_CLKMODE_DPLL_IVA, 0, 3, PLL_MN_POWER_BYPASS);
261 wait_on_value(BIT0, 0, CM_IDLEST_DPLL_IVA, LDELAY);
263 /* CM_BYPCLK_DPLL_IVA = CORE_X2_CLK/2 */
264 sr32(CM_BYPCLK_DPLL_IVA, 0, 2, 0x1);
266 /* Program IVA DPLL */
267 dpll_param_p = &iva_dpll_param[clk_index];
269 sr32(CM_AUTOIDLE_DPLL_IVA, 0, 3, 0x0); /* Disable DPLL autoidle */
272 sr32(CM_CLKSEL_DPLL_IVA, 8, 11, dpll_param_p->m);
273 sr32(CM_CLKSEL_DPLL_IVA, 0, 7, dpll_param_p->n);
274 sr32(CM_DIV_M4_DPLL_IVA, 0, 5, dpll_param_p->m4);
275 sr32(CM_DIV_M4_DPLL_IVA, 8, 1, 0x1);
276 sr32(CM_DIV_M5_DPLL_IVA, 0, 5, dpll_param_p->m5);
277 sr32(CM_DIV_M5_DPLL_IVA, 8, 1, 0x1);
279 /* Lock the iva dpll */
280 sr32(CM_CLKMODE_DPLL_IVA, 0, 3, PLL_LOCK);
281 wait_on_value(BIT0, 1, CM_IDLEST_DPLL_IVA, LDELAY);
284 static void configure_per_dpll(u32 clk_index)
286 struct dpll_param *dpll_param_p;
288 /* Unlock the PER dpll */
289 sr32(CM_CLKMODE_DPLL_PER, 0, 3, PLL_MN_POWER_BYPASS);
290 wait_on_value(BIT0, 0, CM_IDLEST_DPLL_PER, LDELAY);
292 /* Program PER DPLL */
293 dpll_param_p = &per_dpll_param[clk_index];
295 /* Disable autoidle */
296 sr32(CM_AUTOIDLE_DPLL_PER, 0, 3, 0x0);
298 sr32(CM_CLKSEL_DPLL_PER, 8, 11, dpll_param_p->m);
299 sr32(CM_CLKSEL_DPLL_PER, 0, 6, dpll_param_p->n);
300 sr32(CM_DIV_M2_DPLL_PER, 0, 5, dpll_param_p->m2);
301 sr32(CM_DIV_M3_DPLL_PER, 0, 5, dpll_param_p->m3);
302 sr32(CM_DIV_M4_DPLL_PER, 0, 5, dpll_param_p->m4);
303 sr32(CM_DIV_M5_DPLL_PER, 0, 5, dpll_param_p->m5);
304 sr32(CM_DIV_M6_DPLL_PER, 0, 5, dpll_param_p->m6);
305 sr32(CM_DIV_M7_DPLL_PER, 0, 5, dpll_param_p->m7);
308 sr32(CM_DIV_M2_DPLL_PER, 8, 1, 0x1);
309 sr32(CM_DIV_M3_DPLL_PER, 8, 1, 0x1);
310 sr32(CM_DIV_M4_DPLL_PER, 8, 1, 0x1);
311 sr32(CM_DIV_M5_DPLL_PER, 8, 1, 0x1);
312 sr32(CM_DIV_M6_DPLL_PER, 8, 1, 0x1);
313 sr32(CM_DIV_M7_DPLL_PER, 8, 1, 0x1);
315 /* Lock the per dpll */
316 sr32(CM_CLKMODE_DPLL_PER, 0, 3, PLL_LOCK);
317 wait_on_value(BIT0, 1, CM_IDLEST_DPLL_PER, LDELAY);
320 static void configure_abe_dpll(u32 clk_index)
322 struct dpll_param *dpll_param_p;
324 /* Select sys_clk as ref clk for ABE dpll */
325 sr32(CM_ABE_PLL_REF_CLKSEL, 0, 32, 0x0);
327 /* Enable slimbus and pad clocks */
328 sr32(CM_CLKSEL_ABE, 0, 32, 0x500);
330 /* Unlock the ABE dpll */
331 sr32(CM_CLKMODE_DPLL_ABE, 0, 3, PLL_MN_POWER_BYPASS);
332 wait_on_value(BIT0, 0, CM_IDLEST_DPLL_ABE, LDELAY);
334 /* Program ABE DPLL */
335 dpll_param_p = &abe_dpll_param[clk_index];
337 /* Disable autoidle */
338 sr32(CM_AUTOIDLE_DPLL_ABE, 0, 3, 0x0);
340 sr32(CM_CLKSEL_DPLL_ABE, 8, 11, dpll_param_p->m);
341 sr32(CM_CLKSEL_DPLL_ABE, 0, 6, dpll_param_p->n);
343 /* Force DPLL CLKOUTHIF to stay enabled */
344 sr32(CM_DIV_M2_DPLL_ABE, 0, 32, 0x500);
345 sr32(CM_DIV_M2_DPLL_ABE, 0, 5, dpll_param_p->m2);
346 sr32(CM_DIV_M2_DPLL_ABE, 8, 1, 0x1);
347 /* Force DPLL CLKOUTHIF to stay enabled */
348 sr32(CM_DIV_M3_DPLL_ABE, 0, 32, 0x100);
349 sr32(CM_DIV_M3_DPLL_ABE, 0, 5, dpll_param_p->m3);
350 sr32(CM_DIV_M3_DPLL_ABE, 8, 1, 0x1);
352 /* Lock the abe dpll */
353 sr32(CM_CLKMODE_DPLL_ABE, 0, 3, PLL_LOCK);
354 wait_on_value(BIT0, 1, CM_IDLEST_DPLL_ABE, LDELAY);
357 static void configure_usb_dpll(u32 clk_index)
359 struct dpll_param *dpll_param_p;
361 /* Select the 60Mhz clock 480/8 = 60*/
362 sr32(CM_CLKSEL_USB_60MHz, 0, 32, 0x1);
364 /* Unlock the USB dpll */
365 sr32(CM_CLKMODE_DPLL_USB, 0, 3, PLL_MN_POWER_BYPASS);
366 wait_on_value(BIT0, 0, CM_IDLEST_DPLL_USB, LDELAY);
368 /* Program USB DPLL */
369 dpll_param_p = &usb_dpll_param[clk_index];
371 /* Disable autoidle */
372 sr32(CM_AUTOIDLE_DPLL_USB, 0, 3, 0x0);
374 sr32(CM_CLKSEL_DPLL_USB, 8, 11, dpll_param_p->m);
375 sr32(CM_CLKSEL_DPLL_USB, 0, 6, dpll_param_p->n);
377 /* Force DPLL CLKOUT to stay active */
378 sr32(CM_DIV_M2_DPLL_USB, 0, 32, 0x100);
379 sr32(CM_DIV_M2_DPLL_USB, 0, 5, dpll_param_p->m2);
380 sr32(CM_DIV_M2_DPLL_USB, 8, 1, 0x1);
381 sr32(CM_CLKDCOLDO_DPLL_USB, 8, 1, 0x1);
383 /* Lock the usb dpll */
384 sr32(CM_CLKMODE_DPLL_USB, 0, 3, PLL_LOCK);
385 wait_on_value(BIT0, 1, CM_IDLEST_DPLL_USB, LDELAY);
387 /* force enable the CLKDCOLDO clock */
388 sr32(CM_CLKDCOLDO_DPLL_USB, 0, 32, 0x100);
391 static void configure_core_dpll(clk_index)
393 struct dpll_param *dpll_param_p;
395 /* Get the sysclk speed from cm_sys_clksel
396 * Set it to 38.4 MHz, in case ROM code is bypassed
401 /* CORE_CLK=CORE_X2_CLK/2, L3_CLK=CORE_CLK/2, L4_CLK=L3_CLK/2 */
402 sr32(CM_CLKSEL_CORE, 0, 32, 0x110);
404 /* Unlock the CORE dpll */
405 sr32(CM_CLKMODE_DPLL_CORE, 0, 3, PLL_MN_POWER_BYPASS);
406 wait_on_value(BIT0, 0, CM_IDLEST_DPLL_CORE, LDELAY);
408 /* Program Core DPLL */
409 switch (omap_revision()) {
411 dpll_param_p = &core_dpll_param_l3_190[clk_index];
414 dpll_param_p = &core_dpll_param[clk_index];
417 dpll_param_p = &core_dpll_param_ddr400[clk_index];
421 /* Disable autoidle */
422 sr32(CM_AUTOIDLE_DPLL_CORE, 0, 3, 0x0);
424 sr32(CM_CLKSEL_DPLL_CORE, 8, 11, dpll_param_p->m);
425 sr32(CM_CLKSEL_DPLL_CORE, 0, 6, dpll_param_p->n);
426 sr32(CM_DIV_M2_DPLL_CORE, 0, 5, dpll_param_p->m2);
427 sr32(CM_DIV_M3_DPLL_CORE, 0, 5, dpll_param_p->m3);
428 sr32(CM_DIV_M4_DPLL_CORE, 0, 5, dpll_param_p->m4);
429 sr32(CM_DIV_M5_DPLL_CORE, 0, 5, dpll_param_p->m5);
430 sr32(CM_DIV_M6_DPLL_CORE, 0, 5, dpll_param_p->m6);
431 sr32(CM_DIV_M7_DPLL_CORE, 0, 5, dpll_param_p->m7);
433 if (omap_revision() == OMAP4430_ES1_0) {
434 /* Do this only on ES1.0 */
435 sr32(CM_DIV_M2_DPLL_CORE, 8, 1, 0x1);
436 sr32(CM_DIV_M3_DPLL_CORE, 8, 1, 0x1);
437 sr32(CM_DIV_M4_DPLL_CORE, 8, 1, 0x1);
438 sr32(CM_DIV_M5_DPLL_CORE, 8, 1, 0x1);
439 sr32(CM_DIV_M6_DPLL_CORE, 8, 1, 0x0);
440 sr32(CM_DIV_M7_DPLL_CORE, 8, 1, 0x1);
443 /* Lock the core dpll */
444 sr32(CM_CLKMODE_DPLL_CORE, 0, 3, PLL_LOCK);
445 wait_on_value(BIT0, 1, CM_IDLEST_DPLL_CORE, LDELAY);
449 void configure_core_dpll_no_lock(void)
451 struct dpll_param *dpll_param_p;
454 /* Get the sysclk speed from cm_sys_clksel
455 * Set it to 38.4 MHz, in case ROM code is bypassed
457 __raw_writel(0x7, CM_SYS_CLKSEL);
460 clk_index = clk_index - 1;
461 /* CORE_CLK=CORE_X2_CLK/2, L3_CLK=CORE_CLK/2, L4_CLK=L3_CLK/2 */
462 sr32(CM_CLKSEL_CORE, 0, 32, 0x110);
464 /* Unlock the CORE dpll */
465 sr32(CM_CLKMODE_DPLL_CORE, 0, 3, PLL_MN_POWER_BYPASS);
466 wait_on_value(BIT0, 0, CM_IDLEST_DPLL_CORE, LDELAY);
468 /* Program Core DPLL */
469 switch (omap_revision()) {
471 dpll_param_p = &core_dpll_param_l3_190[clk_index];
474 dpll_param_p = &core_dpll_param[clk_index];
477 dpll_param_p = &core_dpll_param_ddr400[clk_index];
481 /* Disable autoidle */
482 sr32(CM_AUTOIDLE_DPLL_CORE, 0, 3, 0x0);
484 sr32(CM_CLKSEL_DPLL_CORE, 8, 11, dpll_param_p->m);
485 sr32(CM_CLKSEL_DPLL_CORE, 0, 6, dpll_param_p->n);
486 sr32(CM_DIV_M2_DPLL_CORE, 0, 5, dpll_param_p->m2);
487 sr32(CM_DIV_M3_DPLL_CORE, 0, 5, dpll_param_p->m3);
488 sr32(CM_DIV_M4_DPLL_CORE, 0, 5, dpll_param_p->m4);
489 sr32(CM_DIV_M5_DPLL_CORE, 0, 5, dpll_param_p->m5);
490 sr32(CM_DIV_M6_DPLL_CORE, 0, 5, dpll_param_p->m6);
491 sr32(CM_DIV_M7_DPLL_CORE, 0, 5, dpll_param_p->m7);
493 sr32(CM_DIV_M2_DPLL_CORE, 8, 1, 0x1);
494 sr32(CM_DIV_M3_DPLL_CORE, 8, 1, 0x1);
495 sr32(CM_DIV_M4_DPLL_CORE, 8, 1, 0x1);
496 sr32(CM_DIV_M5_DPLL_CORE, 8, 1, 0x1);
497 sr32(CM_DIV_M6_DPLL_CORE, 8, 1, 0x0);
498 sr32(CM_DIV_M7_DPLL_CORE, 8, 1, 0x1);
501 void lock_core_dpll(void)
503 /* Lock the core dpll */
504 sr32(CM_CLKMODE_DPLL_CORE, 0, 3, PLL_LOCK);
505 wait_on_value(BIT0, 1, CM_IDLEST_DPLL_CORE, LDELAY);
508 void lock_core_dpll_shadow(void)
510 struct dpll_param *dpll_param_p;
512 /* Lock the core dpll using freq update method */
513 *(volatile int*)0x4A004120 = 10; /* CM_CLKMODE_DPLL_CORE */
515 switch (omap_revision()) {
517 dpll_param_p = &core_dpll_param_l3_190[6];
520 dpll_param_p = &core_dpll_param[6];
523 dpll_param_p = &core_dpll_param_ddr400[6];
527 /* CM_SHADOW_FREQ_CONFIG1: DLL_OVERRIDE = 1(hack), DLL_RESET = 1,
528 * DPLL_CORE_M2_DIV =1, DPLL_CORE_DPLL_EN = 0x7, FREQ_UPDATE = 1
530 *(volatile int*)0x4A004260 = 0x70D | (dpll_param_p->m2 << 11);
532 /* Wait for Freq_Update to get cleared: CM_SHADOW_FREQ_CONFIG1 */
533 while (((*(volatile int*)0x4A004260) & 0x1) == 0x1)
536 /* Wait for DPLL to Lock : CM_IDLEST_DPLL_CORE */
537 wait_on_value(BIT0, 1, CM_IDLEST_DPLL_CORE, LDELAY);
538 /* lock_core_dpll(); */
541 static void enable_all_clocks(void)
543 volatile int regvalue = 0;
545 /* Enable Ducati clocks */
546 sr32(CM_DUCATI_DUCATI_CLKCTRL, 0, 32, 0x1);
547 sr32(CM_DUCATI_CLKSTCTRL, 0, 32, 0x2);
549 wait_on_value(BIT8, BIT8, CM_DUCATI_CLKSTCTRL, LDELAY);
551 * wait_on_value(BIT18|BIT17|BIT16, 0, CM_DUCATI_DUCATI_CLKCTRL,
555 /* Enable ivahd and sl2 clocks */
556 sr32(IVAHD_IVAHD_CLKCTRL, 0, 32, 0x1);
557 sr32(IVAHD_SL2_CLKCTRL, 0, 32, 0x1);
558 sr32(IVAHD_CLKSTCTRL, 0, 32, 0x2);
560 wait_on_value(BIT8, BIT8, IVAHD_CLKSTCTRL, LDELAY);
562 /* wait for ivahd to become accessible */
563 /* wait_on_value(BIT18|BIT17|BIT16, 0, IVAHD_IVAHD_CLKCTRL, LDELAY); */
564 /* wait for sl2 to become accessible */
565 /* wait_on_value(BIT17|BIT16, 0, IVAHD_SL2_CLKCTRL, LDELAY); */
567 /* Enable Tesla clocks */
568 sr32(DSP_DSP_CLKCTRL, 0, 32, 0x1);
569 sr32(DSP_CLKSTCTRL, 0, 32, 0x2);
571 wait_on_value(BIT8, BIT8, DSP_CLKSTCTRL, LDELAY);
573 /* wait for tesla to become accessible */
574 /* wait_on_value(BIT18|BIT17|BIT16, 0, DSP_DSP_CLKCTRL, LDELAY); */
576 /* TODO: Some hack needed by MM: Clean this */
577 #if 0 /* Doesn't work on some Zebu */
578 *(volatile int *)0x4a306910 = 0x00000003;
579 *(volatile int *)0x550809a0 = 0x00000001;
580 *(volatile int *)0x55080a20 = 0x00000007;
584 sr32(CM1_ABE_CLKSTCTRL, 0, 32, 0x3);
585 sr32(CM1_ABE_AESS_CLKCTRL, 0, 32, 0x2);
586 /* wait_on_value(BIT18|BIT17|BIT16, 0, CM1_ABE_AESS_CLKCTRL, LDELAY); */
587 sr32(CM1_ABE_PDM_CLKCTRL, 0, 32, 0x2);
588 /* wait_on_value(BIT17|BIT16, 0, CM1_ABE_PDM_CLKCTRL, LDELAY); */
589 sr32(CM1_ABE_DMIC_CLKCTRL, 0, 32, 0x2);
590 /* wait_on_value(BIT17|BIT16, 0, CM1_ABE_DMIC_CLKCTRL, LDELAY); */
591 sr32(CM1_ABE_MCASP_CLKCTRL, 0, 32, 0x2);
592 /* wait_on_value(BIT17|BIT16, 0, CM1_ABE_MCASP_CLKCTRL, LDELAY); */
593 sr32(CM1_ABE_MCBSP1_CLKCTRL, 0, 32, 0x08000002);
594 /* wait_on_value(BIT17|BIT16, 0, CM1_ABE_MCBSP1_CLKCTRL, LDELAY); */
595 sr32(CM1_ABE_MCBSP2_CLKCTRL, 0, 32, 0x08000002);
596 /* wait_on_value(BIT17|BIT16, 0, CM1_ABE_MCBSP2_CLKCTRL, LDELAY); */
597 sr32(CM1_ABE_MCBSP3_CLKCTRL, 0, 32, 0x08000002);
598 /* wait_on_value(BIT17|BIT16, 0, CM1_ABE_MCBSP3_CLKCTRL, LDELAY); */
599 sr32(CM1_ABE_SLIMBUS_CLKCTRL, 0, 32, 0xf02);
600 /* wait_on_value(BIT17|BIT16, 0, CM1_ABE_SLIMBUS_CLKCTRL, LDELAY); */
601 sr32(CM1_ABE_TIMER5_CLKCTRL, 0, 32, 0x2);
602 /* wait_on_value(BIT17|BIT16, 0, CM1_ABE_TIMER5_CLKCTRL, LDELAY); */
603 sr32(CM1_ABE_TIMER6_CLKCTRL, 0, 32, 0x2);
604 /* wait_on_value(BIT17|BIT16, 0, CM1_ABE_TIMER6_CLKCTRL, LDELAY); */
605 sr32(CM1_ABE_TIMER7_CLKCTRL, 0, 32, 0x2);
606 /* wait_on_value(BIT17|BIT16, 0, CM1_ABE_TIMER7_CLKCTRL, LDELAY); */
607 sr32(CM1_ABE_TIMER8_CLKCTRL, 0, 32, 0x2);
608 /* wait_on_value(BIT17|BIT16, 0, CM1_ABE_TIMER8_CLKCTRL, LDELAY); */
609 sr32(CM1_ABE_WDT3_CLKCTRL, 0, 32, 0x2);
610 /* wait_on_value(BIT17|BIT16, 0, CM1_ABE_WDT3_CLKCTRL, LDELAY); */
611 /* Disable sleep transitions */
612 sr32(CM1_ABE_CLKSTCTRL, 0, 32, 0x0);
615 sr32(CM_L4PER_CLKSTCTRL, 0, 32, 0x2);
616 sr32(CM_L4PER_DMTIMER10_CLKCTRL, 0, 32, 0x2);
617 wait_on_value(BIT17|BIT16, 0, CM_L4PER_DMTIMER10_CLKCTRL, LDELAY);
618 sr32(CM_L4PER_DMTIMER11_CLKCTRL, 0, 32, 0x2);
619 wait_on_value(BIT17|BIT16, 0, CM_L4PER_DMTIMER11_CLKCTRL, LDELAY);
620 sr32(CM_L4PER_DMTIMER2_CLKCTRL, 0, 32, 0x2);
621 wait_on_value(BIT17|BIT16, 0, CM_L4PER_DMTIMER2_CLKCTRL, LDELAY);
622 sr32(CM_L4PER_DMTIMER3_CLKCTRL, 0, 32, 0x2);
623 wait_on_value(BIT17|BIT16, 0, CM_L4PER_DMTIMER3_CLKCTRL, LDELAY);
624 sr32(CM_L4PER_DMTIMER4_CLKCTRL, 0, 32, 0x2);
625 wait_on_value(BIT17|BIT16, 0, CM_L4PER_DMTIMER4_CLKCTRL, LDELAY);
626 sr32(CM_L4PER_DMTIMER9_CLKCTRL, 0, 32, 0x2);
627 wait_on_value(BIT17|BIT16, 0, CM_L4PER_DMTIMER9_CLKCTRL, LDELAY);
630 sr32(CM_L4PER_GPIO2_CLKCTRL, 0, 32, 0x1);
631 wait_on_value(BIT17|BIT16, 0, CM_L4PER_GPIO2_CLKCTRL, LDELAY);
632 sr32(CM_L4PER_GPIO3_CLKCTRL, 0, 32, 0x1);
633 wait_on_value(BIT17|BIT16, 0, CM_L4PER_GPIO3_CLKCTRL, LDELAY);
634 sr32(CM_L4PER_GPIO4_CLKCTRL, 0, 32, 0x1);
635 wait_on_value(BIT17|BIT16, 0, CM_L4PER_GPIO4_CLKCTRL, LDELAY);
636 sr32(CM_L4PER_GPIO5_CLKCTRL, 0, 32, 0x1);
637 wait_on_value(BIT17|BIT16, 0, CM_L4PER_GPIO5_CLKCTRL, LDELAY);
638 sr32(CM_L4PER_GPIO6_CLKCTRL, 0, 32, 0x1);
639 wait_on_value(BIT17|BIT16, 0, CM_L4PER_GPIO6_CLKCTRL, LDELAY);
641 sr32(CM_L4PER_HDQ1W_CLKCTRL, 0, 32, 0x2);
644 sr32(CM_L4PER_I2C1_CLKCTRL, 0, 32, 0x2);
645 wait_on_value(BIT17|BIT16, 0, CM_L4PER_I2C1_CLKCTRL, LDELAY);
646 sr32(CM_L4PER_I2C2_CLKCTRL, 0, 32, 0x2);
647 wait_on_value(BIT17|BIT16, 0, CM_L4PER_I2C2_CLKCTRL, LDELAY);
648 sr32(CM_L4PER_I2C3_CLKCTRL, 0, 32, 0x2);
649 wait_on_value(BIT17|BIT16, 0, CM_L4PER_I2C3_CLKCTRL, LDELAY);
650 sr32(CM_L4PER_I2C4_CLKCTRL, 0, 32, 0x2);
651 wait_on_value(BIT17|BIT16, 0, CM_L4PER_I2C4_CLKCTRL, LDELAY);
653 sr32(CM_L4PER_MCBSP4_CLKCTRL, 0, 32, 0x2);
654 wait_on_value(BIT17|BIT16, 0, CM_L4PER_MCBSP4_CLKCTRL, LDELAY);
657 sr32(CM_L4PER_MCSPI1_CLKCTRL, 0, 32, 0x2);
658 wait_on_value(BIT17|BIT16, 0, CM_L4PER_MCSPI1_CLKCTRL, LDELAY);
659 sr32(CM_L4PER_MCSPI2_CLKCTRL, 0, 32, 0x2);
660 wait_on_value(BIT17|BIT16, 0, CM_L4PER_MCSPI2_CLKCTRL, LDELAY);
661 sr32(CM_L4PER_MCSPI3_CLKCTRL, 0, 32, 0x2);
662 wait_on_value(BIT17|BIT16, 0, CM_L4PER_MCSPI3_CLKCTRL, LDELAY);
663 sr32(CM_L4PER_MCSPI4_CLKCTRL, 0, 32, 0x2);
664 wait_on_value(BIT17|BIT16, 0, CM_L4PER_MCSPI4_CLKCTRL, LDELAY);
667 sr32(CM_L3INIT_HSMMC1_CLKCTRL, 0, 2, 0x2);
668 sr32(CM_L3INIT_HSMMC1_CLKCTRL, 24, 1, 0x1);
669 /*wait_on_value(BIT18|BIT17|BIT16, 0, CM_L3INIT_HSMMC1_CLKCTRL,
671 sr32(CM_L3INIT_HSMMC2_CLKCTRL, 0, 2, 0x2);
672 sr32(CM_L3INIT_HSMMC2_CLKCTRL, 24, 1, 0x1);
673 /*wait_on_value(BIT18|BIT17|BIT16, 0, CM_L3INIT_HSMMC2_CLKCTRL,
675 sr32(CM_L4PER_MMCSD3_CLKCTRL, 0, 32, 0x2);
676 wait_on_value(BIT18|BIT17|BIT16, 0, CM_L4PER_MMCSD3_CLKCTRL, LDELAY);
677 sr32(CM_L4PER_MMCSD4_CLKCTRL, 0, 32, 0x2);
678 wait_on_value(BIT18|BIT17|BIT16, 0, CM_L4PER_MMCSD4_CLKCTRL, LDELAY);
679 sr32(CM_L4PER_MMCSD5_CLKCTRL, 0, 32, 0x2);
680 wait_on_value(BIT17|BIT16, 0, CM_L4PER_MMCSD5_CLKCTRL, LDELAY);
683 sr32(CM_L4PER_UART1_CLKCTRL, 0, 32, 0x2);
684 wait_on_value(BIT17|BIT16, 0, CM_L4PER_UART1_CLKCTRL, LDELAY);
685 sr32(CM_L4PER_UART2_CLKCTRL, 0, 32, 0x2);
686 wait_on_value(BIT17|BIT16, 0, CM_L4PER_UART2_CLKCTRL, LDELAY);
687 sr32(CM_L4PER_UART3_CLKCTRL, 0, 32, 0x2);
688 wait_on_value(BIT17|BIT16, 0, CM_L4PER_UART3_CLKCTRL, LDELAY);
689 sr32(CM_L4PER_UART4_CLKCTRL, 0, 32, 0x2);
690 wait_on_value(BIT17|BIT16, 0, CM_L4PER_UART4_CLKCTRL, LDELAY);
693 sr32(CM_WKUP_GPIO1_CLKCTRL, 0, 32, 0x1);
694 wait_on_value(BIT17|BIT16, 0, CM_WKUP_GPIO1_CLKCTRL, LDELAY);
695 sr32(CM_WKUP_TIMER1_CLKCTRL, 0, 32, 0x01000002);
696 wait_on_value(BIT17|BIT16, 0, CM_WKUP_TIMER1_CLKCTRL, LDELAY);
698 sr32(CM_WKUP_KEYBOARD_CLKCTRL, 0, 32, 0x2);
699 wait_on_value(BIT17|BIT16, 0, CM_WKUP_KEYBOARD_CLKCTRL, LDELAY);
701 sr32(CM_SDMA_CLKSTCTRL, 0, 32, 0x0);
702 sr32(CM_MEMIF_CLKSTCTRL, 0, 32, 0x3);
703 sr32(CM_MEMIF_EMIF_1_CLKCTRL, 0, 32, 0x1);
704 wait_on_value(BIT17|BIT16, 0, CM_MEMIF_EMIF_1_CLKCTRL, LDELAY);
705 sr32(CM_MEMIF_EMIF_2_CLKCTRL, 0, 32, 0x1);
706 wait_on_value(BIT17|BIT16, 0, CM_MEMIF_EMIF_2_CLKCTRL, LDELAY);
707 sr32(CM_D2D_CLKSTCTRL, 0, 32, 0x3);
708 sr32(CM_L3_2_GPMC_CLKCTRL, 0, 32, 0x1);
709 wait_on_value(BIT17|BIT16, 0, CM_L3_2_GPMC_CLKCTRL, LDELAY);
710 sr32(CM_L3INSTR_L3_3_CLKCTRL, 0, 32, 0x1);
711 wait_on_value(BIT17|BIT16, 0, CM_L3INSTR_L3_3_CLKCTRL, LDELAY);
712 sr32(CM_L3INSTR_L3_INSTR_CLKCTRL, 0, 32, 0x1);
713 wait_on_value(BIT17|BIT16, 0, CM_L3INSTR_L3_INSTR_CLKCTRL, LDELAY);
714 sr32(CM_L3INSTR_OCP_WP1_CLKCTRL, 0, 32, 0x1);
715 wait_on_value(BIT17|BIT16, 0, CM_L3INSTR_OCP_WP1_CLKCTRL, LDELAY);
718 sr32(CM_WKUP_WDT2_CLKCTRL, 0, 32, 0x2);
719 wait_on_value(BIT17|BIT16, 0, CM_WKUP_WDT2_CLKCTRL, LDELAY);
721 /* Enable Camera clocks */
722 sr32(CM_CAM_CLKSTCTRL, 0, 32, 0x3);
723 sr32(CM_CAM_ISS_CLKCTRL, 0, 32, 0x102);
724 /* wait_on_value(BIT18|BIT17|BIT16, 0, CM_CAM_ISS_CLKCTRL, LDELAY); */
725 sr32(CM_CAM_FDIF_CLKCTRL, 0, 32, 0x2);
726 /* wait_on_value(BIT18|BIT17|BIT16, 0, CM_CAM_FDIF_CLKCTRL, LDELAY); */
727 sr32(CM_CAM_CLKSTCTRL, 0, 32, 0x0);
729 /* Enable DSS clocks */
730 /* PM_DSS_PWRSTCTRL ON State and LogicState = 1 (Retention) */
731 *(volatile int *)0x4A307100 = 0x7; /* DSS_PRM */
732 sr32(CM_DSS_CLKSTCTRL, 0, 32, 0x2);
733 sr32(CM_DSS_DSS_CLKCTRL, 0, 32, 0xf02);
734 /* wait_on_value(BIT18|BIT17|BIT16, 0, CM_DSS_DSS_CLKCTRL, LDELAY); */
735 sr32(CM_DSS_DEISS_CLKCTRL, 0, 32, 0x2);
736 /* wait_on_value(BIT18|BIT17|BIT16, 0, CM_DSS_DEISS_CLKCTRL, LDELAY); */
738 /* Check for DSS Clocks */
739 while (((*(volatile int *)0x4A009100) & 0xF00) != 0xE00)
740 /* Set HW_AUTO transition mode */
741 sr32(CM_DSS_CLKSTCTRL, 0, 32, 0x3);
743 /* Enable SGX clocks */
744 sr32(CM_SGX_CLKSTCTRL, 0, 32, 0x2);
745 sr32(CM_SGX_SGX_CLKCTRL, 0, 32, 0x2);
746 /* wait_on_value(BIT18|BIT17|BIT16, 0, CM_SGX_SGX_CLKCTRL, LDELAY); */
747 /* Check for SGX FCLK and ICLK */
748 while ((*(volatile int *)0x4A009200) != 0x302)
750 /* sr32(CM_SGX_CLKSTCTRL, 0, 32, 0x0); */
751 /* Enable hsi/unipro/usb clocks */
752 sr32(CM_L3INIT_HSI_CLKCTRL, 0, 32, 0x1);
753 /* wait_on_value(BIT18|BIT17|BIT16, 0, CM_L3INIT_HSI_CLKCTRL,
755 sr32(CM_L3INIT_UNIPRO1_CLKCTRL, 0, 32, 0x2);
756 /* wait_on_value(BIT18|BIT17|BIT16, 0, CM_L3INIT_UNIPRO1_CLKCTRL,
758 sr32(CM_L3INIT_HSUSBHOST_CLKCTRL, 0, 32, 0x2);
759 /* wait_on_value(BIT18|BIT17|BIT16, 0, CM_L3INIT_HSUSBHOST_CLKCTRL,
761 sr32(CM_L3INIT_HSUSBOTG_CLKCTRL, 0, 32, 0x1);
762 /* wait_on_value(BIT18|BIT17|BIT16, 0, CM_L3INIT_HSUSBOTG_CLKCTRL,
764 sr32(CM_L3INIT_HSUSBTLL_CLKCTRL, 0, 32, 0x1);
765 /* wait_on_value(BIT17|BIT16, 0, CM_L3INIT_HSUSBTLL_CLKCTRL, LDELAY); */
766 sr32(CM_L3INIT_FSUSB_CLKCTRL, 0, 32, 0x2);
767 /* wait_on_value(BIT18|BIT17|BIT16, 0, CM_L3INIT_FSUSB_CLKCTRL,
769 /* enable the 32K, 48M optional clocks and enable the module */
770 sr32(CM_L3INIT_USBPHY_CLKCTRL, 0, 32, 0x301);
771 /* wait_on_value(BIT17|BIT16, 0, CM_L3INIT_USBPHY_CLKCTRL, LDELAY); */
774 /******************************************************************************
775 * prcm_init() - inits clocks for PRCM as defined in clocks.h
776 * -- called from SRAM, or Flash (using temp SRAM stack).
777 *****************************************************************************/
782 /* Get the sysclk speed from cm_sys_clksel
783 * Set the CM_SYS_CLKSEL in case ROM code has not set
785 __raw_writel(0x7, CM_SYS_CLKSEL);
786 clk_index = readl(CM_SYS_CLKSEL);
788 return; /* Sys clk uninitialized */
789 /* Core DPLL is locked using FREQ update method */
790 /* configure_core_dpll(clk_index - 1); */
792 /* Configure all DPLL's at 100% OPP */
793 configure_mpu_dpll(clk_index - 1);
794 configure_iva_dpll(clk_index - 1);
795 configure_per_dpll(clk_index - 1);
796 configure_abe_dpll(clk_index - 1);
797 configure_usb_dpll(clk_index - 1);
799 #ifdef CONFIG_OMAP4_SDC
800 /* Enable all clocks */