3 * Texas Instruments, <www.ti.com>
4 * Jian Zhang <jzhang@ti.com>
5 * Richard Woodruff <r-woodruff2@ti.com>
7 * Modified for the Pandora
8 * John Willis <source@distant-earth.com>
10 * See file CREDITS for list of people who contributed to this
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33 #include <asm/arch/cpu.h>
34 #include <asm/arch/bits.h>
35 #include <asm/arch/mux.h>
36 #include <asm/arch/sys_proto.h>
37 #include <asm/arch/sys_info.h>
38 #include <asm/arch/clocks.h>
39 #include <asm/arch/mem.h>
41 /* Used to index into DPLL parameter tables */
49 typedef struct dpll_param dpll_param;
51 /* Following functions are exported from lowlevel_init.S */
52 extern dpll_param *get_mpu_dpll_param();
53 extern dpll_param *get_iva_dpll_param();
54 extern dpll_param *get_core_dpll_param();
55 extern dpll_param *get_per_dpll_param();
57 #define __raw_readl(a) (*(volatile unsigned int *)(a))
58 #define __raw_writel(v, a) (*(volatile unsigned int *)(a) = (v))
59 #define __raw_readw(a) (*(volatile unsigned short *)(a))
60 #define __raw_writew(v, a) (*(volatile unsigned short *)(a) = (v))
62 /*******************************************************
64 * Description: spinning delay to use before udelay works
65 ******************************************************/
66 static inline void delay(unsigned long loops)
68 __asm__ volatile ("1:\n" "subs %0, %1, #1\n"
69 "bne 1b":"=r" (loops):"0"(loops));
72 void udelay (unsigned long usecs) {
76 /*****************************************
78 * Description: Early hardware init.
79 *****************************************/
82 #if defined(CFG_PRINTF) && defined(CONFIG_DRIVER_OMAP34XX_I2C)
85 /* do additional init to prevent trash being output on startup */
88 #ifdef CONFIG_PANDORA_FINAL
89 /* restore GPBR1 for charging to work -
90 * boot ROM or something clears it before us */
92 i2c_write(0x49, 0x91, 1, &byte, 1);
94 /*VAUX3 = 2.8V (AV connector)*/
96 i2c_write(0x4B, 0x7A, 1, &byte, 1);
98 i2c_write(0x4B, 0x7D, 1, &byte, 1);
100 /*VAUX4 = 2.8V (TOUCH,NUBS,RS-232 TRANSCEIVER)*/
102 i2c_write(0x4B, 0x7E, 1, &byte, 1);
104 i2c_write(0x4B, 0x81, 1, &byte, 1);
112 /*************************************************************
113 * get_device_type(): tell if GP/HS/EMU/TST
114 *************************************************************/
115 u32 get_device_type(void)
118 mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
122 /************************************************
123 * get_sysboot_value(void) - return SYS_BOOT[4:0]
124 ************************************************/
125 u32 get_sysboot_value(void)
128 mode = __raw_readl(CONTROL_STATUS) & (SYSBOOT_MASK);
132 /*************************************************************
133 * Routine: get_mem_type(void) - returns the kind of memory connected
134 * to GPMC that we are trying to boot form. Uses SYS BOOT settings.
135 *************************************************************/
136 u32 get_mem_type(void)
138 u32 mem_type = get_sysboot_value();
180 /******************************************
181 * get_cpu_rev(void) - extract version info
182 ******************************************/
183 u32 get_cpu_rev(void)
186 /* On ES1.0 the IDCODE register is not exposed on L4
187 * so using CPU ID to differentiate
188 * between ES2.0 and ES1.0.
190 __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
191 if ((cpuid & 0xf) == 0x0)
198 /******************************************
199 * cpu_is_3410(void) - returns true for 3410
200 ******************************************/
201 u32 cpu_is_3410(void)
204 if (get_cpu_rev() < CPU_3430_ES2) {
207 /* read scalability status and return 1 for 3410*/
208 status = __raw_readl(CONTROL_SCALABLE_OMAP_STATUS);
209 /* Check whether MPU frequency is set to 266 MHz which
210 * is nominal for 3410. If yes return true else false
212 if (((status >> 8) & 0x3) == 0x2)
219 /*****************************************************************
220 * sr32 - clear & set a value in a bit range for a 32 bit address
221 *****************************************************************/
222 void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
227 tmp = __raw_readl(addr) & ~(msk << start_bit);
228 tmp |= value << start_bit;
229 __raw_writel(tmp, addr);
232 /*********************************************************************
233 * wait_on_value() - common routine to allow waiting for changes in
235 *********************************************************************/
236 u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
241 val = __raw_readl(read_addr) & read_bit_mask;
242 if (val == match_value)
249 #ifdef CFG_3430SDRAM_DDR
250 /*********************************************************************
251 * config_3430sdram_ddr() - Init DDR on 3430SDP dev board.
252 *********************************************************************/
253 void config_3430sdram_ddr(void)
255 /* reset sdrc controller */
256 __raw_writel(SOFTRESET, SDRC_SYSCONFIG);
257 wait_on_value(BIT0, BIT0, SDRC_STATUS, 12000000);
258 __raw_writel(0, SDRC_SYSCONFIG);
260 /* setup sdrc to ball mux */
261 __raw_writel(SDP_SDRC_SHARING, SDRC_SHARING);
263 /* SDRC put in weak */
264 // (*(unsigned int*)0x6D00008C) = 0x00000020;
266 /* SDRC_MCFG0 register */
267 (*(unsigned int*)0x6D000080) = 0x02584099;//from Micron
269 /* SDRC_ACTIM_CTRLA0 register */
270 //our value (*(unsigned int*)0x6D00009c) = 0xa29db4c6;// for 166M
271 (*(unsigned int*)0x6D00009c) = 0xaa9db4c6;// for 166M from rkw
273 /* SDRC_ACTIM_CTRLB0 register */
274 //from micron (*(unsigned int*)0x6D0000a0) = 0x12214;// for 166M
276 // (*(unsigned int*)0x6D0000a0) = 0x00011417; our value
277 (*(unsigned int*)0x6D0000a0) = 0x00011517;
279 /* SDRC_RFR_CTRL0 register */
280 //from micron (*(unsigned int*)0x6D0000a4) =0x54601; // for 166M
282 (*(unsigned int*)0x6D0000a4) =0x0004DC01;
284 /* Disble Power Down of CKE cuz of 1 CKE on combo part */
285 (*(unsigned int*)0x6D000070) = 0x00000081;
287 /* SDRC_Manual command register */
288 (*(unsigned int*)0x6D0000a8) = 0x00000000; // NOP command
290 (*(unsigned int*)0x6D0000a8) = 0x00000001; // Precharge command
291 (*(unsigned int*)0x6D0000a8) = 0x00000002; // Auto-refresh command
292 (*(unsigned int*)0x6D0000a8) = 0x00000002; // Auto-refresh command
294 /* SDRC MR0 register */
295 (*(int*)0x6D000084) = 0x00000032; // Burst length =4
297 // Write Burst = Read Burst
300 /* SDRC DLLA control register */
301 (*(unsigned int*)0x6D000060) = 0x0000A;
302 delay(0x20000); // some delay
305 #endif /* CFG_3430SDRAM_DDR */
307 /*************************************************************
308 * get_sys_clk_speed - determine reference oscillator speed
309 * based on known 32kHz clock and gptimer.
310 *************************************************************/
311 u32 get_osc_clk_speed(void)
313 u32 start, cstart, cend, cdiff, val;
315 val = __raw_readl(PRM_CLKSRC_CTRL);
316 /* If SYS_CLK is being divided by 2, remove for now */
317 val = (val & (~BIT7)) | BIT6;
318 __raw_writel(val, PRM_CLKSRC_CTRL);
321 val = __raw_readl(CM_CLKSEL_WKUP) | BIT0;
322 __raw_writel(val, CM_CLKSEL_WKUP); /* select sys_clk for GPT1 */
324 /* Enable I and F Clocks for GPT1 */
325 val = __raw_readl(CM_ICLKEN_WKUP) | BIT0 | BIT2;
326 __raw_writel(val, CM_ICLKEN_WKUP);
327 val = __raw_readl(CM_FCLKEN_WKUP) | BIT0;
328 __raw_writel(val, CM_FCLKEN_WKUP);
330 __raw_writel(0, OMAP34XX_GPT1 + TLDR); /* start counting at 0 */
331 __raw_writel(GPT_EN, OMAP34XX_GPT1 + TCLR); /* enable clock */
332 /* enable 32kHz source */
333 /* enabled out of reset */
334 /* determine sys_clk via gauging */
336 start = 20 + __raw_readl(S32K_CR); /* start time in 20 cycles */
337 while (__raw_readl(S32K_CR) < start) ; /* dead loop till start time */
338 cstart = __raw_readl(OMAP34XX_GPT1 + TCRR); /* get start sys_clk count */
339 while (__raw_readl(S32K_CR) < (start + 20)) ; /* wait for 40 cycles */
340 cend = __raw_readl(OMAP34XX_GPT1 + TCRR); /* get end sys_clk count */
341 cdiff = cend - cstart; /* get elapsed ticks */
343 /* based on number of ticks assign speed */
346 else if (cdiff > 15200)
348 else if (cdiff > 13000)
350 else if (cdiff > 9000)
352 else if (cdiff > 7600)
358 /******************************************************************************
359 * get_sys_clkin_sel() - returns the sys_clkin_sel field value based on
360 * -- input oscillator clock frequency.
362 *****************************************************************************/
363 void get_sys_clkin_sel(u32 osc_clk, u32 * sys_clkin_sel)
365 if (osc_clk == S38_4M)
367 else if (osc_clk == S26M)
369 else if (osc_clk == S19_2M)
371 else if (osc_clk == S13M)
373 else if (osc_clk == S12M)
377 /******************************************************************************
378 * prcm_init() - inits clocks for PRCM as defined in clocks.h
379 * -- called from SRAM, or Flash (using temp SRAM stack).
380 *****************************************************************************/
383 u32 osc_clk = 0, sys_clkin_sel;
384 dpll_param *dpll_param_p;
385 u32 clk_index, sil_index;
387 /* Gauge the input clock speed and find out the sys_clkin_sel
388 * value corresponding to the input clock.
390 osc_clk = get_osc_clk_speed();
391 get_sys_clkin_sel(osc_clk, &sys_clkin_sel);
393 sr32(PRM_CLKSEL, 0, 3, sys_clkin_sel); /* set input crystal speed */
395 /* If the input clock is greater than 19.2M always divide/2 */
396 if (sys_clkin_sel > 2) {
397 sr32(PRM_CLKSRC_CTRL, 6, 2, 2); /* input clock divider */
398 clk_index = sys_clkin_sel / 2;
400 sr32(PRM_CLKSRC_CTRL, 6, 2, 1); /* input clock divider */
401 clk_index = sys_clkin_sel;
404 sr32(PRM_CLKSRC_CTRL, 0, 2, 0);/* Bypass mode: T2 inputs a square clock */
406 /* The DPLL tables are defined according to sysclk value and
407 * silicon revision. The clk_index value will be used to get
408 * the values for that input sysclk from the DPLL param table
409 * and sil_index will get the values for that SysClk for the
410 * appropriate silicon rev.
412 sil_index = get_cpu_rev() - 1;
414 /* Unlock MPU DPLL (slows things down, and needed later) */
415 sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOW_POWER_BYPASS);
416 wait_on_value(BIT0, 0, CM_IDLEST_PLL_MPU, LDELAY);
418 /* Getting the base address of Core DPLL param table */
419 dpll_param_p = (dpll_param *) get_core_dpll_param();
420 /* Moving it to the right sysclk and ES rev base */
421 dpll_param_p = dpll_param_p + 2*clk_index + sil_index;
423 /* sr32(CM_CLKSEL2_EMU) set override to work when asleep */
424 sr32(CM_CLKEN_PLL, 0, 3, PLL_FAST_RELOCK_BYPASS);
425 wait_on_value(BIT0, 0, CM_IDLEST_CKGEN, LDELAY);
426 sr32(CM_CLKSEL1_EMU, 16, 5, CORE_M3X2); /* m3x2 */
427 sr32(CM_CLKSEL1_PLL, 27, 2, dpll_param_p->m2); /* Set M2 */
428 sr32(CM_CLKSEL1_PLL, 16, 11, dpll_param_p->m); /* Set M */
429 sr32(CM_CLKSEL1_PLL, 8, 7, dpll_param_p->n); /* Set N */
430 sr32(CM_CLKSEL1_PLL, 6, 1, 0); /* 96M Src */
431 sr32(CM_CLKSEL_CORE, 8, 4, CORE_SSI_DIV); /* ssi */
432 sr32(CM_CLKSEL_CORE, 4, 2, CORE_FUSB_DIV); /* fsusb */
433 sr32(CM_CLKSEL_CORE, 2, 2, CORE_L4_DIV); /* l4 */
434 sr32(CM_CLKSEL_CORE, 0, 2, CORE_L3_DIV); /* l3 */
435 sr32(CM_CLKSEL_GFX, 0, 3, GFX_DIV); /* gfx */
436 sr32(CM_CLKSEL_WKUP, 1, 2, WKUP_RSM); /* reset mgr */
437 sr32(CM_CLKEN_PLL, 4, 4, dpll_param_p->fsel); /* FREQSEL */
438 sr32(CM_CLKEN_PLL, 0, 3, PLL_LOCK); /* lock mode */
439 wait_on_value(BIT0, 1, CM_IDLEST_CKGEN, LDELAY);
441 /* Getting the base address to PER DPLL param table */
442 dpll_param_p = (dpll_param *) get_per_dpll_param();
443 /* Moving it to the right sysclk base */
444 dpll_param_p = dpll_param_p + clk_index;
446 sr32(CM_CLKEN_PLL, 16, 3, PLL_STOP);
447 wait_on_value(BIT1, 0, CM_IDLEST_CKGEN, LDELAY);
448 sr32(CM_CLKSEL1_EMU, 24, 5, PER_M6X2); /* set M6 */
449 sr32(CM_CLKSEL_CAM, 0, 5, PER_M5X2); /* set M5 */
450 sr32(CM_CLKSEL_DSS, 0, 5, PER_M4X2); /* set M4 */
451 sr32(CM_CLKSEL_DSS, 8, 5, PER_M3X2); /* set M3 */
452 sr32(CM_CLKSEL3_PLL, 0, 5, dpll_param_p->m2); /* set M2 */
453 sr32(CM_CLKSEL2_PLL, 8, 11, dpll_param_p->m); /* set m */
454 sr32(CM_CLKSEL2_PLL, 0, 7, dpll_param_p->n); /* set n */
455 sr32(CM_CLKEN_PLL, 20, 4, dpll_param_p->fsel); /* FREQSEL */
456 sr32(CM_CLKEN_PLL, 16, 3, PLL_LOCK); /* lock mode */
457 wait_on_value(BIT1, 2, CM_IDLEST_CKGEN, LDELAY);
459 /* Getting the base address to MPU DPLL param table */
460 dpll_param_p = (dpll_param *) get_mpu_dpll_param();
461 /* Moving it to the right sysclk and ES rev base */
462 dpll_param_p = dpll_param_p + 2*clk_index + sil_index;
463 /* MPU DPLL (unlocked already) */
464 sr32(CM_CLKSEL2_PLL_MPU, 0, 5, dpll_param_p->m2); /* Set M2 */
465 sr32(CM_CLKSEL1_PLL_MPU, 8, 11, dpll_param_p->m); /* Set M */
466 sr32(CM_CLKSEL1_PLL_MPU, 0, 7, dpll_param_p->n); /* Set N */
467 sr32(CM_CLKEN_PLL_MPU, 4, 4, dpll_param_p->fsel); /* FREQSEL */
468 sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOCK); /* lock mode */
469 wait_on_value(BIT0, 1, CM_IDLEST_PLL_MPU, LDELAY);
471 /* Getting the base address to IVA DPLL param table */
472 dpll_param_p = (dpll_param *) get_iva_dpll_param();
473 /* Moving it to the right sysclk and ES rev base */
474 dpll_param_p = dpll_param_p + 2*clk_index + sil_index;
475 /* IVA DPLL (set to 12*20=240MHz) */
476 sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_STOP);
477 wait_on_value(BIT0, 0, CM_IDLEST_PLL_IVA2, LDELAY);
478 sr32(CM_CLKSEL2_PLL_IVA2, 0, 5, dpll_param_p->m2); /* set M2 */
479 sr32(CM_CLKSEL1_PLL_IVA2, 8, 11, dpll_param_p->m); /* set M */
480 sr32(CM_CLKSEL1_PLL_IVA2, 0, 7, dpll_param_p->n); /* set N */
481 sr32(CM_CLKEN_PLL_IVA2, 4, 4, dpll_param_p->fsel); /* FREQSEL */
482 sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_LOCK); /* lock mode */
483 wait_on_value(BIT0, 1, CM_IDLEST_PLL_IVA2, LDELAY);
485 /* Set up GPTimers to sys_clk source only */
486 sr32(CM_CLKSEL_PER, 0, 8, 0xff);
487 sr32(CM_CLKSEL_WKUP, 0, 1, 1);
492 /*****************************************
493 * Routine: secure_unlock
494 * Description: Setup security registers for access
496 *****************************************/
497 void secure_unlock(void)
499 /* Permission values for registers -Full fledged permissions to all */
500 #define UNLOCK_1 0xFFFFFFFF
501 #define UNLOCK_2 0x00000000
502 #define UNLOCK_3 0x0000FFFF
503 /* Protection Module Register Target APE (PM_RT) */
504 __raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
505 __raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
506 __raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
507 __raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
509 __raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
510 __raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
511 __raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
513 __raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
514 __raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
515 __raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
516 __raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
519 __raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
520 __raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
521 __raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
523 __raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */
526 /**********************************************************
527 * Routine: try_unlock_sram()
528 * Description: If chip is GP type, unlock the SRAM for
530 ***********************************************************/
531 void try_unlock_memory(void)
535 /* if GP device unlock device SRAM for general use */
536 /* secure code breaks for Secure/Emulation device - HS/E/T */
537 mode = get_device_type();
538 if (mode == GP_DEVICE) {
544 /**********************************************************
546 * Description: Does early system init of muxing and clocks.
547 * - Called at time when only stack is available.
548 **********************************************************/
553 #ifdef CONFIG_3430_AS_3410
554 /* setup the scalability control register for
555 * 3430 to work in 3410 mode
557 __raw_writel(0x5ABF, CONTROL_SCALABLE_OMAP_OCP);
564 config_3430sdram_ddr();
567 /*******************************************************
568 * Routine: misc_init_r
570 ********************************************************/
571 int misc_init_r(void)
574 printf("OpenPandora System \n");
580 /******************************************************
581 * Routine: wait_for_command_complete
582 * Description: Wait for posting to finish on watchdog
583 ******************************************************/
584 void wait_for_command_complete(unsigned int wd_base)
588 pending = __raw_readl(wd_base + WWPS);
592 /****************************************
593 * Routine: watchdog_init
594 * Description: Shut down watch dogs
595 *****************************************/
596 void watchdog_init(void)
598 /* There are 3 watch dogs WD1=Secure, WD2=MPU, WD3=IVA. WD1 is
599 * either taken care of by ROM (HS/EMU) or not accessible (GP).
600 * We need to take care of WD2-MPU or take a PRCM reset. WD3
601 * should not be running and does not generate a PRCM reset.
603 sr32(CM_FCLKEN_WKUP, 5, 1, 1);
604 sr32(CM_ICLKEN_WKUP, 5, 1, 1);
605 wait_on_value(BIT5, 0x20, CM_IDLEST_WKUP, 5); /* some issue here */
607 __raw_writel(WD_UNLOCK1, WD2_BASE + WSPR);
608 wait_for_command_complete(WD2_BASE);
609 __raw_writel(WD_UNLOCK2, WD2_BASE + WSPR);
612 /**********************************************
614 * Description: sets uboots idea of sdram size
615 **********************************************/
621 /*****************************************************************
622 * Routine: peripheral_enable
623 * Description: Enable the clks & power for perifs (GPT2, UART1,...)
624 ******************************************************************/
625 void per_clocks_enable(void)
627 /* Enable GP2 timer. */
628 sr32(CM_CLKSEL_PER, 0, 1, 0x1); /* GPT2 = sys clk */
629 sr32(CM_ICLKEN_PER, 3, 1, 0x1); /* ICKen GPT2 */
630 sr32(CM_FCLKEN_PER, 3, 1, 0x1); /* FCKen GPT2 */
633 /* Enable UART1 clocks */
634 sr32(CM_FCLKEN1_CORE, 13, 1, 0x1);
635 sr32(CM_ICLKEN1_CORE, 13, 1, 0x1);
638 sr32(CM_FCLKEN_PER, 11, 1, 0x1);
639 sr32(CM_ICLKEN_PER, 11, 1, 0x1);
643 #ifdef CONFIG_DRIVER_OMAP34XX_I2C
644 /* Turn on all 3 I2C clocks */
645 sr32(CM_FCLKEN1_CORE, 15, 3, 0x7);
646 sr32(CM_ICLKEN1_CORE, 15, 3, 0x7); /* I2C1,2,3 = on */
649 /* Enable the ICLK for 32K Sync Timer as its used in udelay */
650 sr32(CM_ICLKEN_WKUP, 2, 1, 0x1);
652 sr32(CM_FCLKEN_IVA2, 0, 32, FCK_IVA2_ON);
653 sr32(CM_FCLKEN1_CORE, 0, 32, FCK_CORE1_ON);
654 sr32(CM_ICLKEN1_CORE, 0, 32, ICK_CORE1_ON);
655 sr32(CM_ICLKEN2_CORE, 0, 32, ICK_CORE2_ON);
656 sr32(CM_FCLKEN_WKUP, 0, 32, FCK_WKUP_ON);
657 sr32(CM_ICLKEN_WKUP, 0, 32, ICK_WKUP_ON);
658 sr32(CM_FCLKEN_DSS, 0, 32, FCK_DSS_ON);
659 sr32(CM_ICLKEN_DSS, 0, 32, ICK_DSS_ON);
660 sr32(CM_FCLKEN_CAM, 0, 32, FCK_CAM_ON);
661 sr32(CM_ICLKEN_CAM, 0, 32, ICK_CAM_ON);
662 sr32(CM_FCLKEN_PER, 0, 32, FCK_PER_ON);
663 sr32(CM_ICLKEN_PER, 0, 32, ICK_PER_ON);
665 /* Enable GPIO5 clocks for blinky LEDs */
666 sr32(CM_FCLKEN_PER, 16, 1, 0x1); /* FCKen GPIO5 */
667 sr32(CM_ICLKEN_PER, 16, 1, 0x1); /* ICKen GPIO5 */
672 /* Set MUX for UART, GPMC, SDRC, GPIO */
674 #define MUX_VAL(OFFSET,VALUE)\
675 __raw_writew((VALUE), OMAP34XX_CTRL_BASE + (OFFSET));
677 #define CP(x) (CONTROL_PADCONF_##x)
680 * IDIS - Input Disable
681 * PTD - Pull type Down
683 * DIS - Pull type selection is inactive
684 * EN - Pull type selection is active
686 * The commented string gives the final mux configuration for that pin
688 #define MUX_DEFAULT()\
690 MUX_VAL(CP(SDRC_D0), (IEN | PTD | DIS | M0)) /*SDRC_D0*/\
691 MUX_VAL(CP(SDRC_D1), (IEN | PTD | DIS | M0)) /*SDRC_D1*/\
692 MUX_VAL(CP(SDRC_D2), (IEN | PTD | DIS | M0)) /*SDRC_D2*/\
693 MUX_VAL(CP(SDRC_D3), (IEN | PTD | DIS | M0)) /*SDRC_D3*/\
694 MUX_VAL(CP(SDRC_D4), (IEN | PTD | DIS | M0)) /*SDRC_D4*/\
695 MUX_VAL(CP(SDRC_D5), (IEN | PTD | DIS | M0)) /*SDRC_D5*/\
696 MUX_VAL(CP(SDRC_D6), (IEN | PTD | DIS | M0)) /*SDRC_D6*/\
697 MUX_VAL(CP(SDRC_D7), (IEN | PTD | DIS | M0)) /*SDRC_D7*/\
698 MUX_VAL(CP(SDRC_D8), (IEN | PTD | DIS | M0)) /*SDRC_D8*/\
699 MUX_VAL(CP(SDRC_D9), (IEN | PTD | DIS | M0)) /*SDRC_D9*/\
700 MUX_VAL(CP(SDRC_D10), (IEN | PTD | DIS | M0)) /*SDRC_D10*/\
701 MUX_VAL(CP(SDRC_D11), (IEN | PTD | DIS | M0)) /*SDRC_D11*/\
702 MUX_VAL(CP(SDRC_D12), (IEN | PTD | DIS | M0)) /*SDRC_D12*/\
703 MUX_VAL(CP(SDRC_D13), (IEN | PTD | DIS | M0)) /*SDRC_D13*/\
704 MUX_VAL(CP(SDRC_D14), (IEN | PTD | DIS | M0)) /*SDRC_D14*/\
705 MUX_VAL(CP(SDRC_D15), (IEN | PTD | DIS | M0)) /*SDRC_D15*/\
706 MUX_VAL(CP(SDRC_D16), (IEN | PTD | DIS | M0)) /*SDRC_D16*/\
707 MUX_VAL(CP(SDRC_D17), (IEN | PTD | DIS | M0)) /*SDRC_D17*/\
708 MUX_VAL(CP(SDRC_D18), (IEN | PTD | DIS | M0)) /*SDRC_D18*/\
709 MUX_VAL(CP(SDRC_D19), (IEN | PTD | DIS | M0)) /*SDRC_D19*/\
710 MUX_VAL(CP(SDRC_D20), (IEN | PTD | DIS | M0)) /*SDRC_D20*/\
711 MUX_VAL(CP(SDRC_D21), (IEN | PTD | DIS | M0)) /*SDRC_D21*/\
712 MUX_VAL(CP(SDRC_D22), (IEN | PTD | DIS | M0)) /*SDRC_D22*/\
713 MUX_VAL(CP(SDRC_D23), (IEN | PTD | DIS | M0)) /*SDRC_D23*/\
714 MUX_VAL(CP(SDRC_D24), (IEN | PTD | DIS | M0)) /*SDRC_D24*/\
715 MUX_VAL(CP(SDRC_D25), (IEN | PTD | DIS | M0)) /*SDRC_D25*/\
716 MUX_VAL(CP(SDRC_D26), (IEN | PTD | DIS | M0)) /*SDRC_D26*/\
717 MUX_VAL(CP(SDRC_D27), (IEN | PTD | DIS | M0)) /*SDRC_D27*/\
718 MUX_VAL(CP(SDRC_D28), (IEN | PTD | DIS | M0)) /*SDRC_D28*/\
719 MUX_VAL(CP(SDRC_D29), (IEN | PTD | DIS | M0)) /*SDRC_D29*/\
720 MUX_VAL(CP(SDRC_D30), (IEN | PTD | DIS | M0)) /*SDRC_D30*/\
721 MUX_VAL(CP(SDRC_D31), (IEN | PTD | DIS | M0)) /*SDRC_D31*/\
722 MUX_VAL(CP(SDRC_CLK), (IEN | PTD | DIS | M0)) /*SDRC_CLK*/\
723 MUX_VAL(CP(SDRC_DQS0), (IEN | PTD | DIS | M0)) /*SDRC_DQS0*/\
724 MUX_VAL(CP(SDRC_DQS1), (IEN | PTD | DIS | M0)) /*SDRC_DQS1*/\
725 MUX_VAL(CP(SDRC_DQS2), (IEN | PTD | DIS | M0)) /*SDRC_DQS2*/\
726 MUX_VAL(CP(SDRC_DQS3), (IEN | PTD | DIS | M0)) /*SDRC_DQS3*/\
728 MUX_VAL(CP(GPMC_A1), (IDIS | PTD | DIS | M0)) /*GPMC_A1*/\
729 MUX_VAL(CP(GPMC_A2), (IDIS | PTD | DIS | M0)) /*GPMC_A2*/\
730 MUX_VAL(CP(GPMC_A3), (IDIS | PTD | DIS | M0)) /*GPMC_A3*/\
731 MUX_VAL(CP(GPMC_A4), (IDIS | PTD | DIS | M0)) /*GPMC_A4*/\
732 MUX_VAL(CP(GPMC_A5), (IDIS | PTD | DIS | M0)) /*GPMC_A5*/\
733 MUX_VAL(CP(GPMC_A6), (IDIS | PTD | DIS | M0)) /*GPMC_A6*/\
734 MUX_VAL(CP(GPMC_A7), (IDIS | PTD | DIS | M0)) /*GPMC_A7*/\
735 MUX_VAL(CP(GPMC_A8), (IDIS | PTD | DIS | M0)) /*GPMC_A8*/\
736 MUX_VAL(CP(GPMC_A9), (IDIS | PTD | DIS | M0)) /*GPMC_A9*/\
737 MUX_VAL(CP(GPMC_A10), (IDIS | PTD | DIS | M0)) /*GPMC_A10*/\
738 MUX_VAL(CP(GPMC_D0), (IEN | PTD | DIS | M0)) /*GPMC_D0*/\
739 MUX_VAL(CP(GPMC_D1), (IEN | PTD | DIS | M0)) /*GPMC_D1*/\
740 MUX_VAL(CP(GPMC_D2), (IEN | PTD | DIS | M0)) /*GPMC_D2*/\
741 MUX_VAL(CP(GPMC_D3), (IEN | PTD | DIS | M0)) /*GPMC_D3*/\
742 MUX_VAL(CP(GPMC_D4), (IEN | PTD | DIS | M0)) /*GPMC_D4*/\
743 MUX_VAL(CP(GPMC_D5), (IEN | PTD | DIS | M0)) /*GPMC_D5*/\
744 MUX_VAL(CP(GPMC_D6), (IEN | PTD | DIS | M0)) /*GPMC_D6*/\
745 MUX_VAL(CP(GPMC_D7), (IEN | PTD | DIS | M0)) /*GPMC_D7*/\
746 MUX_VAL(CP(GPMC_D8), (IEN | PTD | DIS | M0)) /*GPMC_D8*/\
747 MUX_VAL(CP(GPMC_D9), (IEN | PTD | DIS | M0)) /*GPMC_D9*/\
748 MUX_VAL(CP(GPMC_D10), (IEN | PTD | DIS | M0)) /*GPMC_D10*/\
749 MUX_VAL(CP(GPMC_D11), (IEN | PTD | DIS | M0)) /*GPMC_D11*/\
750 MUX_VAL(CP(GPMC_D12), (IEN | PTD | DIS | M0)) /*GPMC_D12*/\
751 MUX_VAL(CP(GPMC_D13), (IEN | PTD | DIS | M0)) /*GPMC_D13*/\
752 MUX_VAL(CP(GPMC_D14), (IEN | PTD | DIS | M0)) /*GPMC_D14*/\
753 MUX_VAL(CP(GPMC_D15), (IEN | PTD | DIS | M0)) /*GPMC_D15*/\
754 MUX_VAL(CP(GPMC_nCS0), (IDIS | PTU | EN | M0)) /*GPMC_nCS0*/\
755 MUX_VAL(CP(GPMC_nCS1), (IDIS | PTU | EN | M0)) /*GPMC_nCS1*/\
756 MUX_VAL(CP(GPMC_CLK), (IDIS | PTD | DIS | M0)) /*GPMC_CLK*/\
757 MUX_VAL(CP(GPMC_nADV_ALE), (IDIS | PTD | DIS | M0)) /*GPMC_nADV_ALE*/\
758 MUX_VAL(CP(GPMC_nOE), (IDIS | PTD | DIS | M0)) /*GPMC_nOE*/\
759 MUX_VAL(CP(GPMC_nWE), (IDIS | PTD | DIS | M0)) /*GPMC_nWE*/\
760 MUX_VAL(CP(GPMC_nBE0_CLE), (IDIS | PTD | DIS | M0)) /*GPMC_nBE0_CLE*/\
761 MUX_VAL(CP(GPMC_nWP), (IEN | PTD | DIS | M0)) /*GPMC_nWP*/\
762 MUX_VAL(CP(GPMC_WAIT0), (IEN | PTU | EN | M0)) /*GPMC_WAIT0*/\
763 MUX_VAL(CP(GPMC_WAIT1), (IEN | PTU | EN | M0)) /*GPMC_WAIT1*/\
764 /*Serial Interface (Peripheral boot, Linux console)*/\
765 MUX_VAL(CP(UART3_RX_IRRX ), (IEN | PTD | DIS | M0)) /*UART3_RX*/\
766 MUX_VAL(CP(UART3_TX_IRTX ), (IDIS | PTD | DIS | M0)) /*UART3_TX*/\
768 MUX_VAL(CP(I2C1_SCL), (IEN | PTU | EN | M0)) /*I2C1_SCL*/\
769 MUX_VAL(CP(I2C1_SDA), (IEN | PTU | EN | M0)) /*I2C1_SDA*/\
770 /*LEDs (Controlled by OMAP)*/\
771 MUX_VAL(CP(MMC1_DAT6), (IDIS | PTD | DIS | M4)) /*GPIO_128*/\
772 MUX_VAL(CP(MMC1_DAT7), (IDIS | PTD | DIS | M4)) /*GPIO_129*/\
774 /**********************************************************
775 * Routine: set_muxconf_regs
776 * Description: Setting up the configuration Mux registers
777 * specific to the hardware. Many pins need
778 * to be moved from protect to primary mode.
779 *********************************************************/
780 void set_muxconf_regs(void)
785 /**********************************************************
786 * Routine: nand+_init
787 * Description: Set up nand for nand and jffs2 commands
788 *********************************************************/
791 /* global settings */
792 __raw_writel(0x10, GPMC_SYSCONFIG); /* smart idle */
793 __raw_writel(0x0, GPMC_IRQENABLE); /* isr's sources masked */
794 __raw_writel(0, GPMC_TIMEOUT_CONTROL); /* timeout disable */
796 __raw_writel(0x001, GPMC_CONFIG); /* set nWP, disable limited addr */
799 /* Set the GPMC Vals, NAND is mapped at CS0
800 * We configure only GPMC CS0 with required values. Configuring other devices
801 * at other CS is done in u-boot. So we don't have to bother doing it here.
803 __raw_writel(0, GPMC_CONFIG7 + GPMC_CONFIG_CS0);
806 if ((get_mem_type() == GPMC_NAND) || (get_mem_type() == MMC_NAND)) {
807 __raw_writel(M_NAND_GPMC_CONFIG1, GPMC_CONFIG1 + GPMC_CONFIG_CS0);
808 __raw_writel(M_NAND_GPMC_CONFIG2, GPMC_CONFIG2 + GPMC_CONFIG_CS0);
809 __raw_writel(M_NAND_GPMC_CONFIG3, GPMC_CONFIG3 + GPMC_CONFIG_CS0);
810 __raw_writel(M_NAND_GPMC_CONFIG4, GPMC_CONFIG4 + GPMC_CONFIG_CS0);
811 __raw_writel(M_NAND_GPMC_CONFIG5, GPMC_CONFIG5 + GPMC_CONFIG_CS0);
812 __raw_writel(M_NAND_GPMC_CONFIG6, GPMC_CONFIG6 + GPMC_CONFIG_CS0);
814 /* Enable the GPMC Mapping */
815 __raw_writel((((OMAP34XX_GPMC_CS0_SIZE & 0xF)<<8) |
816 ((NAND_BASE_ADR>>24) & 0x3F) |
817 (1<<6)), (GPMC_CONFIG7 + GPMC_CONFIG_CS0));
822 printf("Unsupported Chip!\n");
829 if ((get_mem_type() == GPMC_ONENAND) || (get_mem_type() == MMC_ONENAND)) {
830 __raw_writel(ONENAND_GPMC_CONFIG1, GPMC_CONFIG1 + GPMC_CONFIG_CS0);
831 __raw_writel(ONENAND_GPMC_CONFIG2, GPMC_CONFIG2 + GPMC_CONFIG_CS0);
832 __raw_writel(ONENAND_GPMC_CONFIG3, GPMC_CONFIG3 + GPMC_CONFIG_CS0);
833 __raw_writel(ONENAND_GPMC_CONFIG4, GPMC_CONFIG4 + GPMC_CONFIG_CS0);
834 __raw_writel(ONENAND_GPMC_CONFIG5, GPMC_CONFIG5 + GPMC_CONFIG_CS0);
835 __raw_writel(ONENAND_GPMC_CONFIG6, GPMC_CONFIG6 + GPMC_CONFIG_CS0);
837 /* Enable the GPMC Mapping */
838 __raw_writel((((OMAP34XX_GPMC_CS0_SIZE & 0xF)<<8) |
839 ((ONENAND_BASE>>24) & 0x3F) |
840 (1<<6)), (GPMC_CONFIG7 + GPMC_CONFIG_CS0));
843 if (onenand_chip()) {
845 printf("OneNAND Unsupported !\n");
853 #define DEBUG_SD1_LED 128 /* gpio - SD Slot 1 */
854 #define DEBUG_SD2_LED 129 /* gpio - SD Slot 2 */
860 /* Alternately turn the LEDs on and off */
861 p = (unsigned long *)OMAP34XX_GPIO5_BASE;
863 /* turn LED1 on and LED2 off */
864 *(unsigned long *)(p + 0x94) = 1 << (DEBUG_SD1_LED % 32);
865 *(unsigned long *)(p + 0x90) = 1 << (DEBUG_SD2_LED % 32);
867 /* delay for a while */
870 /* turn LED1 off and LED2 on */
871 *(unsigned long *)(p + 0x90) = 1 << (DEBUG_SD1_LED % 32);
872 *(unsigned long *)(p + 0x94) = 1 << (DEBUG_SD2_LED % 32);
874 /* delay for a while */
879 /* optionally do something like blinking LED */
880 void board_hang(void)
886 /******************************************************************************
887 * Dummy function to handle errors for EABI incompatibility
888 *****************************************************************************/
893 /******************************************************************************
894 * Dummy function to handle errors for EABI incompatibility
895 *****************************************************************************/