3 * ISEE 2007 SL <www.iseebcn.com>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <asm/arch/cpu.h>
29 #include <asm/arch/bits.h>
30 #include <asm/arch/mux.h>
31 #include <asm/arch/sys_proto.h>
32 #include <asm/arch/sys_info.h>
33 #include <asm/arch/clocks.h>
34 #include <asm/arch/mem.h>
35 #include <asm/arch/gpio.h>
38 #define CORE_DPLL_PARAM_M2 0x09
39 #define CORE_DPLL_PARAM_M 0x360
40 #define CORE_DPLL_PARAM_N 0xC
42 /* Used to index into DPLL parameter tables */
50 typedef struct dpll_param dpll_param;
52 /* Following functions are exported from lowlevel_init.S */
53 extern dpll_param *get_mpu_dpll_param(void);
54 extern dpll_param *get_iva_dpll_param(void);
55 extern dpll_param *get_core_dpll_param(void);
56 extern dpll_param *get_per_dpll_param(void);
58 #define __raw_readl(a) (*(volatile unsigned int *)(a))
59 #define __raw_writel(v, a) (*(volatile unsigned int *)(a) = (v))
60 #define __raw_readw(a) (*(volatile unsigned short *)(a))
61 #define __raw_writew(v, a) (*(volatile unsigned short *)(a) = (v))
63 static char *rev_s[CPU_3XX_MAX_REV] = {
73 /*******************************************************
75 * Description: spinning delay to use before udelay works
76 ******************************************************/
77 static inline void delay(unsigned long loops)
79 __asm__ volatile ("1:\n" "subs %0, %1, #1\n"
80 "bne 1b":"=r" (loops):"0"(loops));
83 void udelay (unsigned long usecs) {
87 /*************************************************************
88 * get_device_type(): tell if GP/HS/EMU/TST
89 *************************************************************/
90 u32 get_device_type(void)
93 mode = __raw_readl(CONTROL_STATUS) & (DEVICE_MASK);
97 /*************************************************************
98 * Routine: get_mem_type(void) - returns the kind of memory connected
99 * to GPMC that we are trying to boot form. Uses SYS BOOT settings.
100 *************************************************************/
101 u32 get_mem_type(void)
106 /******************************************
107 * get_cpu_type(void) - extract cpu info
108 ******************************************/
109 u32 get_cpu_type(void)
111 return __raw_readl(CONTROL_OMAP_STATUS);
114 /******************************************
115 * get_cpu_id(void) - extract cpu id
116 * returns 0 for ES1.0, cpuid otherwise
117 ******************************************/
123 * On ES1.0 the IDCODE register is not exposed on L4
124 * so using CPU ID to differentiate between ES1.0 and > ES1.0.
126 __asm__ __volatile__("mrc p15, 0, %0, c0, c0, 0":"=r"(cpuid));
127 if ((cpuid & 0xf) == 0x0) {
130 /* Decode the IDs on > ES1.0 */
131 cpuid = __raw_readl(CONTROL_IDCODE);
137 /*****************************************************************
138 * sr32 - clear & set a value in a bit range for a 32 bit address
139 *****************************************************************/
140 void sr32(u32 addr, u32 start_bit, u32 num_bits, u32 value)
145 tmp = __raw_readl(addr) & ~(msk << start_bit);
146 tmp |= value << start_bit;
147 __raw_writel(tmp, addr);
150 /*********************************************************************
151 * wait_on_value() - common routine to allow waiting for changes in
153 *********************************************************************/
154 u32 wait_on_value(u32 read_bit_mask, u32 match_value, u32 read_addr, u32 bound)
159 val = __raw_readl(read_addr) & read_bit_mask;
160 if (val == match_value)
167 /******************************************
168 * get_cpu_family(void) - extract cpu info
169 ******************************************/
170 u32 get_cpu_family(void)
174 u32 cpuid = get_cpu_id();
179 hawkeye = (cpuid >> HAWKEYE_SHIFT) & 0xffff;
181 case HAWKEYE_OMAP34XX:
182 cpu_family = CPU_OMAP34XX;
185 cpu_family = CPU_AM35XX;
187 case HAWKEYE_OMAP36XX:
188 cpu_family = CPU_OMAP36XX;
191 cpu_family = CPU_OMAP34XX;
197 /******************************************
198 * get_cpu_rev(void) - extract version info
199 ******************************************/
200 u32 get_cpu_rev(void)
202 u32 cpuid = get_cpu_id();
207 return (cpuid >> CPU_3XX_ID_SHIFT) & 0xf;
210 /******************************************
211 * Print CPU information
212 ******************************************/
213 int print_cpuinfo (void)
215 char *cpu_family_s, *cpu_s, *sec_s;
217 switch (get_cpu_family()) {
219 cpu_family_s = "OMAP";
220 switch (get_cpu_type()) {
240 switch (get_cpu_type()) {
253 cpu_family_s = "OMAP";
254 switch (get_cpu_type()) {
264 cpu_family_s = "OMAP";
268 switch (get_device_type()) {
285 printf("%s%s-%s ES%s\n",
286 cpu_family_s, cpu_s, sec_s, rev_s[get_cpu_rev()]);
291 /*************************************************************
292 * get_sys_clk_speed - determine reference oscillator speed
293 * based on known 32kHz clock and gptimer.
294 *************************************************************/
295 u32 get_osc_clk_speed(void)
297 u32 start, cstart, cend, cdiff, val;
299 val = __raw_readl(PRM_CLKSRC_CTRL);
300 /* If SYS_CLK is being divided by 2, remove for now */
301 val = (val & (~BIT7)) | BIT6;
302 __raw_writel(val, PRM_CLKSRC_CTRL);
305 val = __raw_readl(CM_CLKSEL_WKUP) | BIT0;
306 __raw_writel(val, CM_CLKSEL_WKUP); /* select sys_clk for GPT1 */
308 /* Enable I and F Clocks for GPT1 */
309 val = __raw_readl(CM_ICLKEN_WKUP) | BIT0 | BIT2;
310 __raw_writel(val, CM_ICLKEN_WKUP);
311 val = __raw_readl(CM_FCLKEN_WKUP) | BIT0;
312 __raw_writel(val, CM_FCLKEN_WKUP);
314 __raw_writel(0, OMAP34XX_GPT1 + TLDR); /* start counting at 0 */
315 __raw_writel(GPT_EN, OMAP34XX_GPT1 + TCLR); /* enable clock */
316 /* enable 32kHz source */
317 /* enabled out of reset */
318 /* determine sys_clk via gauging */
320 start = 20 + __raw_readl(S32K_CR); /* start time in 20 cycles */
321 while (__raw_readl(S32K_CR) < start) ; /* dead loop till start time */
322 cstart = __raw_readl(OMAP34XX_GPT1 + TCRR); /* get start sys_clk count */
323 while (__raw_readl(S32K_CR) < (start + 20)) ; /* wait for 40 cycles */
324 cend = __raw_readl(OMAP34XX_GPT1 + TCRR); /* get end sys_clk count */
325 cdiff = cend - cstart; /* get elapsed ticks */
327 /* based on number of ticks assign speed */
330 else if (cdiff > 15200)
332 else if (cdiff > 13000)
334 else if (cdiff > 9000)
336 else if (cdiff > 7600)
342 /******************************************************************************
343 * get_sys_clkin_sel() - returns the sys_clkin_sel field value based on
344 * -- input oscillator clock frequency.
346 *****************************************************************************/
347 void get_sys_clkin_sel(u32 osc_clk, u32 *sys_clkin_sel)
349 if (osc_clk == S38_4M)
351 else if (osc_clk == S26M)
353 else if (osc_clk == S19_2M)
355 else if (osc_clk == S13M)
357 else if (osc_clk == S12M)
361 /******************************************************************************
362 * prcm_init() - inits clocks for PRCM as defined in clocks.h
363 * -- called from SRAM, or Flash (using temp SRAM stack).
364 *****************************************************************************/
367 u32 osc_clk = 0, sys_clkin_sel;
368 dpll_param *dpll_param_p;
369 u32 clk_index, sil_index;
371 /* Gauge the input clock speed and find out the sys_clkin_sel
372 * value corresponding to the input clock.
374 osc_clk = get_osc_clk_speed();
375 get_sys_clkin_sel(osc_clk, &sys_clkin_sel);
377 sr32(PRM_CLKSEL, 0, 3, sys_clkin_sel); /* set input crystal speed */
379 /* If the input clock is greater than 19.2M always divide/2 */
380 if (sys_clkin_sel > 2) {
381 sr32(PRM_CLKSRC_CTRL, 6, 2, 2); /* input clock divider */
382 clk_index = sys_clkin_sel / 2;
384 sr32(PRM_CLKSRC_CTRL, 6, 2, 1); /* input clock divider */
385 clk_index = sys_clkin_sel;
388 sr32(PRM_CLKSRC_CTRL, 0, 2, 0);/* Bypass mode: T2 inputs a square clock */
390 /* The DPLL tables are defined according to sysclk value and
391 * silicon revision. The clk_index value will be used to get
392 * the values for that input sysclk from the DPLL param table
393 * and sil_index will get the values for that SysClk for the
394 * appropriate silicon rev.
396 sil_index = get_cpu_rev() - 1;
398 /* Unlock MPU DPLL (slows things down, and needed later) */
399 sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOW_POWER_BYPASS);
400 wait_on_value(BIT0, 0, CM_IDLEST_PLL_MPU, LDELAY);
402 /* Getting the base address of Core DPLL param table */
403 dpll_param_p = (dpll_param *) get_core_dpll_param();
404 /* Moving it to the right sysclk and ES rev base */
405 dpll_param_p = dpll_param_p + 3 * clk_index + sil_index;
407 /* sr32(CM_CLKSEL2_EMU) set override to work when asleep */
408 sr32(CM_CLKEN_PLL, 0, 3, PLL_FAST_RELOCK_BYPASS);
409 wait_on_value(BIT0, 0, CM_IDLEST_CKGEN, LDELAY);
411 /* For 3430 ES1.0 Errata 1.50, default value directly doesnt
412 work. write another value and then default value. */
413 sr32(CM_CLKSEL1_EMU, 16, 5, CORE_M3X2 + 1); /* m3x2 */
414 sr32(CM_CLKSEL1_EMU, 16, 5, CORE_M3X2); /* m3x2 */
415 sr32(CM_CLKSEL1_PLL, 27, 2, dpll_param_p->m2); /* Set M2 */
416 sr32(CM_CLKSEL1_PLL, 16, 11, dpll_param_p->m); /* Set M */
417 sr32(CM_CLKSEL1_PLL, 8, 7, dpll_param_p->n); /* Set N */
418 sr32(CM_CLKSEL1_PLL, 6, 1, 0); /* 96M Src */
419 sr32(CM_CLKSEL_CORE, 8, 4, CORE_SSI_DIV); /* ssi */
420 sr32(CM_CLKSEL_CORE, 4, 2, CORE_FUSB_DIV); /* fsusb */
421 sr32(CM_CLKSEL_CORE, 2, 2, CORE_L4_DIV); /* l4 */
422 sr32(CM_CLKSEL_CORE, 0, 2, CORE_L3_DIV); /* l3 */
423 sr32(CM_CLKSEL_GFX, 0, 3, GFX_DIV); /* gfx */
424 sr32(CM_CLKSEL_WKUP, 1, 2, WKUP_RSM); /* reset mgr */
425 sr32(CM_CLKEN_PLL, 4, 4, dpll_param_p->fsel); /* FREQSEL */
426 sr32(CM_CLKEN_PLL, 0, 3, PLL_LOCK); /* lock mode */
427 wait_on_value(BIT0, 1, CM_IDLEST_CKGEN, LDELAY);
429 /* Getting the base address to PER DPLL param table */
430 dpll_param_p = (dpll_param *) get_per_dpll_param();
431 /* Moving it to the right sysclk base */
432 dpll_param_p = dpll_param_p + clk_index;
434 sr32(CM_CLKEN_PLL, 16, 3, PLL_STOP);
435 wait_on_value(BIT1, 0, CM_IDLEST_CKGEN, LDELAY);
436 sr32(CM_CLKSEL1_EMU, 24, 5, PER_M6X2); /* set M6 */
437 sr32(CM_CLKSEL_CAM, 0, 5, PER_M5X2); /* set M5 */
438 sr32(CM_CLKSEL_DSS, 0, 5, PER_M4X2); /* set M4 */
439 sr32(CM_CLKSEL_DSS, 8, 5, PER_M3X2); /* set M3 */
441 if (get_cpu_family() == CPU_OMAP36XX) {
442 sr32(CM_CLKSEL3_PLL, 0, 5, CORE_DPLL_PARAM_M2); /* set M2 */
443 sr32(CM_CLKSEL2_PLL, 8, 11, CORE_DPLL_PARAM_M); /* set m */
444 sr32(CM_CLKSEL2_PLL, 0, 7, CORE_DPLL_PARAM_N); /* set n */
446 sr32(CM_CLKSEL3_PLL, 0, 5, dpll_param_p->m2); /* set M2 */
447 sr32(CM_CLKSEL2_PLL, 8, 11, dpll_param_p->m); /* set m */
448 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();
458 /* Moving it to the right sysclk and ES rev base */
459 dpll_param_p = dpll_param_p + 3 * clk_index + sil_index;
461 /* MPU DPLL (unlocked already) */
462 sr32(CM_CLKSEL2_PLL_MPU, 0, 5, dpll_param_p->m2); /* Set M2 */
463 sr32(CM_CLKSEL1_PLL_MPU, 8, 11, dpll_param_p->m); /* Set M */
464 sr32(CM_CLKSEL1_PLL_MPU, 0, 7, dpll_param_p->n); /* Set N */
465 sr32(CM_CLKEN_PLL_MPU, 4, 4, dpll_param_p->fsel); /* FREQSEL */
466 sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOCK); /* lock mode */
467 wait_on_value(BIT0, 1, CM_IDLEST_PLL_MPU, LDELAY);
469 /* Getting the base address to IVA DPLL param table */
470 dpll_param_p = (dpll_param *) get_iva_dpll_param();
471 /* Moving it to the right sysclk and ES rev base */
472 dpll_param_p = dpll_param_p + 3 * clk_index + sil_index;
473 /* IVA DPLL (set to 12*20=240MHz) */
474 sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_STOP);
475 wait_on_value(BIT0, 0, CM_IDLEST_PLL_IVA2, LDELAY);
476 sr32(CM_CLKSEL2_PLL_IVA2, 0, 5, dpll_param_p->m2); /* set M2 */
477 sr32(CM_CLKSEL1_PLL_IVA2, 8, 11, dpll_param_p->m); /* set M */
478 sr32(CM_CLKSEL1_PLL_IVA2, 0, 7, dpll_param_p->n); /* set N */
479 sr32(CM_CLKEN_PLL_IVA2, 4, 4, dpll_param_p->fsel); /* FREQSEL */
480 sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_LOCK); /* lock mode */
481 wait_on_value(BIT0, 1, CM_IDLEST_PLL_IVA2, LDELAY);
483 /* Set up GPTimers to sys_clk source only */
484 sr32(CM_CLKSEL_PER, 0, 8, 0xff);
485 sr32(CM_CLKSEL_WKUP, 0, 1, 1);
490 /*****************************************
491 * Routine: secure_unlock
492 * Description: Setup security registers for access
494 *****************************************/
495 void secure_unlock(void)
497 /* Permission values for registers -Full fledged permissions to all */
498 #define UNLOCK_1 0xFFFFFFFF
499 #define UNLOCK_2 0x00000000
500 #define UNLOCK_3 0x0000FFFF
501 /* Protection Module Register Target APE (PM_RT) */
502 __raw_writel(UNLOCK_1, RT_REQ_INFO_PERMISSION_1);
503 __raw_writel(UNLOCK_1, RT_READ_PERMISSION_0);
504 __raw_writel(UNLOCK_1, RT_WRITE_PERMISSION_0);
505 __raw_writel(UNLOCK_2, RT_ADDR_MATCH_1);
507 __raw_writel(UNLOCK_3, GPMC_REQ_INFO_PERMISSION_0);
508 __raw_writel(UNLOCK_3, GPMC_READ_PERMISSION_0);
509 __raw_writel(UNLOCK_3, GPMC_WRITE_PERMISSION_0);
511 __raw_writel(UNLOCK_3, OCM_REQ_INFO_PERMISSION_0);
512 __raw_writel(UNLOCK_3, OCM_READ_PERMISSION_0);
513 __raw_writel(UNLOCK_3, OCM_WRITE_PERMISSION_0);
514 __raw_writel(UNLOCK_2, OCM_ADDR_MATCH_2);
517 __raw_writel(UNLOCK_3, IVA2_REQ_INFO_PERMISSION_0);
518 __raw_writel(UNLOCK_3, IVA2_READ_PERMISSION_0);
519 __raw_writel(UNLOCK_3, IVA2_WRITE_PERMISSION_0);
521 __raw_writel(UNLOCK_1, SMS_RG_ATT0); /* SDRC region 0 public */
524 /**********************************************************
525 * Routine: try_unlock_sram()
526 * Description: If chip is GP type, unlock the SRAM for
528 ***********************************************************/
529 void try_unlock_memory(void)
533 /* if GP device unlock device SRAM for general use */
534 /* secure code breaks for Secure/Emulation device - HS/E/T */
535 mode = get_device_type();
536 if (mode == GP_DEVICE)
541 /*********************************************************************
542 * config_sdram_m65kx002am() - 2 dice of 2Gb, DDR x32 I/O, 4KB page
543 *********************************************************************/
544 void config_sdram_m65kx002am(void)
546 /* M65KX002AM - 2 dice of 2Gb */
547 /* reset sdrc controller */
548 __raw_writel(SOFTRESET, SDRC_SYSCONFIG);
549 wait_on_value(BIT0, BIT0, SDRC_STATUS, 12000000);
550 __raw_writel(0, SDRC_SYSCONFIG);
552 /* setup sdrc to ball mux */
553 __raw_writel(SDP_SDRC_SHARING, SDRC_SHARING);
554 __raw_writel(0x2, SDRC_CS_CFG); /* 256 MB/bank */
556 /* CS0 SDRC Mode Register */
557 __raw_writel(MK65KX002AM_SDRC_MCDCFG, SDRC_MCFG_0);
559 /* CS1 SDRC Mode Register */
560 __raw_writel(MK65KX002AM_SDRC_MCDCFG, SDRC_MCFG_1);
563 __raw_writel(NUMONYX_SDRC_ACTIM_CTRLA_0, SDRC_ACTIM_CTRLA_0);
564 __raw_writel(NUMONYX_SDRC_ACTIM_CTRLB_0, SDRC_ACTIM_CTRLB_0);
565 __raw_writel(NUMONYX_SDRC_ACTIM_CTRLA_0, SDRC_ACTIM_CTRLA_1);
566 __raw_writel(NUMONYX_SDRC_ACTIM_CTRLB_0, SDRC_ACTIM_CTRLB_1);
568 __raw_writel(SDP_SDRC_RFR_CTRL, SDRC_RFR_CTRL_0);
569 __raw_writel(SDP_SDRC_RFR_CTRL, SDRC_RFR_CTRL_1);
571 __raw_writel(SDP_SDRC_POWER_POP, SDRC_POWER);
573 /* init sequence for mDDR/mSDR using manual commands (DDR is different) */
574 __raw_writel(CMD_NOP, SDRC_MANUAL_0);
575 __raw_writel(CMD_NOP, SDRC_MANUAL_1);
579 __raw_writel(CMD_PRECHARGE, SDRC_MANUAL_0);
580 __raw_writel(CMD_PRECHARGE, SDRC_MANUAL_1);
582 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0);
583 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_1);
585 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0);
586 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_1);
589 __raw_writel(SDP_SDRC_MR_0_DDR, SDRC_MR_0);
590 __raw_writel(SDP_SDRC_MR_0_DDR, SDRC_MR_1);
593 __raw_writel(SDP_SDRC_DLLAB_CTRL, SDRC_DLLA_CTRL);
594 delay(0x2000); /* give time to lock */
597 /*********************************************************************
598 * config_onenand_nand0xgr4wxa() - 4-Gbit DDP or 2-Gbit OneNAND Flash
599 *********************************************************************/
600 void config_onenand_nand0xgr4wxa(void)
602 /* global settings */
603 __raw_writel(0x10, GPMC_SYSCONFIG); /* smart idle */
604 __raw_writel(0x0, GPMC_IRQENABLE); /* isr's sources masked */
605 __raw_writel(0, GPMC_TIMEOUT_CONTROL);/* timeout disable */
607 /* Set the GPMC Vals, NAND is mapped at CS0, oneNAND at CS0.
608 * We configure only GPMC CS0 with required values. Configuring other devices
609 * at other CS is done in u-boot. So we don't have to bother doing it here.
611 __raw_writel(0 , GPMC_CONFIG7 + GPMC_CONFIG_CS0);
614 __raw_writel(ONENAND_GPMC_CONFIG1, GPMC_CONFIG1 + GPMC_CONFIG_CS0);
615 __raw_writel(ONENAND_GPMC_CONFIG2, GPMC_CONFIG2 + GPMC_CONFIG_CS0);
616 __raw_writel(ONENAND_GPMC_CONFIG3, GPMC_CONFIG3 + GPMC_CONFIG_CS0);
617 __raw_writel(ONENAND_GPMC_CONFIG4, GPMC_CONFIG4 + GPMC_CONFIG_CS0);
618 __raw_writel(ONENAND_GPMC_CONFIG5, GPMC_CONFIG5 + GPMC_CONFIG_CS0);
619 __raw_writel(ONENAND_GPMC_CONFIG6, GPMC_CONFIG6 + GPMC_CONFIG_CS0);
621 /* Enable the GPMC Mapping */
622 __raw_writel((((OMAP34XX_GPMC_CS0_SIZE & 0xF)<<8) |
623 ((ONENAND_BASE>>24) & 0x3F) |
624 (1<<6)), (GPMC_CONFIG7 + GPMC_CONFIG_CS0));
628 /**********************************************************
630 * Description: Does early system init of muxing and clocks.
631 * - Called at time when only stack is available.
632 **********************************************************/
642 config_sdram_m65kx002am();
645 /*****************************************
646 * Routine: board_init
647 * Description: Early hardware init.
648 *****************************************/
654 /*******************************************************
655 * Routine: misc_init_r
656 * Description: Init ethernet (done here so udelay works)
657 ********************************************************/
658 int misc_init_r(void)
660 omap_request_gpio(27);
661 omap_set_gpio_direction(27, 0);
662 omap_set_gpio_dataout(27, 1);
667 /******************************************************
668 * Routine: wait_for_command_complete
669 * Description: Wait for posting to finish on watchdog
670 ******************************************************/
671 void wait_for_command_complete(unsigned int wd_base)
675 pending = __raw_readl(wd_base + WWPS);
679 /****************************************
680 * Routine: watchdog_init
681 * Description: Shut down watch dogs
682 *****************************************/
683 void watchdog_init(void)
685 /* There are 3 watch dogs WD1=Secure, WD2=MPU, WD3=IVA. WD1 is
686 * either taken care of by ROM (HS/EMU) or not accessible (GP).
687 * We need to take care of WD2-MPU or take a PRCM reset. WD3
688 * should not be running and does not generate a PRCM reset.
690 sr32(CM_FCLKEN_WKUP, 5, 1, 1);
691 sr32(CM_ICLKEN_WKUP, 5, 1, 1);
692 wait_on_value(BIT5, 0x20, CM_IDLEST_WKUP, 5); /* some issue here */
694 #ifdef CONFIG_WATCHDOG
695 /* Enable WD2 watchdog */
696 __raw_writel(WD_UNLOCK3, WD2_BASE + WSPR);
697 wait_for_command_complete(WD2_BASE);
698 __raw_writel(WD_UNLOCK4, WD2_BASE + WSPR);
700 /* Disable WD2 watchdog */
701 __raw_writel(WD_UNLOCK1, WD2_BASE + WSPR);
702 wait_for_command_complete(WD2_BASE);
703 __raw_writel(WD_UNLOCK2, WD2_BASE + WSPR);
707 /**********************************************
709 * Description: sets uboots idea of sdram size
710 **********************************************/
716 /*****************************************************************
717 * Routine: peripheral_enable
718 * Description: Enable the clks & power for perifs (GPT2, UART1,...)
719 ******************************************************************/
720 void per_clocks_enable(void)
722 /* Enable GP2 timer. */
723 sr32(CM_CLKSEL_PER, 0, 1, 0x1); /* GPT2 = sys clk */
724 sr32(CM_ICLKEN_PER, 3, 1, 0x1); /* ICKen GPT2 */
725 sr32(CM_FCLKEN_PER, 3, 1, 0x1); /* FCKen GPT2 */
729 sr32(CM_FCLKEN1_CORE, 13, 1, 0x1);
730 sr32(CM_ICLKEN1_CORE, 13, 1, 0x1);
733 sr32(CM_FCLKEN_PER, 11, 1, 0x1);
734 sr32(CM_ICLKEN_PER, 11, 1, 0x1);
738 #ifdef CONFIG_DRIVER_OMAP34XX_I2C
739 /* Turn on all 3 I2C clocks */
740 sr32(CM_FCLKEN1_CORE, 15, 3, 0x7);
741 sr32(CM_ICLKEN1_CORE, 15, 3, 0x7); /* I2C1,2,3 = on */
744 /* Enable the ICLK for 32K Sync Timer as its used in udelay */
745 sr32(CM_ICLKEN_WKUP, 2, 1, 0x1);
747 sr32(CM_FCLKEN_IVA2, 0, 32, FCK_IVA2_ON);
748 sr32(CM_FCLKEN1_CORE, 0, 32, FCK_CORE1_ON);
749 sr32(CM_ICLKEN1_CORE, 0, 32, ICK_CORE1_ON);
750 sr32(CM_ICLKEN2_CORE, 0, 32, ICK_CORE2_ON);
751 sr32(CM_FCLKEN_WKUP, 0, 32, FCK_WKUP_ON);
752 sr32(CM_ICLKEN_WKUP, 0, 32, ICK_WKUP_ON);
753 sr32(CM_FCLKEN_DSS, 0, 32, FCK_DSS_ON);
754 sr32(CM_ICLKEN_DSS, 0, 32, ICK_DSS_ON);
755 sr32(CM_FCLKEN_CAM, 0, 32, FCK_CAM_ON);
756 sr32(CM_ICLKEN_CAM, 0, 32, ICK_CAM_ON);
757 sr32(CM_FCLKEN_PER, 0, 32, FCK_PER_ON);
758 sr32(CM_ICLKEN_PER, 0, 32, ICK_PER_ON);
763 /* Set MUX for UART, GPMC, SDRC, GPIO */
765 #define MUX_VAL(OFFSET,VALUE)\
766 __raw_writew((VALUE), OMAP34XX_CTRL_BASE + (OFFSET));
768 #define CP(x) (CONTROL_PADCONF_##x)
771 * IDIS - Input Disable
772 * PTD - Pull type Down
774 * DIS - Pull type selection is inactive
775 * EN - Pull type selection is active
777 * The commented string gives the final mux configuration for that pin
779 #define MUX_DEFAULT()\
780 MUX_VAL(CP(SDRC_D0), (IEN | PTD | DIS | M0)) /*SDRC_D0*/\
781 MUX_VAL(CP(SDRC_D1), (IEN | PTD | DIS | M0)) /*SDRC_D1*/\
782 MUX_VAL(CP(SDRC_D2), (IEN | PTD | DIS | M0)) /*SDRC_D2*/\
783 MUX_VAL(CP(SDRC_D3), (IEN | PTD | DIS | M0)) /*SDRC_D3*/\
784 MUX_VAL(CP(SDRC_D4), (IEN | PTD | DIS | M0)) /*SDRC_D4*/\
785 MUX_VAL(CP(SDRC_D5), (IEN | PTD | DIS | M0)) /*SDRC_D5*/\
786 MUX_VAL(CP(SDRC_D6), (IEN | PTD | DIS | M0)) /*SDRC_D6*/\
787 MUX_VAL(CP(SDRC_D7), (IEN | PTD | DIS | M0)) /*SDRC_D7*/\
788 MUX_VAL(CP(SDRC_D8), (IEN | PTD | DIS | M0)) /*SDRC_D8*/\
789 MUX_VAL(CP(SDRC_D9), (IEN | PTD | DIS | M0)) /*SDRC_D9*/\
790 MUX_VAL(CP(SDRC_D10), (IEN | PTD | DIS | M0)) /*SDRC_D10*/\
791 MUX_VAL(CP(SDRC_D11), (IEN | PTD | DIS | M0)) /*SDRC_D11*/\
792 MUX_VAL(CP(SDRC_D12), (IEN | PTD | DIS | M0)) /*SDRC_D12*/\
793 MUX_VAL(CP(SDRC_D13), (IEN | PTD | DIS | M0)) /*SDRC_D13*/\
794 MUX_VAL(CP(SDRC_D14), (IEN | PTD | DIS | M0)) /*SDRC_D14*/\
795 MUX_VAL(CP(SDRC_D15), (IEN | PTD | DIS | M0)) /*SDRC_D15*/\
796 MUX_VAL(CP(SDRC_D16), (IEN | PTD | DIS | M0)) /*SDRC_D16*/\
797 MUX_VAL(CP(SDRC_D17), (IEN | PTD | DIS | M0)) /*SDRC_D17*/\
798 MUX_VAL(CP(SDRC_D18), (IEN | PTD | DIS | M0)) /*SDRC_D18*/\
799 MUX_VAL(CP(SDRC_D19), (IEN | PTD | DIS | M0)) /*SDRC_D19*/\
800 MUX_VAL(CP(SDRC_D20), (IEN | PTD | DIS | M0)) /*SDRC_D20*/\
801 MUX_VAL(CP(SDRC_D21), (IEN | PTD | DIS | M0)) /*SDRC_D21*/\
802 MUX_VAL(CP(SDRC_D22), (IEN | PTD | DIS | M0)) /*SDRC_D22*/\
803 MUX_VAL(CP(SDRC_D23), (IEN | PTD | DIS | M0)) /*SDRC_D23*/\
804 MUX_VAL(CP(SDRC_D24), (IEN | PTD | DIS | M0)) /*SDRC_D24*/\
805 MUX_VAL(CP(SDRC_D25), (IEN | PTD | DIS | M0)) /*SDRC_D25*/\
806 MUX_VAL(CP(SDRC_D26), (IEN | PTD | DIS | M0)) /*SDRC_D26*/\
807 MUX_VAL(CP(SDRC_D27), (IEN | PTD | DIS | M0)) /*SDRC_D27*/\
808 MUX_VAL(CP(SDRC_D28), (IEN | PTD | DIS | M0)) /*SDRC_D28*/\
809 MUX_VAL(CP(SDRC_D29), (IEN | PTD | DIS | M0)) /*SDRC_D29*/\
810 MUX_VAL(CP(SDRC_D30), (IEN | PTD | DIS | M0)) /*SDRC_D30*/\
811 MUX_VAL(CP(SDRC_D31), (IEN | PTD | DIS | M0)) /*SDRC_D31*/\
812 MUX_VAL(CP(SDRC_CLK), (IEN | PTD | DIS | M0)) /*SDRC_CLK*/\
813 MUX_VAL(CP(SDRC_DQS0), (IEN | PTD | DIS | M0)) /*SDRC_DQS0*/\
814 MUX_VAL(CP(SDRC_DQS1), (IEN | PTD | DIS | M0)) /*SDRC_DQS1*/\
815 MUX_VAL(CP(SDRC_DQS2), (IEN | PTD | DIS | M0)) /*SDRC_DQS2*/\
816 MUX_VAL(CP(SDRC_DQS3), (IEN | PTD | DIS | M0)) /*SDRC_DQS3*/\
817 MUX_VAL(CP(GPMC_A1), (IDIS | PTD | DIS | M0)) /*GPMC_A1*/\
818 MUX_VAL(CP(GPMC_A2), (IDIS | PTD | DIS | M0)) /*GPMC_A2*/\
819 MUX_VAL(CP(GPMC_A3), (IDIS | PTD | DIS | M0)) /*GPMC_A3*/\
820 MUX_VAL(CP(GPMC_A4), (IDIS | PTD | DIS | M0)) /*GPMC_A4*/\
821 MUX_VAL(CP(GPMC_A5), (IDIS | PTD | DIS | M0)) /*GPMC_A5*/\
822 MUX_VAL(CP(GPMC_A6), (IDIS | PTD | DIS | M0)) /*GPMC_A6*/\
823 MUX_VAL(CP(GPMC_A7), (IDIS | PTD | DIS | M0)) /*GPMC_A7*/\
824 MUX_VAL(CP(GPMC_A8), (IDIS | PTD | DIS | M0)) /*GPMC_A8*/\
825 MUX_VAL(CP(GPMC_A9), (IDIS | PTD | DIS | M0)) /*GPMC_A9*/\
826 MUX_VAL(CP(GPMC_A10), (IDIS | PTD | DIS | M0)) /*GPMC_A10*/\
827 MUX_VAL(CP(GPMC_D0), (IEN | PTD | DIS | M0)) /*GPMC_D0*/\
828 MUX_VAL(CP(GPMC_D1), (IEN | PTD | DIS | M0)) /*GPMC_D1*/\
829 MUX_VAL(CP(GPMC_D2), (IEN | PTD | DIS | M0)) /*GPMC_D2*/\
830 MUX_VAL(CP(GPMC_D3), (IEN | PTD | DIS | M0)) /*GPMC_D3*/\
831 MUX_VAL(CP(GPMC_D4), (IEN | PTD | DIS | M0)) /*GPMC_D4*/\
832 MUX_VAL(CP(GPMC_D5), (IEN | PTD | DIS | M0)) /*GPMC_D5*/\
833 MUX_VAL(CP(GPMC_D6), (IEN | PTD | DIS | M0)) /*GPMC_D6*/\
834 MUX_VAL(CP(GPMC_D7), (IEN | PTD | DIS | M0)) /*GPMC_D7*/\
835 MUX_VAL(CP(GPMC_D8), (IEN | PTD | DIS | M0)) /*GPMC_D8*/\
836 MUX_VAL(CP(GPMC_D9), (IEN | PTD | DIS | M0)) /*GPMC_D9*/\
837 MUX_VAL(CP(GPMC_D10), (IEN | PTD | DIS | M0)) /*GPMC_D10*/\
838 MUX_VAL(CP(GPMC_D11), (IEN | PTD | DIS | M0)) /*GPMC_D11*/\
839 MUX_VAL(CP(GPMC_D12), (IEN | PTD | DIS | M0)) /*GPMC_D12*/\
840 MUX_VAL(CP(GPMC_D13), (IEN | PTD | DIS | M0)) /*GPMC_D13*/\
841 MUX_VAL(CP(GPMC_D14), (IEN | PTD | DIS | M0)) /*GPMC_D14*/\
842 MUX_VAL(CP(GPMC_D15), (IEN | PTD | DIS | M0)) /*GPMC_D15*/\
843 MUX_VAL(CP(GPMC_nCS0), (IDIS | PTU | EN | M0)) /*GPMC_nCS0*/\
844 MUX_VAL(CP(GPMC_nCS1), (IDIS | PTU | EN | M0)) /*GPMC_nCS1*/\
845 MUX_VAL(CP(GPMC_nCS2), (IDIS | PTU | EN | M0)) /*GPMC_nCS2*/\
846 MUX_VAL(CP(GPMC_nCS3), (IDIS | PTU | EN | M0)) /*GPMC_nCS3*/\
847 MUX_VAL(CP(GPMC_nCS4), (IDIS | PTU | EN | M0)) /*GPMC_nCS4*/\
848 MUX_VAL(CP(GPMC_nCS5), (IDIS | PTU | EN | M0)) /*GPMC_nCS5*/\
849 MUX_VAL(CP(GPMC_nCS6), (IDIS | PTU | EN | M0)) /*GPMC_nCS6*/\
850 MUX_VAL(CP(GPMC_nCS7), (IDIS | PTU | EN | M0)) /*GPMC_nCS7*/\
851 MUX_VAL(CP(GPMC_CLK), (IDIS | PTD | DIS | M0)) /*GPMC_CLK*/\
852 MUX_VAL(CP(GPMC_nADV_ALE), (IDIS | PTD | DIS | M0)) /*GPMC_nADV_ALE*/\
853 MUX_VAL(CP(GPMC_nOE), (IDIS | PTD | DIS | M0)) /*GPMC_nOE*/\
854 MUX_VAL(CP(GPMC_nWE), (IDIS | PTD | DIS | M0)) /*GPMC_nWE*/\
855 MUX_VAL(CP(GPMC_nBE0_CLE), (IDIS | PTD | DIS | M0)) /*GPMC_nBE0_CLE*/\
856 MUX_VAL(CP(GPMC_nBE1), (IEN | PTD | DIS | M0)) /*GPIO_61*/\
857 MUX_VAL(CP(GPMC_nWP), (IEN | PTD | DIS | M0)) /*GPMC_nWP*/\
858 MUX_VAL(CP(GPMC_WAIT0), (IEN | PTU | EN | M0)) /*GPMC_WAIT0*/\
859 MUX_VAL(CP(GPMC_WAIT1), (IEN | PTU | EN | M0)) /*GPMC_WAIT1*/\
860 MUX_VAL(CP(GPMC_WAIT2), (IEN | PTU | EN | M4)) /*GPIO_64*/\
861 MUX_VAL(CP(GPMC_WAIT3), (IEN | PTU | EN | M4)) /*GPIO_65*/\
862 MUX_VAL(CP(DSS_DATA18), (IEN | PTD | DIS | M4)) /*GPIO_88*/\
863 MUX_VAL(CP(DSS_DATA19), (IEN | PTD | DIS | M4)) /*GPIO_89*/\
864 MUX_VAL(CP(DSS_DATA20), (IEN | PTD | DIS | M4)) /*GPIO_90*/\
865 MUX_VAL(CP(DSS_DATA21), (IEN | PTD | DIS | M4)) /*GPIO_91*/\
866 MUX_VAL(CP(CAM_WEN), (IEN | PTD | DIS | M4)) /*GPIO_167*/\
867 MUX_VAL(CP(MMC1_CLK), (IDIS | PTU | EN | M0)) /*MMC1_CLK*/\
868 MUX_VAL(CP(MMC1_CMD), (IEN | PTU | EN | M0)) /*MMC1_CMD*/\
869 MUX_VAL(CP(MMC1_DAT0), (IEN | PTU | EN | M0)) /*MMC1_DAT0*/\
870 MUX_VAL(CP(MMC1_DAT1), (IEN | PTU | EN | M0)) /*MMC1_DAT1*/\
871 MUX_VAL(CP(MMC1_DAT2), (IEN | PTU | EN | M0)) /*MMC1_DAT2*/\
872 MUX_VAL(CP(MMC1_DAT3), (IEN | PTU | EN | M0)) /*MMC1_DAT3*/\
873 MUX_VAL(CP(MMC1_DAT4), (IEN | PTU | EN | M0)) /*MMC1_DAT4*/\
874 MUX_VAL(CP(MMC1_DAT5), (IEN | PTU | EN | M0)) /*MMC1_DAT5*/\
875 MUX_VAL(CP(MMC1_DAT6), (IEN | PTU | EN | M0)) /*MMC1_DAT6*/\
876 MUX_VAL(CP(MMC1_DAT7), (IEN | PTU | EN | M0)) /*MMC1_DAT7*/\
877 MUX_VAL(CP(UART1_TX), (IDIS | PTD | DIS | M0)) /*UART1_TX*/\
878 MUX_VAL(CP(UART1_RTS), (IDIS | PTD | DIS | M0)) /*UART1_RTS*/\
879 MUX_VAL(CP(UART1_CTS), (IEN | PTU | DIS | M0)) /*UART1_CTS*/\
880 MUX_VAL(CP(UART1_RX), (IEN | PTD | DIS | M0)) /*UART1_RX*/\
881 MUX_VAL(CP(UART3_CTS_RCTX), (IEN | PTD | EN | M0)) /*UART3_CTS_RCTX */\
882 MUX_VAL(CP(UART3_RTS_SD), (IDIS | PTD | DIS | M0)) /*UART3_RTS_SD */\
883 MUX_VAL(CP(UART3_RX_IRRX), (IEN | PTD | DIS | M0)) /*UART3_RX_IRRX*/\
884 MUX_VAL(CP(UART3_TX_IRTX), (IDIS | PTD | DIS | M0)) /*UART3_TX_IRTX*/\
885 MUX_VAL(CP(I2C1_SCL), (IEN | PTU | EN | M0)) /*I2C1_SCL*/\
886 MUX_VAL(CP(I2C1_SDA), (IEN | PTU | EN | M0)) /*I2C1_SDA*/\
887 MUX_VAL(CP(I2C2_SCL), (IEN | PTU | EN | M0)) /*I2C2_SCL*/\
888 MUX_VAL(CP(I2C2_SDA), (IEN | PTU | EN | M0)) /*I2C2_SDA*/\
889 MUX_VAL(CP(I2C3_SCL), (IEN | PTU | EN | M0)) /*I2C3_SCL*/\
890 MUX_VAL(CP(I2C3_SDA), (IEN | PTU | EN | M0)) /*I2C3_SDA*/\
891 MUX_VAL(CP(I2C4_SCL), (IEN | PTU | EN | M0)) /*I2C4_SCL*/\
892 MUX_VAL(CP(I2C4_SDA), (IEN | PTU | EN | M0)) /*I2C4_SDA*/\
893 MUX_VAL(CP(McBSP1_DX), (IEN | PTD | DIS | M4)) /*GPIO_158*/\
894 MUX_VAL(CP(SYS_32K), (IEN | PTD | DIS | M0)) /*SYS_32K*/\
895 MUX_VAL(CP(SYS_BOOT0), (IEN | PTD | DIS | M4)) /*GPIO_2 */\
896 MUX_VAL(CP(SYS_BOOT1), (IEN | PTD | DIS | M4)) /*GPIO_3 */\
897 MUX_VAL(CP(SYS_BOOT2), (IEN | PTD | DIS | M4)) /*GPIO_4 */\
898 MUX_VAL(CP(SYS_BOOT3), (IEN | PTD | DIS | M4)) /*GPIO_5 */\
899 MUX_VAL(CP(SYS_BOOT4), (IEN | PTD | DIS | M4)) /*GPIO_6 */\
900 MUX_VAL(CP(SYS_BOOT5), (IEN | PTD | DIS | M4)) /*GPIO_7 */\
901 MUX_VAL(CP(SYS_BOOT6), (IEN | PTD | DIS | M4)) /*GPIO_8 */\
902 MUX_VAL(CP(SYS_CLKOUT2), (IEN | PTU | EN | M4)) /*GPIO_186*/\
903 MUX_VAL(CP(JTAG_nTRST), (IEN | PTD | DIS | M0)) /*JTAG_nTRST*/\
904 MUX_VAL(CP(JTAG_TCK), (IEN | PTD | DIS | M0)) /*JTAG_TCK*/\
905 MUX_VAL(CP(JTAG_TMS), (IEN | PTD | DIS | M0)) /*JTAG_TMS*/\
906 MUX_VAL(CP(JTAG_TDI), (IEN | PTD | DIS | M0)) /*JTAG_TDI*/\
907 MUX_VAL(CP(JTAG_EMU0), (IEN | PTD | DIS | M0)) /*JTAG_EMU0*/\
908 MUX_VAL(CP(JTAG_EMU1), (IEN | PTD | DIS | M0)) /*JTAG_EMU1*/\
909 MUX_VAL(CP(ETK_CLK), (IEN | PTD | DIS | M4)) /*GPIO_12*/\
910 MUX_VAL(CP(ETK_CTL), (IEN | PTD | DIS | M4)) /*GPIO_13*/\
911 MUX_VAL(CP(ETK_D0), (IEN | PTD | DIS | M4)) /*GPIO_14*/\
912 MUX_VAL(CP(ETK_D1), (IEN | PTD | DIS | M4)) /*GPIO_15*/\
913 MUX_VAL(CP(ETK_D2), (IEN | PTD | DIS | M4)) /*GPIO_16*/\
914 MUX_VAL(CP(ETK_D11), (IEN | PTD | DIS | M4)) /*GPIO_25*/\
915 MUX_VAL(CP(ETK_D12), (IDIS | PTD | DIS | M4)) /*GPIO_26*/\
916 MUX_VAL(CP(ETK_D13), (IDIS | PTD | DIS | M4)) /*GPIO_27*/\
917 MUX_VAL(CP(ETK_D14), (IEN | PTD | DIS | M4)) /*GPIO_28*/\
918 MUX_VAL(CP(ETK_D15), (IEN | PTD | DIS | M4)) /*GPIO_29 */\
919 MUX_VAL(CP(sdrc_cke0), (IDIS | PTU | EN | M0)) /*sdrc_cke0 */\
920 MUX_VAL(CP(sdrc_cke1), (IDIS | PTD | DIS | M7)) /*sdrc_cke1 not used*/
922 /**********************************************************
923 * Routine: set_muxconf_regs
924 * Description: Setting up the configuration Mux registers
925 * specific to the hardware. Many pins need
926 * to be moved from protect to primary mode.
927 *********************************************************/
928 void set_muxconf_regs(void)
933 /**********************************************************
935 * Description: Set up flash, NAND and OneNAND
936 *********************************************************/
940 config_onenand_nand0xgr4wxa();
941 if (onenand_chip()) {
943 printf("OneNAND Unsupported !\n");
952 /* optionally do something */
953 void board_hang(void)
957 /******************************************************************************
958 * Dummy function to handle errors for EABI incompatibility
959 *****************************************************************************/