2 * (C) Copyright 2004-2005
3 * Texas Instruments, <www.ti.com>
4 * Jian Zhang <jzhang@ti.com>
5 * Richard Woodruff <r-woodruff2@ti.com>
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <asm/arch/omap2430.h>
27 #include <asm/arch/bits.h>
28 #include <asm/arch/mem.h>
29 #include <asm/arch/sys_info.h>
30 #include <asm/arch/clocks.h>
32 static void wait_for_command_complete(unsigned int wd_base);
33 static void watchdog_init(void);
34 static void peripheral_enable(void);
35 static void muxSetupAll(void);
36 static u32 get_cpu_rev(void);
37 static u32 get_device_type(void);
38 static void prcm_init(void);
41 /*******************************************************
43 * Description: spinning delay to use before udelay works
44 ******************************************************/
45 static inline void delay (unsigned long loops)
47 __asm__ volatile ("1:\n"
49 "bne 1b":"=r" (loops):"0" (loops));
52 /*****************************************
54 * Description: Early hardware init.
55 *****************************************/
61 /******************************************
62 * get_cpu_rev(void) - extract version info
63 ******************************************/
67 v = __raw_readl(TAP_IDCODE_REG);
69 return(v+1); /* currently 2422 and 2420 match up */
72 /*************************************************************
73 * get_device_type(): tell if GP/HS/EMU/TST
74 *************************************************************/
75 u32 get_device_type(void)
78 mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
82 /*************************************************************
83 * Helper function to wait for the status of a register
84 *************************************************************/
85 u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
90 val = __raw_readl(read_addr) & read_bit_mask;
91 if (val == match_value)
98 /*************************************************************
99 * Support for multiple type of memory types
100 *************************************************************/
103 config_sdram_ddr(u32 rev)
105 /* ball D11, mode 0 */
106 __raw_writeb(0x08, 0x48000032);
108 /* SDRC_CS0 Configuration */
109 __raw_writel(H4_2420_SDRC_MDCFG_0_DDR, SDRC_MCFG_0);
110 __raw_writel(H4_2420_SDRC_SHARING, SDRC_SHARING);
112 __raw_writel(H4_242x_SDRC_RFR_CTRL_ES1, SDRC_RFR_CTRL);
113 __raw_writel(H4_242x_SDRC_ACTIM_CTRLA_0_ES1, SDRC_ACTIM_CTRLA_0);
114 __raw_writel(H4_242x_SDRC_ACTIM_CTRLB_0_ES1, SDRC_ACTIM_CTRLB_0);
116 /* Manual Command sequence */
117 __raw_writel(CMD_NOP, SDRC_MANUAL_0);
118 __raw_writel(CMD_PRECHARGE, SDRC_MANUAL_0);
119 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0);
120 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0);
124 * CS0 SDRC Mode Register
125 * Burst length = 4 - DDR memory
129 __raw_writel(0x00000032, SDRC_MR_0);
131 /* SDRC DLLA control register */
132 /* Delay is 90 degrees */
133 /* Enable DLL, Load counter with 115 (middle of range) */
134 __raw_writel(0x00000008, SDRC_DLLA_CTRL); // ES2.x
135 /* Enable DLL, Load counter with 128 (middle of range) */
136 __raw_writel(0x00000008, SDRC_DLLB_CTRL); // ES2.x
139 #endif // CFG_SDRAM_DDR
141 #ifdef CFG_SDRAM_COMBO
143 config_sdram_combo(u32 rev)
148 /* ball C12, mode 0 */
149 __raw_writeb(0x00, 0x480000a1);
150 /* ball D11, mode 0 */
151 __raw_writeb(0x00, 0x48000032);
152 /* ball B13, mode 0 - for CKE1 (not needed rkw for combo) */
153 __raw_writeb(0x00, 0x480000a3);
155 /*configure sdrc 32 bit for COMBO ddr sdram. Issue soft reset */
156 __raw_writel(0x00000012, SDRC_SYSCONFIG);
157 wait_on_value(BIT0, BIT0, SDRC_STATUS, 12000000); /* wait till reset done set */
158 __raw_writel(0x00000000, SDRC_SYSCONFIG);
160 /* SDRCTriState: no Tris */
161 /* CS0MuxCfg: 000 (32-bit SDRAM on D31..0) */
162 if (rev == CPU_2420_2422_ES1)
163 __raw_writel(H4_2422_SDRC_SHARING, SDRC_SHARING);
165 __raw_writel(H4_2420_SDRC_SHARING, SDRC_SHARING);
168 /* CS0 SDRC Memory Configuration, */
169 /* DDR-SDRAM, External SDRAM is x32bit, */
170 /* Configure to MUX9: 1x8Mbx32 */
171 __raw_writel(H4_2420_COMBO_MDCFG_0_DDR, SDRC_MCFG_0);
172 __raw_writel(H4_2420_SDRC_ACTIM_CTRLA_0, SDRC_ACTIM_CTRLA_0);
173 __raw_writel(H4_2420_SDRC_ACTIM_CTRLB_0, SDRC_ACTIM_CTRLB_0);
175 /* This is reqd only for ES1 */
176 if (rev == CPU_242X_ES1)
177 __raw_writel(H4_242x_SDRC_RFR_CTRL_ES1, SDRC_RFR_CTRL);
179 /* Manual Command sequence */
180 __raw_writel(CMD_NOP, SDRC_MANUAL_0);
182 __raw_writel(CMD_PRECHARGE, SDRC_MANUAL_0);
183 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0);
184 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0);
186 /* CS0 SDRC Mode Register */
187 /* Burst length = 4 - DDR memory */
189 /* CAS latency = 3 */
190 __raw_writel(H4_2422_SDRC_MR_0_DDR, SDRC_MR_0);
192 /* CS1 SDRC Memory Configuration, */
193 /* DDR-SDRAM, External SDRAM is x32bit, */
194 /* Configure to MUX9: 1x8Mbx32 */
195 __raw_writel(H4_2420_COMBO_MDCFG_0_DDR, SDRC_MCFG_1);
196 __raw_writel(H4_242X_SDRC_ACTIM_CTRLA_0_100MHz, SDRC_ACTIM_CTRLA_1);
197 __raw_writel(H4_2420_SDRC_ACTIM_CTRLB_0, SDRC_ACTIM_CTRLB_1);
198 /* This is reqd only for ES1 */
199 if (rev == CPU_242X_ES1)
200 __raw_writel(H4_242x_SDRC_RFR_CTRL_ES1, 0x680090d4);
202 /* Manual Command sequence */
203 __raw_writel(CMD_NOP, 0x680090d8);
204 __raw_writel(CMD_PRECHARGE, 0x680090d8);
205 __raw_writel(CMD_AUTOREFRESH, 0x680090d8);
206 __raw_writel(CMD_AUTOREFRESH, 0x680090d8);
208 /* CS1 SDRC Mode Register */
209 /* Burst length = 4 - DDR memory */
211 /* CAS latency = 3 */
212 __raw_writel(H4_2422_SDRC_MR_0_DDR, 0x680090b4);
214 /* SDRC DLLA control register */
215 /* Delay is 90 degrees */
217 if (rev == CPU_242X_ES1)
218 dllctrl = (BIT0|BIT3);
222 if (rev == CPU_2420_2422_ES1) {
223 /* Enable DLL, Load counter with 115 (middle of range) */
224 __raw_writel(0x00007306, SDRC_DLLA_CTRL);
225 __raw_writel(0x00007302, SDRC_DLLA_CTRL);
226 /* Enable DLL, Load counter with 128 (middle of range) */
227 __raw_writel(0x00007306, SDRC_DLLB_CTRL); /* load ctr value */
228 __raw_writel(0x00007302, SDRC_DLLB_CTRL); /* lock and go */
231 /* Enable DLL, Load counter with 115 (middle of range) */
232 __raw_writel(H4_2420_SDRC_DLLAB_CTRL, SDRC_DLLA_CTRL); // ES2.x
233 __raw_writel(H4_2420_SDRC_DLLAB_CTRL & ~(LOADDLL|dllctrl), SDRC_DLLA_CTRL); // ES2.x
234 // __raw_writel(0x00009808, SDRC_DLLA_CTRL); // ES2.x
235 /* Enable DLL, Load counter with 128 (middle of range) */
236 __raw_writel(H4_2420_SDRC_DLLAB_CTRL, SDRC_DLLB_CTRL); // ES2.x ?
237 __raw_writel(H4_2420_SDRC_DLLAB_CTRL & ~(LOADDLL|dllctrl), SDRC_DLLB_CTRL); // ES2.x
238 //__raw_writel(0x00009808, SDRC_DLLB_CTRL); // ES2.x
242 #endif // CFG_SDRAM_COMBO
244 #ifdef CFG_2430SDRAM_DDR
246 config_2430sdram_ddr(u32 rev)
248 u32 dllstat, dllctrl;
250 __raw_writel(0x00000012, SDRC_SYSCONFIG);
251 wait_on_value(BIT0, BIT0, SDRC_STATUS, 12000000); /* wait till reset done set */
252 __raw_writel(0x00000000, SDRC_SYSCONFIG);
254 /* Chip-level shared interface management */
255 /* SDRCTriState: no Tris */
256 /* CS0MuxCfg: 000 (32-bit SDRAM on D31..0) */
257 /* CS1MuxCfg: 000 (32-bit SDRAM on D31..0) */
258 __raw_writel(H4_2420_SDRC_SHARING, SDRC_SHARING);
260 /* CS0 SDRC Memory Configuration, */
261 /* DDR-SDRAM, External SDRAM is x32bit, */
262 /* Configure to MUX14: 32Mbx32 */
263 __raw_writel(SDP_2430_SDRC_MDCFG_0_DDR, SDRC_MCFG_0);
264 __raw_writel(SDP_2430_SDRC_ACTIM_CTRLA_0, SDRC_ACTIM_CTRLA_0);
265 __raw_writel(H4_2420_SDRC_ACTIM_CTRLB_0, SDRC_ACTIM_CTRLB_0);
267 __raw_writel(H4_2420_SDRC_RFR_CTRL, SDRC_RFR_CTRL);
269 /* Manual Command sequence */
270 __raw_writel(CMD_NOP, SDRC_MANUAL_0);
272 __raw_writel(CMD_PRECHARGE, SDRC_MANUAL_0);
273 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0);
274 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0);
276 /* CS0 SDRC Mode Register */
277 /* Burst length = 2 - SDR memory */
279 /* CAS latency = 3 */
280 __raw_writel(H4_2420_SDRC_MR_0_DDR, SDRC_MR_0);
282 /* Set up SDRC DLL values for 2430 DDR */
283 dllctrl = (SDP_2430_SDRC_DLLAB_CTRL & ~BIT2); /* set target ctrl val */
284 __raw_writel(dllctrl, SDRC_DLLA_CTRL); /* set lock mode */
285 __raw_writel(dllctrl, SDRC_DLLB_CTRL); /* set lock mode */
286 delay(0x1000); /* time to track to center */
287 dllstat = __raw_readl(SDRC_DLLA_STATUS) & 0xFF00; /* get status */
288 dllctrl = (dllctrl & 0x00FF) | dllstat | BIT2; /* build unlock value */
289 __raw_writel(dllctrl, SDRC_DLLA_CTRL); /* set unlock mode */
290 __raw_writel(dllctrl, SDRC_DLLB_CTRL); /* set unlock mode */
292 #endif // CFG_2430SDRAM_DDR
294 #ifdef CFG_SDRAM_STACKED
296 config_sdram_stacked(u32 rev)
299 /* Pin Muxing for SDRC */
300 __raw_writeb(0x00, 0x480000a1); /* mux mode 0 (CS1) */
301 __raw_writeb(0x00, 0x480000a3); /* mux mode 0 (CKE1) */
302 __raw_writeb(0x00, 0x48000032); /* connect sdrc_a12 */
303 __raw_writeb(0x00, 0x48000031); /* connect sdrc_a13 */
305 /* configure sdrc 32 bit for COMBO ddr sdram */
306 __raw_writel(0x00000010, SDRC_SYSCONFIG); /* no idle ack and RESET enable */
308 __raw_writel(0x00000010, SDRC_SYSCONFIG); /* smart idle mode */
311 /* U-boot is writing 0x00000100 though (H4_2420_SDRC_SHARING ) */
312 //__raw_writel(H4_2420_SDRC_SHARING, SDRC_SHARING);
314 __raw_writel(0x00004900, SDRC_SHARING);
316 /* SDRC_CS0 Configuration */
319 /* SDRC_CS1 Configuration */
320 __raw_writel(0x00000000, SDRC_CS_CFG); /* Remap CS1 to 0x80000000 */
322 /* Disable power down of CKE */
323 __raw_writel(0x00000085, SDRC_POWER);
325 __raw_writel(0x01A02019, SDRC_MCFG_1); /* SDRC_MCFG1 */
326 __raw_writel(0x0003DD03, SDRC_RFR_CTRL1); /* SDRC_RFR_CTRL1 */
327 __raw_writel(0x92DDC485, SDRC_ACTIM_CTRLA_1); /* SDRC_ACTIM_CTRLA0 */
328 __raw_writel(0x00000014, SDRC_ACTIM_CTRLB_1); /* SDRC_ACTIM_CTRLB0 */
330 /*Manual Command sequence */
331 __raw_writel(0x00000000, 0x680090D8);
332 __raw_writel(0x00000001, 0x680090D8);
333 __raw_writel(0x00000002, 0x680090D8);
334 __raw_writel(0x00000002, 0x680090D8);
336 /* CS0 SDRC Mode Register */
337 /* Burst length = 4 - DDR memory */
339 /* CAS latency = 3 */
340 __raw_writel(0x00000032, 0x680090B4);
341 __raw_writel(0x00000020, 0x680090BC); /* weak-strength driver */
343 /* SDRC DLLA control register */
344 /* Delay is 90 degrees */
345 if (rev == CPU_2420_2422_ES1) {
346 /* Enable DLL, Load counter with 115 (middle of range) */
347 __raw_writel(0x00007302, SDRC_DLLA_CTRL);
348 /* Enable DLL, Load counter with 128 (middle of range) */
349 __raw_writel(0x00007302, SDRC_DLLB_CTRL);
352 /* Enable DLL, Load counter with 115 (middle of range) */
353 __raw_writel(0x00003108, SDRC_DLLA_CTRL); // ES2.x
354 /* Enable DLL, Load counter with 128 (middle of range) */
355 __raw_writel(0x00003108, SDRC_DLLB_CTRL); // ES2.x
358 #endif // CFG_SDRAM_STACKED
360 /*************************************************************
361 * get_sys_clk_speed - determine reference oscillator speed
362 * based on known 32kHz clock and gptimer.
363 *************************************************************/
364 u32 get_osc_clk_speed(u32 *shift)
366 #define GPT_EN ((0<<2)|BIT1|BIT0) /* enable sys_clk NO-prescale /1 */
367 #define GPT_CTR OMAP24XX_GPT2+TCRR /* read counter address */
368 u32 start, cstart, cend, cdiff, val;
369 unsigned int v, if_clks=0, func_clks=0 ;
373 if(__raw_readl(PRCM_CLKSRC_CTRL) & BIT7){ /* if currently /2 */
380 val = __raw_readl(CM_CLKSEL2_CORE) | 0x4; /* mask for sys_clk use */
381 __raw_writel(val, CM_CLKSEL2_CORE); /* timer2 source to sys_clk */
382 __raw_writel(BIT4, CM_ICLKEN1_CORE); /* timer2 interface clock on */
383 __raw_writel(BIT4, CM_FCLKEN1_CORE); /* timer2 function clock on */
384 /* Enable GP2 timer.*/
387 v = __raw_readl(CM_ICLKEN1_CORE) | if_clks; /* Interface clocks on */
388 __raw_writel(v,CM_ICLKEN1_CORE );
389 v = __raw_readl(CM_FCLKEN1_CORE) | func_clks; /* Functional Clocks on */
390 __raw_writel(v, CM_FCLKEN1_CORE);
391 __raw_writel(0, OMAP24XX_GPT2+TLDR); /* start counting at 0 */
392 __raw_writel(GPT_EN, OMAP24XX_GPT2+TCLR); /* enable clock */
393 /* enable 32kHz source */ /* enabled out of reset */
394 /* determine sys_clk via gauging */
395 start = 20 + __raw_readl(S32K_CR); /* start time in 20 cycles*/
396 while(__raw_readl(S32K_CR) < start); /* dead loop till start time */
397 cstart = __raw_readl(GPT_CTR); /* get start sys_clk count */
398 while(__raw_readl(S32K_CR) < (start+20)); /* wait for 40 cycles */
399 cend = __raw_readl(GPT_CTR); /* get end sys_clk count */
400 cdiff = cend - cstart; /* get elapsed ticks */
401 /* based on number of ticks assign speed */
402 if(cdiff > (19000 >> *shift))
404 else if (cdiff > (15200 >> *shift))
406 else if (cdiff > (13000 >> *shift))
408 else if (cdiff > (9000 >> *shift))
410 else if (cdiff > (7600 >> *shift))
416 /*********************************************************************************
417 * prcm_init() - inits clocks for PRCM as defined in clocks.h (config II default).
418 * -- called from SRAM
419 *********************************************************************************/
423 u32 div, speed, val, div_by_2;
425 val = __raw_readl(PRCM_CLKSRC_CTRL) & ~(BIT1 | BIT0);
426 #if defined(OMAP2430_SQUARE_CLOCK_INPUT)
427 __raw_writel(val, PRCM_CLKSRC_CTRL);
429 __raw_writel((val | BIT0), PRCM_CLKSRC_CTRL);
431 speed = get_osc_clk_speed(&div_by_2);
432 if((speed > S19_2M) && (!div_by_2)){ /* if fast && /2 off, enable it */
433 val = ~(BIT6|BIT7) & __raw_readl(PRCM_CLKSRC_CTRL);
434 val |= (0x2 << 6); /* divide by 2 if (24,26,38.4) -> (12/13/19.2) */
435 __raw_writel(val, PRCM_CLKSRC_CTRL);
438 __raw_writel(0, CM_FCLKEN1_CORE); /* stop all clocks to reduce ringing */
439 __raw_writel(0, CM_FCLKEN2_CORE); /* may not be necessary */
440 __raw_writel(0, CM_ICLKEN1_CORE);
441 __raw_writel(0, CM_ICLKEN2_CORE);
443 /*DPLL into low power bypass (others off) */
444 __raw_writel(0x00000001, CM_CLKEN_PLL);
446 __raw_writel(DPLL_OUT, CM_CLKSEL2_PLL); /* set DPLL out */
447 __raw_writel(MPU_DIV, CM_CLKSEL_MPU); /* set MPU divider */
448 __raw_writel(DSP_DIV, CM_CLKSEL_DSP); /* set dsp and iva dividers */
449 __raw_writel(GFX_DIV, CM_CLKSEL_GFX); /* set gfx dividers */
450 __raw_writel(MDM_DIV, CM_CLKSEL_MDM); /* set mdm dividers */
453 __raw_writel(div, CM_CLKSEL1_CORE);/* set L3/L4/USB/Display/SSi dividers */
456 /*13MHz apll src, PRCM 'x' DPLL rate */
457 __raw_writel(DPLL_VAL, CM_CLKSEL1_PLL);
459 /*Valid the configuration */
460 __raw_writel(0x00000001, PRCM_CLKCFG_CTRL);
463 /* set up APLLS_CLKIN per crystal */
465 speed >>= 1; /* if fast shift to /2 range */
466 val = (0x2 << 23); /* default to 13Mhz for 2430c */
469 else if (speed == S19_2M)
471 val |= (~(BIT23|BIT24|BIT25) & __raw_readl(CM_CLKSEL1_PLL));
472 __raw_writel(val, CM_CLKSEL1_PLL);
474 __raw_writel(DPLL_LOCK|APLL_LOCK, CM_CLKEN_PLL); /* enable apll */
475 wait_on_value(BIT8, BIT8, CM_IDLEST_CKGEN, LDELAY);/* wait for apll lock */
480 void SEC_generic(void)
482 /* Permission values for registers -Full fledged permissions to all */
483 #define UNLOCK_1 0xFFFFFFFF
484 #define UNLOCK_2 0x00000000
485 #define UNLOCK_3 0x0000FFFF
486 /* Protection Module Register Target APE (PM_RT)*/
487 __raw_writel(UNLOCK_1, PM_RT_APE_BASE_ADDR_ARM + 0x68); /* REQ_INFO_PERMISSION_1 L*/
488 __raw_writel(UNLOCK_1, PM_RT_APE_BASE_ADDR_ARM + 0x50); /* READ_PERMISSION_0 L*/
489 __raw_writel(UNLOCK_1, PM_RT_APE_BASE_ADDR_ARM + 0x58); /* WRITE_PERMISSION_0 L*/
490 __raw_writel(UNLOCK_2, PM_RT_APE_BASE_ADDR_ARM + 0x60); /* ADDR_MATCH_1 L*/
493 __raw_writel(UNLOCK_3, PM_GPMC_BASE_ADDR_ARM + 0x48); /* REQ_INFO_PERMISSION_0 L*/
494 __raw_writel(UNLOCK_3, PM_GPMC_BASE_ADDR_ARM + 0x50); /* READ_PERMISSION_0 L*/
495 __raw_writel(UNLOCK_3, PM_GPMC_BASE_ADDR_ARM + 0x58); /* WRITE_PERMISSION_0 L*/
497 __raw_writel(UNLOCK_3, PM_OCM_RAM_BASE_ADDR_ARM + 0x48); /* REQ_INFO_PERMISSION_0 L*/
498 __raw_writel(UNLOCK_3, PM_OCM_RAM_BASE_ADDR_ARM + 0x50); /* READ_PERMISSION_0 L*/
499 __raw_writel(UNLOCK_3, PM_OCM_RAM_BASE_ADDR_ARM + 0x58); /* WRITE_PERMISSION_0 L*/
500 __raw_writel(UNLOCK_2, PM_OCM_RAM_BASE_ADDR_ARM + 0x80); /* ADDR_MATCH_2 L*/
503 __raw_writel(UNLOCK_3, PM_IVA2_BASE_ADDR_ARM + 0x48); /* REQ_INFO_PERMISSION_0 L*/
504 __raw_writel(UNLOCK_3, PM_IVA2_BASE_ADDR_ARM + 0x50); /* READ_PERMISSION_0 L*/
505 __raw_writel(UNLOCK_3, PM_IVA2_BASE_ADDR_ARM + 0x58); /* WRITE_PERMISSION_0 L*/
508 /**********************************************************
509 * Routine: try_unlock_sram()
510 * Description: If chip is GP type, unlock the SRAM for general use.
511 ***********************************************************/
512 void try_unlock_sram(void)
516 /* if GP device unlock device SRAM for general use */
517 mode = get_device_type();
519 if ((mode == GP_DEVICE) || (mode == HS_DEVICE) || (mode == EMU_DEVICE)
520 || (mode == TST_DEVICE)) {
521 /* Secure or Emulation device - HS/E/T */
527 /**********************************************************
529 * Description: Does early system init of muxing and clocks.
530 * - Called at time when only stack is available.
531 **********************************************************/
546 config_sdram_ddr(rev);
547 #elif defined(CFG_SDRAM_COMBO)
548 config_sdram_combo(rev);
549 #elif defined(CFG_2430SDRAM_DDR)
550 config_2430sdram_ddr(rev);
551 #elif defined(CFG_SDRAM_STACKED)
552 config_sdram_stacked(rev);
554 #error SDRAM type not supported
562 /*******************************************************
563 * Routine: misc_init_r
564 * Description: Init ethernet (done here so udelay works)
565 ********************************************************/
566 int misc_init_r (void)
571 /****************************************
572 * Routine: watchdog_init
573 * Description: Shut down watch dogs
574 *****************************************/
575 static void watchdog_init(void)
577 #define GP (BIT8|BIT9)
579 /* There are 4 watch dogs. 1 secure, and 3 general purpose.
580 * I would expect that the ROM takes care of the secure one,
581 * but we will try also. Of the 3 GP ones, 1 can reset us
582 * directly, the other 2 only generate MPU interrupts.
584 __raw_writel(WD_UNLOCK1 ,WD2_BASE+WSPR);
585 wait_for_command_complete(WD2_BASE);
586 __raw_writel(WD_UNLOCK2 ,WD2_BASE+WSPR);
590 /******************************************************
591 * Routine: wait_for_command_complete
592 * Description: Wait for posting to finish on watchdog
593 ******************************************************/
594 static void wait_for_command_complete(unsigned int wd_base)
598 pending = __raw_readl(wd_base+WWPS);
603 /**********************************************
605 * Description: sets uboots idea of sdram size
606 **********************************************/
612 /*****************************************************************
613 * Routine: peripheral_enable
614 * Description: Enable the clks & power for perifs (GPT2, UART1,...)
615 ******************************************************************/
616 static void peripheral_enable(void)
618 unsigned int v, if_clks=0, if_clks2 = 0, func_clks=0, func_clks2 = 0;
620 /* Enable GP2 timer.*/
623 v = __raw_readl(CM_CLKSEL2_CORE) | 0x4; /* Sys_clk input OMAP24XX_GPT2 */
624 __raw_writel(v, CM_CLKSEL2_CORE);
625 __raw_writel(0x1, CM_CLKSEL_WKUP);
628 /* Enable UART1 clock */
632 v = __raw_readl(CM_ICLKEN1_CORE) | if_clks; /* Interface clocks on */
633 __raw_writel(v,CM_ICLKEN1_CORE );
634 v = __raw_readl(CM_ICLKEN2_CORE) | if_clks2; /* Interface clocks on */
635 __raw_writel(v, CM_ICLKEN2_CORE);
636 v = __raw_readl(CM_FCLKEN1_CORE) | func_clks; /* Functional Clocks on */
637 __raw_writel(v, CM_FCLKEN1_CORE);
638 v = __raw_readl(CM_FCLKEN2_CORE) | func_clks2; /* Functional Clocks on */
639 __raw_writel(v, CM_FCLKEN2_CORE);
644 /* Do pin muxing for all the devices used in X-Loader */
645 #define MUX_VAL(OFFSET,VALUE)\
646 __raw_writeb(VALUE, OMAP24XX_CTRL_BASE + OFFSET);
647 static void muxSetupAll(void)
650 MUX_VAL(0x00B1, 0x1B) /* uart1_cts- EN, HI, 3, ->gpio_32 */
651 MUX_VAL(0x00B2, 0x1B) /* uart1_rts- EN, HI, 3, ->gpio_8 */
652 MUX_VAL(0x00B3, 0x1B) /* uart1_tx- EN, HI, 3, ->gpio_9 */
653 MUX_VAL(0x00B4, 0x1B) /* uart1_rx- EN, HI, 3, ->gpio_10 */
654 MUX_VAL(0x0107, 0x01) /* ssi1_dat_tx- Dis, 1, ->uart1_tx */
655 MUX_VAL(0x0108, 0x01) /* ssi1_flag_tx- Dis, 1, ->uart1_rts */
656 MUX_VAL(0x0109, 0x01) /* ssi1_rdy_tx- Dis, 1, ->uart1_cts */
657 MUX_VAL(0x010A, 0x01) /* ssi1_dat_rx- Dis, 1, ->uart1_rx */
659 /* Mux settings for SDRC */
660 MUX_VAL(0x0054, 0x1B) /* sdrc_a14 - EN, HI, 3, ->gpio_0 */
661 MUX_VAL(0x0055, 0x1B) /* sdrc_a13 - EN, HI, 3, ->gpio_1 */
662 MUX_VAL(0x0056, 0x00) /* sdrc_a12 - Dis, 0 */
663 MUX_VAL(0x0046, 0x00) /* sdrc_ncs1 - Dis, 0 */
664 MUX_VAL(0x0048, 0x00) /* sdrc_cke1 - Dis, 0 */
666 MUX_VAL(0x0030, 0x00) /* gpmc_clk - Dis, 0 */
667 MUX_VAL(0x0032, 0x00) /* gpmc_ncs1- Dis, 0 */
668 MUX_VAL(0x0033, 0x00) /* gpmc_ncs2- Dis, 0 */
669 MUX_VAL(0x0034, 0x03) /* gpmc_ncs3- Dis, 3, ->gpio_24 */
670 MUX_VAL(0x0035, 0x03) /* gpmc_ncs4- Dis, 3, ->gpio_25 */
671 MUX_VAL(0x0036, 0x00) /* gpmc_ncs5- Dis, 0 */
672 MUX_VAL(0x0037, 0x03) /* gpmc_ncs6- Dis, 3, ->gpio_27 */
673 MUX_VAL(0x0038, 0x00) /* gpmc_ncs7- Dis, 0 */
674 MUX_VAL(0x0040, 0x18) /* gpmc_wait1- Dis, 0 */
675 MUX_VAL(0x0041, 0x18) /* gpmc_wait2- Dis, 0 */
676 MUX_VAL(0x0042, 0x1B) /* gpmc_wait3- EN, HI, 3, ->gpio_35 */
677 MUX_VAL(0x0085, 0x1B) /* gpmc_a10- EN, HI, 3, ->gpio_3 */
684 /* GPMC Configuration */
687 /* global settings */
688 __raw_writel(0x10, GPMC_SYSCONFIG); /* smart idle */
689 __raw_writel(0x0, GPMC_IRQENABLE); /* isr's sources masked */
690 __raw_writel(0, GPMC_TIMEOUT_CONTROL);/* timeout disable */
692 __raw_writel(0x001, GPMC_CONFIG); /* set nWP, disable limited addr */
695 /* Set the GPMC Vals . For NAND boot on 2430SDP, NAND is mapped at CS0
696 * , NOR at CS1 and MPDB at CS5. And oneNAND boot, we map oneNAND at CS0.
697 * We configure only GPMC CS0 with required values. Configiring other devices
698 * at other CS in done in u-boot anyway. So we don't have to bother doing it here.
700 __raw_writel(0, GPMC_CONFIG7_0);
704 __raw_writel( SMNAND_GPMC_CONFIG1, GPMC_CONFIG1_0);
705 __raw_writel( SMNAND_GPMC_CONFIG2, GPMC_CONFIG2_0);
706 __raw_writel( SMNAND_GPMC_CONFIG3, GPMC_CONFIG3_0);
707 __raw_writel( SMNAND_GPMC_CONFIG4, GPMC_CONFIG4_0);
708 __raw_writel( SMNAND_GPMC_CONFIG5, GPMC_CONFIG5_0);
709 __raw_writel( SMNAND_GPMC_CONFIG6, GPMC_CONFIG6_0);
711 #else /* CFG_ONENAND */
712 __raw_writel( ONENAND_GPMC_CONFIG1, GPMC_CONFIG1_0);
713 __raw_writel( ONENAND_GPMC_CONFIG2, GPMC_CONFIG2_0);
714 __raw_writel( ONENAND_GPMC_CONFIG3, GPMC_CONFIG3_0);
715 __raw_writel( ONENAND_GPMC_CONFIG4, GPMC_CONFIG4_0);
716 __raw_writel( ONENAND_GPMC_CONFIG5, GPMC_CONFIG5_0);
717 __raw_writel( ONENAND_GPMC_CONFIG6, GPMC_CONFIG6_0);
720 /* Enable the GPMC Mapping */
721 __raw_writel(( ((OMAP24XX_GPMC_CS0_SIZE & 0xF)<<8) |
722 ((OMAP24XX_GPMC_CS0_MAP>>24) & 0x3F) |
723 (1<<6) ), GPMC_CONFIG7_0);
728 printf("Unsupported Chip!\n");
735 printf("OneNAND Unsupported !\n");
744 /* optionally do something like blinking LED */
745 void board_hang (void)