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 /*VAUX3 = 2.8V (AV connector)*/
91 i2c_write(0x4B, 0x7A, 1, &byte, 1);
93 i2c_write(0x4B, 0x7D, 1, &byte, 1);
95 /*VAUX4 = 2.8V (TOUCH,NUBS,RS-232 TRANSCEIVER)*/
97 i2c_write(0x4B, 0x7E, 1, &byte, 1);
99 i2c_write(0x4B, 0x81, 1, &byte, 1);
102 delay(10000); /* give time to power up */
108 /*************************************************************
109 * get_device_type(): tell if GP/HS/EMU/TST
110 *************************************************************/
111 u32 get_device_type(void)
114 mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
118 /************************************************
119 * get_sysboot_value(void) - return SYS_BOOT[4:0]
120 ************************************************/
121 u32 get_sysboot_value(void)
124 mode = __raw_readl(CONTROL_STATUS) & (SYSBOOT_MASK);
128 /*************************************************************
129 * Routine: get_mem_type(void) - returns the kind of memory connected
130 * to GPMC that we are trying to boot form. Uses SYS BOOT settings.
131 *************************************************************/
132 u32 get_mem_type(void)
134 u32 mem_type = get_sysboot_value();
176 /******************************************
177 * get_cpu_rev(void) - extract version info
178 ******************************************/
179 u32 get_cpu_rev(void)
182 /* On ES1.0 the IDCODE register is not exposed on L4
183 * so using CPU ID to differentiate
184 * between ES2.0 and ES1.0.
186 __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
187 if ((cpuid & 0xf) == 0x0)
194 /******************************************
195 * cpu_is_3410(void) - returns true for 3410
196 ******************************************/
197 u32 cpu_is_3410(void)
200 if (get_cpu_rev() < CPU_3430_ES2) {
203 /* read scalability status and return 1 for 3410*/
204 status = __raw_readl(CONTROL_SCALABLE_OMAP_STATUS);
205 /* Check whether MPU frequency is set to 266 MHz which
206 * is nominal for 3410. If yes return true else false
208 if (((status >> 8) & 0x3) == 0x2)
215 /*****************************************************************
216 * sr32 - clear & set a value in a bit range for a 32 bit address
217 *****************************************************************/
218 void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
223 tmp = __raw_readl(addr) & ~(msk << start_bit);
224 tmp |= value << start_bit;
225 __raw_writel(tmp, addr);
228 /*********************************************************************
229 * wait_on_value() - common routine to allow waiting for changes in
231 *********************************************************************/
232 u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
237 val = __raw_readl(read_addr) & read_bit_mask;
238 if (val == match_value)
245 #ifdef CFG_3430SDRAM_DDR
246 /*********************************************************************
247 * config_3430sdram_ddr() - Init DDR on 3430SDP dev board.
248 *********************************************************************/
249 void config_3430sdram_ddr(void)
251 /* reset sdrc controller */
252 __raw_writel(SOFTRESET, SDRC_SYSCONFIG);
253 wait_on_value(BIT0, BIT0, SDRC_STATUS, 12000000);
254 __raw_writel(0, SDRC_SYSCONFIG);
256 /* setup sdrc to ball mux */
257 __raw_writel(SDP_SDRC_SHARING, SDRC_SHARING);
259 /* SDRC put in weak */
260 // (*(unsigned int*)0x6D00008C) = 0x00000020;
262 /* SDRC_MCFG0 register */
263 (*(unsigned int*)0x6D000080) = 0x02584099;//from Micron
265 /* SDRC_ACTIM_CTRLA0 register */
266 //our value (*(unsigned int*)0x6D00009c) = 0xa29db4c6;// for 166M
267 (*(unsigned int*)0x6D00009c) = 0xaa9db4c6;// for 166M from rkw
269 /* SDRC_ACTIM_CTRLB0 register */
270 //from micron (*(unsigned int*)0x6D0000a0) = 0x12214;// for 166M
272 // (*(unsigned int*)0x6D0000a0) = 0x00011417; our value
273 (*(unsigned int*)0x6D0000a0) = 0x00011517;
275 /* SDRC_RFR_CTRL0 register */
276 //from micron (*(unsigned int*)0x6D0000a4) =0x54601; // for 166M
278 (*(unsigned int*)0x6D0000a4) =0x0004DC01;
280 /* Disble Power Down of CKE cuz of 1 CKE on combo part */
281 (*(unsigned int*)0x6D000070) = 0x00000081;
283 /* SDRC_Manual command register */
284 (*(unsigned int*)0x6D0000a8) = 0x00000000; // NOP command
286 (*(unsigned int*)0x6D0000a8) = 0x00000001; // Precharge command
287 (*(unsigned int*)0x6D0000a8) = 0x00000002; // Auto-refresh command
288 (*(unsigned int*)0x6D0000a8) = 0x00000002; // Auto-refresh command
290 /* SDRC MR0 register */
291 (*(int*)0x6D000084) = 0x00000032; // Burst length =4
293 // Write Burst = Read Burst
296 /* SDRC DLLA control register */
297 (*(unsigned int*)0x6D000060) = 0x0000A;
298 delay(0x20000); // some delay
301 #endif /* CFG_3430SDRAM_DDR */
303 /*************************************************************
304 * get_sys_clk_speed - determine reference oscillator speed
305 * based on known 32kHz clock and gptimer.
306 *************************************************************/
307 u32 get_osc_clk_speed(void)
309 u32 start, cstart, cend, cdiff, val;
311 val = __raw_readl(PRM_CLKSRC_CTRL);
312 /* If SYS_CLK is being divided by 2, remove for now */
313 val = (val & (~BIT7)) | BIT6;
314 __raw_writel(val, PRM_CLKSRC_CTRL);
317 val = __raw_readl(CM_CLKSEL_WKUP) | BIT0;
318 __raw_writel(val, CM_CLKSEL_WKUP); /* select sys_clk for GPT1 */
320 /* Enable I and F Clocks for GPT1 */
321 val = __raw_readl(CM_ICLKEN_WKUP) | BIT0 | BIT2;
322 __raw_writel(val, CM_ICLKEN_WKUP);
323 val = __raw_readl(CM_FCLKEN_WKUP) | BIT0;
324 __raw_writel(val, CM_FCLKEN_WKUP);
326 __raw_writel(0, OMAP34XX_GPT1 + TLDR); /* start counting at 0 */
327 __raw_writel(GPT_EN, OMAP34XX_GPT1 + TCLR); /* enable clock */
328 /* enable 32kHz source */
329 /* enabled out of reset */
330 /* determine sys_clk via gauging */
332 start = 20 + __raw_readl(S32K_CR); /* start time in 20 cycles */
333 while (__raw_readl(S32K_CR) < start) ; /* dead loop till start time */
334 cstart = __raw_readl(OMAP34XX_GPT1 + TCRR); /* get start sys_clk count */
335 while (__raw_readl(S32K_CR) < (start + 20)) ; /* wait for 40 cycles */
336 cend = __raw_readl(OMAP34XX_GPT1 + TCRR); /* get end sys_clk count */
337 cdiff = cend - cstart; /* get elapsed ticks */
339 /* based on number of ticks assign speed */
342 else if (cdiff > 15200)
344 else if (cdiff > 13000)
346 else if (cdiff > 9000)
348 else if (cdiff > 7600)
354 /******************************************************************************
355 * get_sys_clkin_sel() - returns the sys_clkin_sel field value based on
356 * -- input oscillator clock frequency.
358 *****************************************************************************/
359 void get_sys_clkin_sel(u32 osc_clk, u32 * sys_clkin_sel)
361 if (osc_clk == S38_4M)
363 else if (osc_clk == S26M)
365 else if (osc_clk == S19_2M)
367 else if (osc_clk == S13M)
369 else if (osc_clk == S12M)
373 /******************************************************************************
374 * prcm_init() - inits clocks for PRCM as defined in clocks.h
375 * -- called from SRAM, or Flash (using temp SRAM stack).
376 *****************************************************************************/
379 u32 osc_clk = 0, sys_clkin_sel;
380 dpll_param *dpll_param_p;
381 u32 clk_index, sil_index;
383 /* Gauge the input clock speed and find out the sys_clkin_sel
384 * value corresponding to the input clock.
386 osc_clk = get_osc_clk_speed();
387 get_sys_clkin_sel(osc_clk, &sys_clkin_sel);
389 sr32(PRM_CLKSEL, 0, 3, sys_clkin_sel); /* set input crystal speed */
391 /* If the input clock is greater than 19.2M always divide/2 */
392 if (sys_clkin_sel > 2) {
393 sr32(PRM_CLKSRC_CTRL, 6, 2, 2); /* input clock divider */
394 clk_index = sys_clkin_sel / 2;
396 sr32(PRM_CLKSRC_CTRL, 6, 2, 1); /* input clock divider */
397 clk_index = sys_clkin_sel;
400 sr32(PRM_CLKSRC_CTRL, 0, 2, 0);/* Bypass mode: T2 inputs a square clock */
402 /* The DPLL tables are defined according to sysclk value and
403 * silicon revision. The clk_index value will be used to get
404 * the values for that input sysclk from the DPLL param table
405 * and sil_index will get the values for that SysClk for the
406 * appropriate silicon rev.
408 sil_index = get_cpu_rev() - 1;
410 /* Unlock MPU DPLL (slows things down, and needed later) */
411 sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOW_POWER_BYPASS);
412 wait_on_value(BIT0, 0, CM_IDLEST_PLL_MPU, LDELAY);
414 /* Getting the base address of Core DPLL param table */
415 dpll_param_p = (dpll_param *) get_core_dpll_param();
416 /* Moving it to the right sysclk and ES rev base */
417 dpll_param_p = dpll_param_p + 2*clk_index + sil_index;
419 /* sr32(CM_CLKSEL2_EMU) set override to work when asleep */
420 sr32(CM_CLKEN_PLL, 0, 3, PLL_FAST_RELOCK_BYPASS);
421 wait_on_value(BIT0, 0, CM_IDLEST_CKGEN, LDELAY);
422 sr32(CM_CLKSEL1_EMU, 16, 5, CORE_M3X2); /* m3x2 */
423 sr32(CM_CLKSEL1_PLL, 27, 2, dpll_param_p->m2); /* Set M2 */
424 sr32(CM_CLKSEL1_PLL, 16, 11, dpll_param_p->m); /* Set M */
425 sr32(CM_CLKSEL1_PLL, 8, 7, dpll_param_p->n); /* Set N */
426 sr32(CM_CLKSEL1_PLL, 6, 1, 0); /* 96M Src */
427 sr32(CM_CLKSEL_CORE, 8, 4, CORE_SSI_DIV); /* ssi */
428 sr32(CM_CLKSEL_CORE, 4, 2, CORE_FUSB_DIV); /* fsusb */
429 sr32(CM_CLKSEL_CORE, 2, 2, CORE_L4_DIV); /* l4 */
430 sr32(CM_CLKSEL_CORE, 0, 2, CORE_L3_DIV); /* l3 */
431 sr32(CM_CLKSEL_GFX, 0, 3, GFX_DIV); /* gfx */
432 sr32(CM_CLKSEL_WKUP, 1, 2, WKUP_RSM); /* reset mgr */
433 sr32(CM_CLKEN_PLL, 4, 4, dpll_param_p->fsel); /* FREQSEL */
434 sr32(CM_CLKEN_PLL, 0, 3, PLL_LOCK); /* lock mode */
435 wait_on_value(BIT0, 1, CM_IDLEST_CKGEN, LDELAY);
437 /* Getting the base address to PER DPLL param table */
438 dpll_param_p = (dpll_param *) get_per_dpll_param();
439 /* Moving it to the right sysclk base */
440 dpll_param_p = dpll_param_p + clk_index;
442 sr32(CM_CLKEN_PLL, 16, 3, PLL_STOP);
443 wait_on_value(BIT1, 0, CM_IDLEST_CKGEN, LDELAY);
444 sr32(CM_CLKSEL1_EMU, 24, 5, PER_M6X2); /* set M6 */
445 sr32(CM_CLKSEL_CAM, 0, 5, PER_M5X2); /* set M5 */
446 sr32(CM_CLKSEL_DSS, 0, 5, PER_M4X2); /* set M4 */
447 sr32(CM_CLKSEL_DSS, 8, 5, PER_M3X2); /* set M3 */
448 sr32(CM_CLKSEL3_PLL, 0, 5, dpll_param_p->m2); /* set M2 */
449 sr32(CM_CLKSEL2_PLL, 8, 11, dpll_param_p->m); /* set m */
450 sr32(CM_CLKSEL2_PLL, 0, 7, dpll_param_p->n); /* set n */
451 sr32(CM_CLKEN_PLL, 20, 4, dpll_param_p->fsel); /* FREQSEL */
452 sr32(CM_CLKEN_PLL, 16, 3, PLL_LOCK); /* lock mode */
453 wait_on_value(BIT1, 2, CM_IDLEST_CKGEN, LDELAY);
455 /* Getting the base address to MPU DPLL param table */
456 dpll_param_p = (dpll_param *) get_mpu_dpll_param();
457 /* Moving it to the right sysclk and ES rev base */
458 dpll_param_p = dpll_param_p + 2*clk_index + sil_index;
459 /* MPU DPLL (unlocked already) */
460 sr32(CM_CLKSEL2_PLL_MPU, 0, 5, dpll_param_p->m2); /* Set M2 */
461 sr32(CM_CLKSEL1_PLL_MPU, 8, 11, dpll_param_p->m); /* Set M */
462 sr32(CM_CLKSEL1_PLL_MPU, 0, 7, dpll_param_p->n); /* Set N */
463 sr32(CM_CLKEN_PLL_MPU, 4, 4, dpll_param_p->fsel); /* FREQSEL */
464 sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOCK); /* lock mode */
465 wait_on_value(BIT0, 1, CM_IDLEST_PLL_MPU, LDELAY);
467 /* Getting the base address to IVA DPLL param table */
468 dpll_param_p = (dpll_param *) get_iva_dpll_param();
469 /* Moving it to the right sysclk and ES rev base */
470 dpll_param_p = dpll_param_p + 2*clk_index + sil_index;
471 /* IVA DPLL (set to 12*20=240MHz) */
472 sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_STOP);
473 wait_on_value(BIT0, 0, CM_IDLEST_PLL_IVA2, LDELAY);
474 sr32(CM_CLKSEL2_PLL_IVA2, 0, 5, dpll_param_p->m2); /* set M2 */
475 sr32(CM_CLKSEL1_PLL_IVA2, 8, 11, dpll_param_p->m); /* set M */
476 sr32(CM_CLKSEL1_PLL_IVA2, 0, 7, dpll_param_p->n); /* set N */
477 sr32(CM_CLKEN_PLL_IVA2, 4, 4, dpll_param_p->fsel); /* FREQSEL */
478 sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_LOCK); /* lock mode */
479 wait_on_value(BIT0, 1, CM_IDLEST_PLL_IVA2, LDELAY);
481 /* Set up GPTimers to sys_clk source only */
482 sr32(CM_CLKSEL_PER, 0, 8, 0xff);
483 sr32(CM_CLKSEL_WKUP, 0, 1, 1);
488 /*****************************************
489 * Routine: secure_unlock
490 * Description: Setup security registers for access
492 *****************************************/
493 void secure_unlock(void)
495 /* Permission values for registers -Full fledged permissions to all */
496 #define UNLOCK_1 0xFFFFFFFF
497 #define UNLOCK_2 0x00000000
498 #define UNLOCK_3 0x0000FFFF
499 /* Protection Module Register Target APE (PM_RT) */
500 __raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
501 __raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
502 __raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
503 __raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
505 __raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
506 __raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
507 __raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
509 __raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
510 __raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
511 __raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
512 __raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
515 __raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
516 __raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
517 __raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
519 __raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */
522 /**********************************************************
523 * Routine: try_unlock_sram()
524 * Description: If chip is GP type, unlock the SRAM for
526 ***********************************************************/
527 void try_unlock_memory(void)
531 /* if GP device unlock device SRAM for general use */
532 /* secure code breaks for Secure/Emulation device - HS/E/T */
533 mode = get_device_type();
534 if (mode == GP_DEVICE) {
540 /**********************************************************
542 * Description: Does early system init of muxing and clocks.
543 * - Called at time when only stack is available.
544 **********************************************************/
549 #ifdef CONFIG_3430_AS_3410
550 /* setup the scalability control register for
551 * 3430 to work in 3410 mode
553 __raw_writel(0x5ABF, CONTROL_SCALABLE_OMAP_OCP);
560 config_3430sdram_ddr();
563 /*******************************************************
564 * Routine: misc_init_r
566 ********************************************************/
567 int misc_init_r(void)
570 printf("Pandora edition\n");
576 /******************************************************
577 * Routine: wait_for_command_complete
578 * Description: Wait for posting to finish on watchdog
579 ******************************************************/
580 void wait_for_command_complete(unsigned int wd_base)
584 pending = __raw_readl(wd_base + WWPS);
588 /****************************************
589 * Routine: watchdog_init
590 * Description: Shut down watch dogs
591 *****************************************/
592 void watchdog_init(void)
594 /* There are 3 watch dogs WD1=Secure, WD2=MPU, WD3=IVA. WD1 is
595 * either taken care of by ROM (HS/EMU) or not accessible (GP).
596 * We need to take care of WD2-MPU or take a PRCM reset. WD3
597 * should not be running and does not generate a PRCM reset.
599 sr32(CM_FCLKEN_WKUP, 5, 1, 1);
600 sr32(CM_ICLKEN_WKUP, 5, 1, 1);
601 wait_on_value(BIT5, 0x20, CM_IDLEST_WKUP, 5); /* some issue here */
603 __raw_writel(WD_UNLOCK1, WD2_BASE + WSPR);
604 wait_for_command_complete(WD2_BASE);
605 __raw_writel(WD_UNLOCK2, WD2_BASE + WSPR);
608 /**********************************************
610 * Description: sets uboots idea of sdram size
611 **********************************************/
617 /*****************************************************************
618 * Routine: peripheral_enable
619 * Description: Enable the clks & power for perifs (GPT2, UART1,...)
620 ******************************************************************/
621 void per_clocks_enable(void)
623 /* Enable GP2 timer. */
624 sr32(CM_CLKSEL_PER, 0, 1, 0x1); /* GPT2 = sys clk */
625 sr32(CM_ICLKEN_PER, 3, 1, 0x1); /* ICKen GPT2 */
626 sr32(CM_FCLKEN_PER, 3, 1, 0x1); /* FCKen GPT2 */
629 /* Enable UART1 clocks */
630 sr32(CM_FCLKEN1_CORE, 13, 1, 0x1);
631 sr32(CM_ICLKEN1_CORE, 13, 1, 0x1);
634 sr32(CM_FCLKEN_PER, 11, 1, 0x1);
635 sr32(CM_ICLKEN_PER, 11, 1, 0x1);
639 #ifdef CONFIG_DRIVER_OMAP34XX_I2C
640 /* Turn on all 3 I2C clocks */
641 sr32(CM_FCLKEN1_CORE, 15, 3, 0x7);
642 sr32(CM_ICLKEN1_CORE, 15, 3, 0x7); /* I2C1,2,3 = on */
645 /* Enable the ICLK for 32K Sync Timer as its used in udelay */
646 sr32(CM_ICLKEN_WKUP, 2, 1, 0x1);
648 sr32(CM_FCLKEN_IVA2, 0, 32, FCK_IVA2_ON);
649 sr32(CM_FCLKEN1_CORE, 0, 32, FCK_CORE1_ON);
650 sr32(CM_ICLKEN1_CORE, 0, 32, ICK_CORE1_ON);
651 sr32(CM_ICLKEN2_CORE, 0, 32, ICK_CORE2_ON);
652 sr32(CM_FCLKEN_WKUP, 0, 32, FCK_WKUP_ON);
653 sr32(CM_ICLKEN_WKUP, 0, 32, ICK_WKUP_ON);
654 sr32(CM_FCLKEN_DSS, 0, 32, FCK_DSS_ON);
655 sr32(CM_ICLKEN_DSS, 0, 32, ICK_DSS_ON);
656 sr32(CM_FCLKEN_CAM, 0, 32, FCK_CAM_ON);
657 sr32(CM_ICLKEN_CAM, 0, 32, ICK_CAM_ON);
658 sr32(CM_FCLKEN_PER, 0, 32, FCK_PER_ON);
659 sr32(CM_ICLKEN_PER, 0, 32, ICK_PER_ON);
661 /* Enable GPIO5 clocks for blinky LEDs */
662 sr32(CM_FCLKEN_PER, 16, 1, 0x1); /* FCKen GPIO5 */
663 sr32(CM_ICLKEN_PER, 16, 1, 0x1); /* ICKen GPIO5 */
668 /* Set MUX for UART, GPMC, SDRC, GPIO */
670 #define MUX_VAL(OFFSET,VALUE)\
671 __raw_writew((VALUE), OMAP34XX_CTRL_BASE + (OFFSET));
673 #define CP(x) (CONTROL_PADCONF_##x)
676 * IDIS - Input Disable
677 * PTD - Pull type Down
679 * DIS - Pull type selection is inactive
680 * EN - Pull type selection is active
682 * The commented string gives the final mux configuration for that pin
684 #define MUX_DEFAULT()\
686 MUX_VAL(CP(SDRC_D0), (IEN | PTD | DIS | M0)) /*SDRC_D0*/\
687 MUX_VAL(CP(SDRC_D1), (IEN | PTD | DIS | M0)) /*SDRC_D1*/\
688 MUX_VAL(CP(SDRC_D2), (IEN | PTD | DIS | M0)) /*SDRC_D2*/\
689 MUX_VAL(CP(SDRC_D3), (IEN | PTD | DIS | M0)) /*SDRC_D3*/\
690 MUX_VAL(CP(SDRC_D4), (IEN | PTD | DIS | M0)) /*SDRC_D4*/\
691 MUX_VAL(CP(SDRC_D5), (IEN | PTD | DIS | M0)) /*SDRC_D5*/\
692 MUX_VAL(CP(SDRC_D6), (IEN | PTD | DIS | M0)) /*SDRC_D6*/\
693 MUX_VAL(CP(SDRC_D7), (IEN | PTD | DIS | M0)) /*SDRC_D7*/\
694 MUX_VAL(CP(SDRC_D8), (IEN | PTD | DIS | M0)) /*SDRC_D8*/\
695 MUX_VAL(CP(SDRC_D9), (IEN | PTD | DIS | M0)) /*SDRC_D9*/\
696 MUX_VAL(CP(SDRC_D10), (IEN | PTD | DIS | M0)) /*SDRC_D10*/\
697 MUX_VAL(CP(SDRC_D11), (IEN | PTD | DIS | M0)) /*SDRC_D11*/\
698 MUX_VAL(CP(SDRC_D12), (IEN | PTD | DIS | M0)) /*SDRC_D12*/\
699 MUX_VAL(CP(SDRC_D13), (IEN | PTD | DIS | M0)) /*SDRC_D13*/\
700 MUX_VAL(CP(SDRC_D14), (IEN | PTD | DIS | M0)) /*SDRC_D14*/\
701 MUX_VAL(CP(SDRC_D15), (IEN | PTD | DIS | M0)) /*SDRC_D15*/\
702 MUX_VAL(CP(SDRC_D16), (IEN | PTD | DIS | M0)) /*SDRC_D16*/\
703 MUX_VAL(CP(SDRC_D17), (IEN | PTD | DIS | M0)) /*SDRC_D17*/\
704 MUX_VAL(CP(SDRC_D18), (IEN | PTD | DIS | M0)) /*SDRC_D18*/\
705 MUX_VAL(CP(SDRC_D19), (IEN | PTD | DIS | M0)) /*SDRC_D19*/\
706 MUX_VAL(CP(SDRC_D20), (IEN | PTD | DIS | M0)) /*SDRC_D20*/\
707 MUX_VAL(CP(SDRC_D21), (IEN | PTD | DIS | M0)) /*SDRC_D21*/\
708 MUX_VAL(CP(SDRC_D22), (IEN | PTD | DIS | M0)) /*SDRC_D22*/\
709 MUX_VAL(CP(SDRC_D23), (IEN | PTD | DIS | M0)) /*SDRC_D23*/\
710 MUX_VAL(CP(SDRC_D24), (IEN | PTD | DIS | M0)) /*SDRC_D24*/\
711 MUX_VAL(CP(SDRC_D25), (IEN | PTD | DIS | M0)) /*SDRC_D25*/\
712 MUX_VAL(CP(SDRC_D26), (IEN | PTD | DIS | M0)) /*SDRC_D26*/\
713 MUX_VAL(CP(SDRC_D27), (IEN | PTD | DIS | M0)) /*SDRC_D27*/\
714 MUX_VAL(CP(SDRC_D28), (IEN | PTD | DIS | M0)) /*SDRC_D28*/\
715 MUX_VAL(CP(SDRC_D29), (IEN | PTD | DIS | M0)) /*SDRC_D29*/\
716 MUX_VAL(CP(SDRC_D30), (IEN | PTD | DIS | M0)) /*SDRC_D30*/\
717 MUX_VAL(CP(SDRC_D31), (IEN | PTD | DIS | M0)) /*SDRC_D31*/\
718 MUX_VAL(CP(SDRC_CLK), (IEN | PTD | DIS | M0)) /*SDRC_CLK*/\
719 MUX_VAL(CP(SDRC_DQS0), (IEN | PTD | DIS | M0)) /*SDRC_DQS0*/\
720 MUX_VAL(CP(SDRC_DQS1), (IEN | PTD | DIS | M0)) /*SDRC_DQS1*/\
721 MUX_VAL(CP(SDRC_DQS2), (IEN | PTD | DIS | M0)) /*SDRC_DQS2*/\
722 MUX_VAL(CP(SDRC_DQS3), (IEN | PTD | DIS | M0)) /*SDRC_DQS3*/\
724 MUX_VAL(CP(GPMC_A1), (IDIS | PTD | DIS | M0)) /*GPMC_A1*/\
725 MUX_VAL(CP(GPMC_A2), (IDIS | PTD | DIS | M0)) /*GPMC_A2*/\
726 MUX_VAL(CP(GPMC_A3), (IDIS | PTD | DIS | M0)) /*GPMC_A3*/\
727 MUX_VAL(CP(GPMC_A4), (IDIS | PTD | DIS | M0)) /*GPMC_A4*/\
728 MUX_VAL(CP(GPMC_A5), (IDIS | PTD | DIS | M0)) /*GPMC_A5*/\
729 MUX_VAL(CP(GPMC_A6), (IDIS | PTD | DIS | M0)) /*GPMC_A6*/\
730 MUX_VAL(CP(GPMC_A7), (IDIS | PTD | DIS | M0)) /*GPMC_A7*/\
731 MUX_VAL(CP(GPMC_A8), (IDIS | PTD | DIS | M0)) /*GPMC_A8*/\
732 MUX_VAL(CP(GPMC_A9), (IDIS | PTD | DIS | M0)) /*GPMC_A9*/\
733 MUX_VAL(CP(GPMC_A10), (IDIS | PTD | DIS | M0)) /*GPMC_A10*/\
734 MUX_VAL(CP(GPMC_D0), (IEN | PTD | DIS | M0)) /*GPMC_D0*/\
735 MUX_VAL(CP(GPMC_D1), (IEN | PTD | DIS | M0)) /*GPMC_D1*/\
736 MUX_VAL(CP(GPMC_D2), (IEN | PTD | DIS | M0)) /*GPMC_D2*/\
737 MUX_VAL(CP(GPMC_D3), (IEN | PTD | DIS | M0)) /*GPMC_D3*/\
738 MUX_VAL(CP(GPMC_D4), (IEN | PTD | DIS | M0)) /*GPMC_D4*/\
739 MUX_VAL(CP(GPMC_D5), (IEN | PTD | DIS | M0)) /*GPMC_D5*/\
740 MUX_VAL(CP(GPMC_D6), (IEN | PTD | DIS | M0)) /*GPMC_D6*/\
741 MUX_VAL(CP(GPMC_D7), (IEN | PTD | DIS | M0)) /*GPMC_D7*/\
742 MUX_VAL(CP(GPMC_D8), (IEN | PTD | DIS | M0)) /*GPMC_D8*/\
743 MUX_VAL(CP(GPMC_D9), (IEN | PTD | DIS | M0)) /*GPMC_D9*/\
744 MUX_VAL(CP(GPMC_D10), (IEN | PTD | DIS | M0)) /*GPMC_D10*/\
745 MUX_VAL(CP(GPMC_D11), (IEN | PTD | DIS | M0)) /*GPMC_D11*/\
746 MUX_VAL(CP(GPMC_D12), (IEN | PTD | DIS | M0)) /*GPMC_D12*/\
747 MUX_VAL(CP(GPMC_D13), (IEN | PTD | DIS | M0)) /*GPMC_D13*/\
748 MUX_VAL(CP(GPMC_D14), (IEN | PTD | DIS | M0)) /*GPMC_D14*/\
749 MUX_VAL(CP(GPMC_D15), (IEN | PTD | DIS | M0)) /*GPMC_D15*/\
750 MUX_VAL(CP(GPMC_nCS0), (IDIS | PTU | EN | M0)) /*GPMC_nCS0*/\
751 MUX_VAL(CP(GPMC_nCS1), (IDIS | PTU | EN | M0)) /*GPMC_nCS1*/\
752 MUX_VAL(CP(GPMC_CLK), (IDIS | PTD | DIS | M0)) /*GPMC_CLK*/\
753 MUX_VAL(CP(GPMC_nADV_ALE), (IDIS | PTD | DIS | M0)) /*GPMC_nADV_ALE*/\
754 MUX_VAL(CP(GPMC_nOE), (IDIS | PTD | DIS | M0)) /*GPMC_nOE*/\
755 MUX_VAL(CP(GPMC_nWE), (IDIS | PTD | DIS | M0)) /*GPMC_nWE*/\
756 MUX_VAL(CP(GPMC_nBE0_CLE), (IDIS | PTD | DIS | M0)) /*GPMC_nBE0_CLE*/\
757 MUX_VAL(CP(GPMC_nWP), (IEN | PTD | DIS | M0)) /*GPMC_nWP*/\
758 MUX_VAL(CP(GPMC_WAIT0), (IEN | PTU | EN | M0)) /*GPMC_WAIT0*/\
759 MUX_VAL(CP(GPMC_WAIT1), (IEN | PTU | EN | M0)) /*GPMC_WAIT1*/\
760 /*Serial Interface (Peripheral boot, Linux console)*/\
761 MUX_VAL(CP(UART3_RX_IRRX ), (IEN | PTD | DIS | M0)) /*UART3_RX*/\
762 MUX_VAL(CP(UART3_TX_IRTX ), (IDIS | PTD | DIS | M0)) /*UART3_TX*/\
764 MUX_VAL(CP(I2C1_SCL), (IEN | PTU | EN | M0)) /*I2C1_SCL*/\
765 MUX_VAL(CP(I2C1_SDA), (IEN | PTU | EN | M0)) /*I2C1_SDA*/\
766 /*LEDs (Controlled by OMAP)*/\
767 MUX_VAL(CP(MMC1_DAT6), (IDIS | PTD | DIS | M4)) /*GPIO_128*/\
768 MUX_VAL(CP(MMC1_DAT7), (IDIS | PTD | DIS | M4)) /*GPIO_129*/\
770 /**********************************************************
771 * Routine: set_muxconf_regs
772 * Description: Setting up the configuration Mux registers
773 * specific to the hardware. Many pins need
774 * to be moved from protect to primary mode.
775 *********************************************************/
776 void set_muxconf_regs(void)
781 /**********************************************************
782 * Routine: nand+_init
783 * Description: Set up nand for nand and jffs2 commands
784 *********************************************************/
787 /* global settings */
788 __raw_writel(0x10, GPMC_SYSCONFIG); /* smart idle */
789 __raw_writel(0x0, GPMC_IRQENABLE); /* isr's sources masked */
790 __raw_writel(0, GPMC_TIMEOUT_CONTROL); /* timeout disable */
792 __raw_writel(0x001, GPMC_CONFIG); /* set nWP, disable limited addr */
795 /* Set the GPMC Vals, NAND is mapped at CS0
796 * We configure only GPMC CS0 with required values. Configuring other devices
797 * at other CS is done in u-boot. So we don't have to bother doing it here.
799 __raw_writel(0, GPMC_CONFIG7 + GPMC_CONFIG_CS0);
802 if ((get_mem_type() == GPMC_NAND) || (get_mem_type() == MMC_NAND)) {
803 __raw_writel(M_NAND_GPMC_CONFIG1, GPMC_CONFIG1 + GPMC_CONFIG_CS0);
804 __raw_writel(M_NAND_GPMC_CONFIG2, GPMC_CONFIG2 + GPMC_CONFIG_CS0);
805 __raw_writel(M_NAND_GPMC_CONFIG3, GPMC_CONFIG3 + GPMC_CONFIG_CS0);
806 __raw_writel(M_NAND_GPMC_CONFIG4, GPMC_CONFIG4 + GPMC_CONFIG_CS0);
807 __raw_writel(M_NAND_GPMC_CONFIG5, GPMC_CONFIG5 + GPMC_CONFIG_CS0);
808 __raw_writel(M_NAND_GPMC_CONFIG6, GPMC_CONFIG6 + GPMC_CONFIG_CS0);
810 /* Enable the GPMC Mapping */
811 __raw_writel((((OMAP34XX_GPMC_CS0_SIZE & 0xF)<<8) |
812 ((NAND_BASE_ADR>>24) & 0x3F) |
813 (1<<6)), (GPMC_CONFIG7 + GPMC_CONFIG_CS0));
818 printf("Unsupported Chip!\n");
825 if ((get_mem_type() == GPMC_ONENAND) || (get_mem_type() == MMC_ONENAND)) {
826 __raw_writel(ONENAND_GPMC_CONFIG1, GPMC_CONFIG1 + GPMC_CONFIG_CS0);
827 __raw_writel(ONENAND_GPMC_CONFIG2, GPMC_CONFIG2 + GPMC_CONFIG_CS0);
828 __raw_writel(ONENAND_GPMC_CONFIG3, GPMC_CONFIG3 + GPMC_CONFIG_CS0);
829 __raw_writel(ONENAND_GPMC_CONFIG4, GPMC_CONFIG4 + GPMC_CONFIG_CS0);
830 __raw_writel(ONENAND_GPMC_CONFIG5, GPMC_CONFIG5 + GPMC_CONFIG_CS0);
831 __raw_writel(ONENAND_GPMC_CONFIG6, GPMC_CONFIG6 + GPMC_CONFIG_CS0);
833 /* Enable the GPMC Mapping */
834 __raw_writel((((OMAP34XX_GPMC_CS0_SIZE & 0xF)<<8) |
835 ((ONENAND_BASE>>24) & 0x3F) |
836 (1<<6)), (GPMC_CONFIG7 + GPMC_CONFIG_CS0));
839 if (onenand_chip()) {
841 printf("OneNAND Unsupported !\n");
849 #define DEBUG_SD1_LED 128 /* gpio - SD Slot 1 */
850 #define DEBUG_SD2_LED 129 /* gpio - SD Slot 2 */
856 /* Alternately turn the LEDs on and off */
857 p = (unsigned long *)OMAP34XX_GPIO5_BASE;
859 /* turn LED1 on and LED2 off */
860 *(unsigned long *)(p + 0x94) = 1 << (DEBUG_SD1_LED % 32);
861 *(unsigned long *)(p + 0x90) = 1 << (DEBUG_SD2_LED % 32);
863 /* delay for a while */
866 /* turn LED1 off and LED2 on */
867 *(unsigned long *)(p + 0x90) = 1 << (DEBUG_SD1_LED % 32);
868 *(unsigned long *)(p + 0x94) = 1 << (DEBUG_SD2_LED % 32);
870 /* delay for a while */
875 /* optionally do something like blinking LED */
876 void board_hang(void)
882 /******************************************************************************
883 * Dummy function to handle errors for EABI incompatibility
884 *****************************************************************************/
889 /******************************************************************************
890 * Dummy function to handle errors for EABI incompatibility
891 *****************************************************************************/