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>
9 * GraÅžvydas Ignotas <notasas@gmail.com>
11 * See file CREDITS for list of people who contributed to this
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 #include <asm/arch/cpu.h>
33 #include <asm/arch/bits.h>
34 #include <asm/arch/mux.h>
35 #include <asm/arch/gpio.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>
45 #define CORE_DPLL_PARAM_M2 0x09
46 #define CORE_DPLL_PARAM_M 0x360
47 #define CORE_DPLL_PARAM_N 0xC
49 /* Used to index into DPLL parameter tables */
57 typedef struct dpll_param dpll_param;
59 /* Following functions are exported from lowlevel_init.S */
60 extern dpll_param *get_mpu_dpll_param(void);
61 extern dpll_param *get_iva_dpll_param(void);
62 extern dpll_param *get_core_dpll_param(void);
63 extern dpll_param *get_per_dpll_param(void);
65 #define __raw_readl(a) (*(volatile unsigned int *)(a))
66 #define __raw_writel(v, a) (*(volatile unsigned int *)(a) = (v))
67 #define __raw_readw(a) (*(volatile unsigned short *)(a))
68 #define __raw_writew(v, a) (*(volatile unsigned short *)(a) = (v))
70 /* slight RAM timing differencer,
71 * tCKE differs from beagle's Micron part */
72 #define MICRON_V_ACTIMB_200_2 (((MICRON_V_ACTIMB_200) & ~(7 << 12)) | (1 << 12))
74 /*******************************************************
76 * Description: spinning delay to use before udelay works
77 ******************************************************/
78 static inline void delay(unsigned long loops)
80 __asm__ volatile ("1:\n" "subs %0, %1, #1\n"
81 "bne 1b":"=r" (loops):"0"(loops));
84 void udelay (unsigned long usecs) {
88 /*****************************************
90 * Description: Early hardware init.
91 *****************************************/
94 #if defined(CFG_PRINTF) && defined(CONFIG_DRIVER_OMAP34XX_I2C)
97 /* do additional init to prevent trash being output on startup */
100 /* restore GPBR1 for charging to work -
101 * boot ROM or something clears it before us */
103 i2c_write(0x49, 0x91, 1, &byte, 1);
105 /* VAUX3 = 2.8V (AV connector) */
107 i2c_write(0x4B, 0x7A, 1, &byte, 1);
109 i2c_write(0x4B, 0x7D, 1, &byte, 1);
115 /*************************************************************
116 * Routine: get_mem_type(void) - returns the kind of memory connected
117 * to GPMC that we are trying to boot form. Uses SYS BOOT settings.
118 *************************************************************/
119 u32 get_mem_type(void)
121 u32 mem_type = get_sysboot_value();
163 static void early_nand_init(void)
165 /* global settings */
166 __raw_writel(0x10, GPMC_SYSCONFIG); /* smart idle */
167 __raw_writel(0x0, GPMC_IRQENABLE); /* isr's sources masked */
168 __raw_writel(0, GPMC_TIMEOUT_CONTROL); /* timeout disable */
170 /* Set the GPMC Vals, NAND is mapped at CS0, oneNAND at CS0.
171 * We configure only GPMC CS0 with required values. Configiring other devices
172 * at other CS is done in u-boot. So we don't have to bother doing it here.
174 __raw_writel(0 , GPMC_CONFIG7 + GPMC_CONFIG_CS0);
177 __raw_writel(M_NAND_GPMC_CONFIG1, GPMC_CONFIG1 + GPMC_CONFIG_CS0);
178 __raw_writel(M_NAND_GPMC_CONFIG2, GPMC_CONFIG2 + GPMC_CONFIG_CS0);
179 __raw_writel(M_NAND_GPMC_CONFIG3, GPMC_CONFIG3 + GPMC_CONFIG_CS0);
180 __raw_writel(M_NAND_GPMC_CONFIG4, GPMC_CONFIG4 + GPMC_CONFIG_CS0);
181 __raw_writel(M_NAND_GPMC_CONFIG5, GPMC_CONFIG5 + GPMC_CONFIG_CS0);
182 __raw_writel(M_NAND_GPMC_CONFIG6, GPMC_CONFIG6 + GPMC_CONFIG_CS0);
184 /* Enable the GPMC Mapping */
185 __raw_writel((((OMAP34XX_GPMC_CS0_SIZE & 0xF)<<8) |
186 ((NAND_BASE_ADR>>24) & 0x3F) |
187 (1<<6)), (GPMC_CONFIG7 + GPMC_CONFIG_CS0));
191 #ifdef CFG_3430SDRAM_DDR
192 static int strncmp(const char *s1, const char *s2, int n)
195 for (i = 0; i < n; i++)
197 return s1[i] - s2[i];
201 #define MICRON_128MB_166MHZ 0
202 #define MICRON_256MB_200MHZ 1
204 /*********************************************************************
205 * config_sdram_ddr() - Init DDR SDRAM
206 *********************************************************************/
207 static void config_sdram_ddr(void)
209 unsigned char buf[64];
210 int ram_type = MICRON_128MB_166MHZ;
213 /* reset sdrc controller */
214 __raw_writel(SOFTRESET, SDRC_SYSCONFIG);
215 wait_on_value(BIT0, BIT0, SDRC_STATUS, 12000000);
216 __raw_writel(0, SDRC_SYSCONFIG);
218 /* setup sdrc to ball mux */
219 __raw_writel(SDP_SDRC_SHARING, SDRC_SHARING);
221 /* read NAND id to guess what RAM is attached */
223 ret = nand_read_param_page(buf, sizeof(buf));
225 if (strncmp((char *)buf + 44, "MT29F4G16ABBDA", 14) == 0)
226 ram_type = MICRON_256MB_200MHZ;
229 if (ram_type == MICRON_256MB_200MHZ) {
230 __raw_writel(0x2, SDRC_CS_CFG); /* 256MB/bank */
231 __raw_writel(SDP_SDRC_MDCFG_0_DDR_MICRON_XM, SDRC_MCFG_0);
232 __raw_writel(SDP_SDRC_MDCFG_0_DDR_MICRON_XM, SDRC_MCFG_1);
234 __raw_writel(0x1, SDRC_CS_CFG); /* 128MB/bank */
235 __raw_writel(SDP_SDRC_MDCFG_0_DDR, SDRC_MCFG_0);
236 __raw_writel(SDP_SDRC_MDCFG_0_DDR, SDRC_MCFG_1);
239 if (get_cpu_family() == CPU_OMAP36XX && ram_type == MICRON_256MB_200MHZ) {
240 __raw_writel(MICRON_V_ACTIMA_200, SDRC_ACTIM_CTRLA_0);
241 __raw_writel(MICRON_V_ACTIMB_200_2, SDRC_ACTIM_CTRLB_0);
242 __raw_writel(MICRON_V_ACTIMA_200, SDRC_ACTIM_CTRLA_1);
243 __raw_writel(MICRON_V_ACTIMB_200_2, SDRC_ACTIM_CTRLB_1);
244 __raw_writel(SDP_3430_SDRC_RFR_CTRL_200MHz, SDRC_RFR_CTRL_0);
245 __raw_writel(SDP_3430_SDRC_RFR_CTRL_200MHz, SDRC_RFR_CTRL_1);
247 __raw_writel(MICRON_V_ACTIMA_165, SDRC_ACTIM_CTRLA_0);
248 __raw_writel(MICRON_V_ACTIMB_165, SDRC_ACTIM_CTRLB_0);
249 __raw_writel(MICRON_V_ACTIMA_165, SDRC_ACTIM_CTRLA_1);
250 __raw_writel(MICRON_V_ACTIMB_165, SDRC_ACTIM_CTRLB_1);
251 __raw_writel(SDP_3430_SDRC_RFR_CTRL_165MHz, SDRC_RFR_CTRL_0);
252 __raw_writel(SDP_3430_SDRC_RFR_CTRL_165MHz, SDRC_RFR_CTRL_1);
255 __raw_writel(SDP_SDRC_POWER_POP, SDRC_POWER);
257 /* init sequence for mDDR/mSDR using manual commands (DDR is different) */
258 __raw_writel(CMD_NOP, SDRC_MANUAL_0);
259 __raw_writel(CMD_NOP, SDRC_MANUAL_1);
263 __raw_writel(CMD_PRECHARGE, SDRC_MANUAL_0);
264 __raw_writel(CMD_PRECHARGE, SDRC_MANUAL_1);
266 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0);
267 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_1);
269 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_0);
270 __raw_writel(CMD_AUTOREFRESH, SDRC_MANUAL_1);
273 __raw_writel(SDP_SDRC_MR_0_DDR, SDRC_MR_0);
274 __raw_writel(SDP_SDRC_MR_0_DDR, SDRC_MR_1);
277 __raw_writel(SDP_SDRC_DLLAB_CTRL, SDRC_DLLA_CTRL);
278 delay(0x2000); /* give time to lock */
280 #endif /* CFG_3430SDRAM_DDR */
282 /*************************************************************
283 * get_sys_clk_speed - determine reference oscillator speed
284 * based on known 32kHz clock and gptimer.
285 *************************************************************/
286 u32 get_osc_clk_speed(void)
288 u32 start, cstart, cend, cdiff, cdiv, val;
290 val = __raw_readl(PRM_CLKSRC_CTRL);
292 if (val & SYSCLKDIV_2)
298 val = __raw_readl(CM_CLKSEL_WKUP) | BIT0;
299 __raw_writel(val, CM_CLKSEL_WKUP); /* select sys_clk for GPT1 */
301 /* Enable I and F Clocks for GPT1 */
302 val = __raw_readl(CM_ICLKEN_WKUP) | BIT0 | BIT2;
303 __raw_writel(val, CM_ICLKEN_WKUP);
304 val = __raw_readl(CM_FCLKEN_WKUP) | BIT0;
305 __raw_writel(val, CM_FCLKEN_WKUP);
307 __raw_writel(0, OMAP34XX_GPT1 + TLDR); /* start counting at 0 */
308 __raw_writel(GPT_EN, OMAP34XX_GPT1 + TCLR); /* enable clock */
309 /* enable 32kHz source */
310 /* enabled out of reset */
311 /* determine sys_clk via gauging */
313 start = 20 + __raw_readl(S32K_CR); /* start time in 20 cycles */
314 while (__raw_readl(S32K_CR) < start) ; /* dead loop till start time */
315 cstart = __raw_readl(OMAP34XX_GPT1 + TCRR); /* get start sys_clk count */
316 while (__raw_readl(S32K_CR) < (start + 20)) ; /* wait for 40 cycles */
317 cend = __raw_readl(OMAP34XX_GPT1 + TCRR); /* get end sys_clk count */
318 cdiff = cend - cstart; /* get elapsed ticks */
321 /* based on number of ticks assign speed */
324 else if (cdiff > 15200)
326 else if (cdiff > 13000)
328 else if (cdiff > 9000)
330 else if (cdiff > 7600)
336 /******************************************************************************
337 * prcm_init() - inits clocks for PRCM as defined in clocks.h
338 * -- called from SRAM, or Flash (using temp SRAM stack).
339 *****************************************************************************/
342 u32 osc_clk = 0, sys_clkin_sel;
343 dpll_param *dpll_param_p;
344 u32 clk_index, sil_index;
346 /* Gauge the input clock speed and find out the sys_clkin_sel
347 * value corresponding to the input clock.
349 osc_clk = get_osc_clk_speed();
350 get_sys_clkin_sel(osc_clk, &sys_clkin_sel);
352 sr32(PRM_CLKSEL, 0, 3, sys_clkin_sel); /* set input crystal speed */
354 /* If the input clock is greater than 19.2M always divide/2 */
355 if (sys_clkin_sel > 2) {
356 sr32(PRM_CLKSRC_CTRL, 6, 2, 2); /* input clock divider */
357 clk_index = sys_clkin_sel / 2;
359 sr32(PRM_CLKSRC_CTRL, 6, 2, 1); /* input clock divider */
360 clk_index = sys_clkin_sel;
363 sr32(PRM_CLKSRC_CTRL, 0, 2, 0);/* Bypass mode: T2 inputs a square clock */
365 /* The DPLL tables are defined according to sysclk value and
366 * silicon revision. The clk_index value will be used to get
367 * the values for that input sysclk from the DPLL param table
368 * and sil_index will get the values for that SysClk for the
369 * appropriate silicon rev.
371 sil_index = !(get_cpu_rev() == CPU_3XX_ES10);
373 /* Unlock MPU DPLL (slows things down, and needed later) */
374 sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOW_POWER_BYPASS);
375 wait_on_value(BIT0, 0, CM_IDLEST_PLL_MPU, LDELAY);
377 /* Getting the base address of Core DPLL param table */
378 dpll_param_p = (dpll_param *) get_core_dpll_param();
379 /* Moving it to the right sysclk and ES rev base */
380 dpll_param_p = dpll_param_p + 3 * clk_index + sil_index;
382 /* sr32(CM_CLKSEL2_EMU) set override to work when asleep */
383 sr32(CM_CLKEN_PLL, 0, 3, PLL_FAST_RELOCK_BYPASS);
384 wait_on_value(BIT0, 0, CM_IDLEST_CKGEN, LDELAY);
386 /* For 3430 ES1.0 Errata 1.50, default value directly doesnt
387 work. write another value and then default value. */
388 sr32(CM_CLKSEL1_EMU, 16, 5, CORE_M3X2 + 1); /* m3x2 */
389 sr32(CM_CLKSEL1_EMU, 16, 5, CORE_M3X2); /* m3x2 */
390 sr32(CM_CLKSEL1_PLL, 27, 2, dpll_param_p->m2); /* Set M2 */
391 sr32(CM_CLKSEL1_PLL, 16, 11, dpll_param_p->m); /* Set M */
392 sr32(CM_CLKSEL1_PLL, 8, 7, dpll_param_p->n); /* Set N */
393 sr32(CM_CLKSEL1_PLL, 6, 1, 0); /* 96M Src */
394 sr32(CM_CLKSEL_CORE, 8, 4, CORE_SSI_DIV); /* ssi */
395 sr32(CM_CLKSEL_CORE, 4, 2, CORE_FUSB_DIV); /* fsusb */
396 sr32(CM_CLKSEL_CORE, 2, 2, CORE_L4_DIV); /* l4 */
397 sr32(CM_CLKSEL_CORE, 0, 2, CORE_L3_DIV); /* l3 */
398 sr32(CM_CLKSEL_GFX, 0, 3, GFX_DIV); /* gfx */
399 sr32(CM_CLKSEL_WKUP, 1, 2, WKUP_RSM); /* reset mgr */
400 sr32(CM_CLKEN_PLL, 4, 4, dpll_param_p->fsel); /* FREQSEL */
401 sr32(CM_CLKEN_PLL, 0, 3, PLL_LOCK); /* lock mode */
402 wait_on_value(BIT0, 1, CM_IDLEST_CKGEN, LDELAY);
404 /* Getting the base address to PER DPLL param table */
405 dpll_param_p = (dpll_param *) get_per_dpll_param();
406 /* Moving it to the right sysclk base */
407 dpll_param_p = dpll_param_p + clk_index;
409 sr32(CM_CLKEN_PLL, 16, 3, PLL_STOP);
410 wait_on_value(BIT1, 0, CM_IDLEST_CKGEN, LDELAY);
411 sr32(CM_CLKSEL1_EMU, 24, 5, PER_M6X2); /* set M6 */
412 sr32(CM_CLKSEL_CAM, 0, 5, PER_M5X2); /* set M5 */
413 sr32(CM_CLKSEL_DSS, 0, 5, PER_M4X2); /* set M4 */
414 sr32(CM_CLKSEL_DSS, 8, 5, PER_M3X2); /* set M3 */
416 if (get_cpu_family() == CPU_OMAP36XX) {
417 sr32(CM_CLKSEL3_PLL, 0, 5, CORE_DPLL_PARAM_M2); /* set M2 */
418 sr32(CM_CLKSEL2_PLL, 8, 11, CORE_DPLL_PARAM_M); /* set m */
419 sr32(CM_CLKSEL2_PLL, 0, 7, CORE_DPLL_PARAM_N); /* set n */
421 sr32(CM_CLKSEL3_PLL, 0, 5, dpll_param_p->m2); /* set M2 */
422 sr32(CM_CLKSEL2_PLL, 8, 11, dpll_param_p->m); /* set m */
423 sr32(CM_CLKSEL2_PLL, 0, 7, dpll_param_p->n); /* set n */
426 sr32(CM_CLKEN_PLL, 20, 4, dpll_param_p->fsel); /* FREQSEL */
427 sr32(CM_CLKEN_PLL, 16, 3, PLL_LOCK); /* lock mode */
428 wait_on_value(BIT1, 2, CM_IDLEST_CKGEN, LDELAY);
430 /* Getting the base address to MPU DPLL param table */
431 dpll_param_p = (dpll_param *) get_mpu_dpll_param();
433 /* Moving it to the right sysclk and ES rev base */
434 dpll_param_p = dpll_param_p + 3 * clk_index + sil_index;
436 /* MPU DPLL (unlocked already) */
437 sr32(CM_CLKSEL2_PLL_MPU, 0, 5, dpll_param_p->m2); /* Set M2 */
438 sr32(CM_CLKSEL1_PLL_MPU, 8, 11, dpll_param_p->m); /* Set M */
439 sr32(CM_CLKSEL1_PLL_MPU, 0, 7, dpll_param_p->n); /* Set N */
440 sr32(CM_CLKEN_PLL_MPU, 4, 4, dpll_param_p->fsel); /* FREQSEL */
441 sr32(CM_CLKEN_PLL_MPU, 0, 3, PLL_LOCK); /* lock mode */
442 wait_on_value(BIT0, 1, CM_IDLEST_PLL_MPU, LDELAY);
444 /* Getting the base address to IVA DPLL param table */
445 dpll_param_p = (dpll_param *) get_iva_dpll_param();
446 /* Moving it to the right sysclk and ES rev base */
447 dpll_param_p = dpll_param_p + 3 * clk_index + sil_index;
448 /* IVA DPLL (set to 12*20=240MHz) */
449 sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_STOP);
450 wait_on_value(BIT0, 0, CM_IDLEST_PLL_IVA2, LDELAY);
451 sr32(CM_CLKSEL2_PLL_IVA2, 0, 5, dpll_param_p->m2); /* set M2 */
452 sr32(CM_CLKSEL1_PLL_IVA2, 8, 11, dpll_param_p->m); /* set M */
453 sr32(CM_CLKSEL1_PLL_IVA2, 0, 7, dpll_param_p->n); /* set N */
454 sr32(CM_CLKEN_PLL_IVA2, 4, 4, dpll_param_p->fsel); /* FREQSEL */
455 sr32(CM_CLKEN_PLL_IVA2, 0, 3, PLL_LOCK); /* lock mode */
456 wait_on_value(BIT0, 1, CM_IDLEST_PLL_IVA2, LDELAY);
458 /* Set up GPTimers to sys_clk source only */
459 sr32(CM_CLKSEL_PER, 0, 8, 0xff);
460 sr32(CM_CLKSEL_WKUP, 0, 1, 1);
465 /**********************************************************
467 * Description: Does early system init of muxing and clocks.
468 * - Called at time when only stack is available.
469 **********************************************************/
482 /*******************************************************
483 * Routine: misc_init_r
484 ********************************************************/
485 int misc_init_r(void)
488 unsigned char buf[64];
492 printf("OpenPandora System\n");
496 ret = nand_read_param_page(buf, sizeof(buf));
498 for (i = 0; i < sizeof(nand_model) - 1; i++) {
499 if (buf[i + 44] == ' ')
501 nand_model[i] = buf[i + 44];
504 printf("NAND: %s\n", nand_model);
511 /******************************************************
512 * Routine: wait_for_command_complete
513 * Description: Wait for posting to finish on watchdog
514 ******************************************************/
515 void wait_for_command_complete(unsigned int wd_base)
519 pending = __raw_readl(wd_base + WWPS);
523 /****************************************
524 * Routine: watchdog_init
525 * Description: Shut down watch dogs
526 *****************************************/
527 void watchdog_init(void)
529 /* There are 3 watch dogs WD1=Secure, WD2=MPU, WD3=IVA. WD1 is
530 * either taken care of by ROM (HS/EMU) or not accessible (GP).
531 * We need to take care of WD2-MPU or take a PRCM reset. WD3
532 * should not be running and does not generate a PRCM reset.
534 sr32(CM_FCLKEN_WKUP, 5, 1, 1);
535 sr32(CM_ICLKEN_WKUP, 5, 1, 1);
536 wait_on_value(BIT5, 0x20, CM_IDLEST_WKUP, 5); /* some issue here */
538 __raw_writel(WD_UNLOCK1, WD2_BASE + WSPR);
539 wait_for_command_complete(WD2_BASE);
540 __raw_writel(WD_UNLOCK2, WD2_BASE + WSPR);
543 /**********************************************
545 * Description: sets uboots idea of sdram size
546 **********************************************/
552 /*****************************************************************
553 * Routine: peripheral_enable
554 * Description: Enable the clks & power for perifs (GPT2, UART1,...)
555 ******************************************************************/
556 void per_clocks_enable(void)
558 /* Enable GP2 timer. */
559 sr32(CM_CLKSEL_PER, 0, 1, 0x1); /* GPT2 = sys clk */
560 sr32(CM_ICLKEN_PER, 3, 1, 0x1); /* ICKen GPT2 */
561 sr32(CM_FCLKEN_PER, 3, 1, 0x1); /* FCKen GPT2 */
565 sr32(CM_FCLKEN1_CORE, 13, 1, 0x1);
566 sr32(CM_ICLKEN1_CORE, 13, 1, 0x1);
569 sr32(CM_FCLKEN_PER, 11, 1, 0x1);
570 sr32(CM_ICLKEN_PER, 11, 1, 0x1);
573 #ifdef CONFIG_DRIVER_OMAP34XX_I2C
574 /* Turn on all 3 I2C clocks */
575 sr32(CM_FCLKEN1_CORE, 15, 3, 0x7);
576 sr32(CM_ICLKEN1_CORE, 15, 3, 0x7); /* I2C1,2,3 = on */
579 /* Enable the ICLK for 32K Sync Timer as its used in udelay */
580 sr32(CM_ICLKEN_WKUP, 2, 1, 0x1);
582 sr32(CM_FCLKEN_IVA2, 0, 32, FCK_IVA2_ON);
583 sr32(CM_FCLKEN1_CORE, 0, 32, FCK_CORE1_ON);
584 sr32(CM_ICLKEN1_CORE, 0, 32, ICK_CORE1_ON);
585 sr32(CM_ICLKEN2_CORE, 0, 32, ICK_CORE2_ON);
586 sr32(CM_FCLKEN_WKUP, 0, 32, FCK_WKUP_ON);
587 sr32(CM_ICLKEN_WKUP, 0, 32, ICK_WKUP_ON);
588 sr32(CM_FCLKEN_DSS, 0, 32, FCK_DSS_ON);
589 sr32(CM_ICLKEN_DSS, 0, 32, ICK_DSS_ON);
590 sr32(CM_FCLKEN_CAM, 0, 32, FCK_CAM_ON);
591 sr32(CM_ICLKEN_CAM, 0, 32, ICK_CAM_ON);
592 sr32(CM_FCLKEN_PER, 0, 32, FCK_PER_ON);
593 sr32(CM_ICLKEN_PER, 0, 32, ICK_PER_ON);
595 /* Enable GPIO5 clocks for blinky LEDs */
596 sr32(CM_FCLKEN_PER, 16, 1, 0x1); /* FCKen GPIO5 */
597 sr32(CM_ICLKEN_PER, 16, 1, 0x1); /* ICKen GPIO5 */
602 /* Set MUX for UART, GPMC, SDRC, GPIO */
604 #define MUX_VAL(OFFSET,VALUE)\
605 __raw_writew((VALUE), OMAP34XX_CTRL_BASE + (OFFSET));
607 #define CP(x) (CONTROL_PADCONF_##x)
610 * IDIS - Input Disable
611 * PTD - Pull type Down
613 * DIS - Pull type selection is inactive
614 * EN - Pull type selection is active
616 * The commented string gives the final mux configuration for that pin
618 #define MUX_DEFAULT()\
620 MUX_VAL(CP(SDRC_D0), (IEN | PTD | DIS | M0)) /*SDRC_D0*/\
621 MUX_VAL(CP(SDRC_D1), (IEN | PTD | DIS | M0)) /*SDRC_D1*/\
622 MUX_VAL(CP(SDRC_D2), (IEN | PTD | DIS | M0)) /*SDRC_D2*/\
623 MUX_VAL(CP(SDRC_D3), (IEN | PTD | DIS | M0)) /*SDRC_D3*/\
624 MUX_VAL(CP(SDRC_D4), (IEN | PTD | DIS | M0)) /*SDRC_D4*/\
625 MUX_VAL(CP(SDRC_D5), (IEN | PTD | DIS | M0)) /*SDRC_D5*/\
626 MUX_VAL(CP(SDRC_D6), (IEN | PTD | DIS | M0)) /*SDRC_D6*/\
627 MUX_VAL(CP(SDRC_D7), (IEN | PTD | DIS | M0)) /*SDRC_D7*/\
628 MUX_VAL(CP(SDRC_D8), (IEN | PTD | DIS | M0)) /*SDRC_D8*/\
629 MUX_VAL(CP(SDRC_D9), (IEN | PTD | DIS | M0)) /*SDRC_D9*/\
630 MUX_VAL(CP(SDRC_D10), (IEN | PTD | DIS | M0)) /*SDRC_D10*/\
631 MUX_VAL(CP(SDRC_D11), (IEN | PTD | DIS | M0)) /*SDRC_D11*/\
632 MUX_VAL(CP(SDRC_D12), (IEN | PTD | DIS | M0)) /*SDRC_D12*/\
633 MUX_VAL(CP(SDRC_D13), (IEN | PTD | DIS | M0)) /*SDRC_D13*/\
634 MUX_VAL(CP(SDRC_D14), (IEN | PTD | DIS | M0)) /*SDRC_D14*/\
635 MUX_VAL(CP(SDRC_D15), (IEN | PTD | DIS | M0)) /*SDRC_D15*/\
636 MUX_VAL(CP(SDRC_D16), (IEN | PTD | DIS | M0)) /*SDRC_D16*/\
637 MUX_VAL(CP(SDRC_D17), (IEN | PTD | DIS | M0)) /*SDRC_D17*/\
638 MUX_VAL(CP(SDRC_D18), (IEN | PTD | DIS | M0)) /*SDRC_D18*/\
639 MUX_VAL(CP(SDRC_D19), (IEN | PTD | DIS | M0)) /*SDRC_D19*/\
640 MUX_VAL(CP(SDRC_D20), (IEN | PTD | DIS | M0)) /*SDRC_D20*/\
641 MUX_VAL(CP(SDRC_D21), (IEN | PTD | DIS | M0)) /*SDRC_D21*/\
642 MUX_VAL(CP(SDRC_D22), (IEN | PTD | DIS | M0)) /*SDRC_D22*/\
643 MUX_VAL(CP(SDRC_D23), (IEN | PTD | DIS | M0)) /*SDRC_D23*/\
644 MUX_VAL(CP(SDRC_D24), (IEN | PTD | DIS | M0)) /*SDRC_D24*/\
645 MUX_VAL(CP(SDRC_D25), (IEN | PTD | DIS | M0)) /*SDRC_D25*/\
646 MUX_VAL(CP(SDRC_D26), (IEN | PTD | DIS | M0)) /*SDRC_D26*/\
647 MUX_VAL(CP(SDRC_D27), (IEN | PTD | DIS | M0)) /*SDRC_D27*/\
648 MUX_VAL(CP(SDRC_D28), (IEN | PTD | DIS | M0)) /*SDRC_D28*/\
649 MUX_VAL(CP(SDRC_D29), (IEN | PTD | DIS | M0)) /*SDRC_D29*/\
650 MUX_VAL(CP(SDRC_D30), (IEN | PTD | DIS | M0)) /*SDRC_D30*/\
651 MUX_VAL(CP(SDRC_D31), (IEN | PTD | DIS | M0)) /*SDRC_D31*/\
652 MUX_VAL(CP(SDRC_CLK), (IEN | PTD | DIS | M0)) /*SDRC_CLK*/\
653 MUX_VAL(CP(SDRC_DQS0), (IEN | PTD | DIS | M0)) /*SDRC_DQS0*/\
654 MUX_VAL(CP(SDRC_DQS1), (IEN | PTD | DIS | M0)) /*SDRC_DQS1*/\
655 MUX_VAL(CP(SDRC_DQS2), (IEN | PTD | DIS | M0)) /*SDRC_DQS2*/\
656 MUX_VAL(CP(SDRC_DQS3), (IEN | PTD | DIS | M0)) /*SDRC_DQS3*/\
658 MUX_VAL(CP(GPMC_A1), (IDIS | PTD | DIS | M0)) /*GPMC_A1*/\
659 MUX_VAL(CP(GPMC_A2), (IDIS | PTD | DIS | M0)) /*GPMC_A2*/\
660 MUX_VAL(CP(GPMC_A3), (IDIS | PTD | DIS | M0)) /*GPMC_A3*/\
661 MUX_VAL(CP(GPMC_A4), (IDIS | PTD | DIS | M0)) /*GPMC_A4*/\
662 MUX_VAL(CP(GPMC_A5), (IDIS | PTD | DIS | M0)) /*GPMC_A5*/\
663 MUX_VAL(CP(GPMC_A6), (IDIS | PTD | DIS | M0)) /*GPMC_A6*/\
664 MUX_VAL(CP(GPMC_A7), (IDIS | PTD | DIS | M0)) /*GPMC_A7*/\
665 MUX_VAL(CP(GPMC_A8), (IDIS | PTD | DIS | M0)) /*GPMC_A8*/\
666 MUX_VAL(CP(GPMC_A9), (IDIS | PTD | DIS | M0)) /*GPMC_A9*/\
667 MUX_VAL(CP(GPMC_A10), (IDIS | PTD | DIS | M0)) /*GPMC_A10*/\
668 MUX_VAL(CP(GPMC_D0), (IEN | PTD | DIS | M0)) /*GPMC_D0*/\
669 MUX_VAL(CP(GPMC_D1), (IEN | PTD | DIS | M0)) /*GPMC_D1*/\
670 MUX_VAL(CP(GPMC_D2), (IEN | PTD | DIS | M0)) /*GPMC_D2*/\
671 MUX_VAL(CP(GPMC_D3), (IEN | PTD | DIS | M0)) /*GPMC_D3*/\
672 MUX_VAL(CP(GPMC_D4), (IEN | PTD | DIS | M0)) /*GPMC_D4*/\
673 MUX_VAL(CP(GPMC_D5), (IEN | PTD | DIS | M0)) /*GPMC_D5*/\
674 MUX_VAL(CP(GPMC_D6), (IEN | PTD | DIS | M0)) /*GPMC_D6*/\
675 MUX_VAL(CP(GPMC_D7), (IEN | PTD | DIS | M0)) /*GPMC_D7*/\
676 MUX_VAL(CP(GPMC_D8), (IEN | PTD | DIS | M0)) /*GPMC_D8*/\
677 MUX_VAL(CP(GPMC_D9), (IEN | PTD | DIS | M0)) /*GPMC_D9*/\
678 MUX_VAL(CP(GPMC_D10), (IEN | PTD | DIS | M0)) /*GPMC_D10*/\
679 MUX_VAL(CP(GPMC_D11), (IEN | PTD | DIS | M0)) /*GPMC_D11*/\
680 MUX_VAL(CP(GPMC_D12), (IEN | PTD | DIS | M0)) /*GPMC_D12*/\
681 MUX_VAL(CP(GPMC_D13), (IEN | PTD | DIS | M0)) /*GPMC_D13*/\
682 MUX_VAL(CP(GPMC_D14), (IEN | PTD | DIS | M0)) /*GPMC_D14*/\
683 MUX_VAL(CP(GPMC_D15), (IEN | PTD | DIS | M0)) /*GPMC_D15*/\
684 MUX_VAL(CP(GPMC_nCS0), (IDIS | PTU | EN | M0)) /*GPMC_nCS0*/\
685 MUX_VAL(CP(GPMC_nCS1), (IDIS | PTU | EN | M0)) /*GPMC_nCS1*/\
686 MUX_VAL(CP(GPMC_CLK), (IDIS | PTD | DIS | M0)) /*GPMC_CLK*/\
687 MUX_VAL(CP(GPMC_nADV_ALE), (IDIS | PTD | DIS | M0)) /*GPMC_nADV_ALE*/\
688 MUX_VAL(CP(GPMC_nOE), (IDIS | PTD | DIS | M0)) /*GPMC_nOE*/\
689 MUX_VAL(CP(GPMC_nWE), (IDIS | PTD | DIS | M0)) /*GPMC_nWE*/\
690 MUX_VAL(CP(GPMC_nBE0_CLE), (IDIS | PTD | DIS | M0)) /*GPMC_nBE0_CLE*/\
691 MUX_VAL(CP(GPMC_nWP), (IEN | PTD | DIS | M0)) /*GPMC_nWP*/\
692 MUX_VAL(CP(GPMC_WAIT0), (IEN | PTU | EN | M0)) /*GPMC_WAIT0*/\
693 MUX_VAL(CP(GPMC_WAIT1), (IEN | PTU | EN | M0)) /*GPMC_WAIT1*/\
694 /*Serial Interface (Peripheral boot, Linux console)*/\
695 MUX_VAL(CP(UART3_RX_IRRX ), (IEN | PTD | DIS | M0)) /*UART3_RX*/\
696 MUX_VAL(CP(UART3_TX_IRTX ), (IDIS | PTD | DIS | M0)) /*UART3_TX*/\
698 MUX_VAL(CP(I2C1_SCL), (IEN | PTU | EN | M0)) /*I2C1_SCL*/\
699 MUX_VAL(CP(I2C1_SDA), (IEN | PTU | EN | M0)) /*I2C1_SDA*/\
700 /*LEDs (Controlled by OMAP)*/\
701 MUX_VAL(CP(MMC1_DAT6), (IDIS | PTD | DIS | M4)) /*GPIO_128*/\
702 MUX_VAL(CP(MMC1_DAT7), (IDIS | PTD | DIS | M4)) /*GPIO_129*/\
704 /**********************************************************
705 * Routine: set_muxconf_regs
706 * Description: Setting up the configuration Mux registers
707 * specific to the hardware. Many pins need
708 * to be moved from protect to primary mode.
709 *********************************************************/
710 void set_muxconf_regs(void)
715 /**********************************************************
716 * Routine: nand+_init
717 * Description: Set up nand for nand and jffs2 commands
718 *********************************************************/
721 /* init already done in early_nand_init */
723 if (get_mem_type() != GPMC_NAND && get_mem_type() != MMC_NAND) {
725 printf("Unsupported flash chip!\n");
732 printf("Unsupported NAND Chip!\n");
740 #define DEBUG_LED1 128 /* gpio - SD Slot 1 */
741 #define DEBUG_LED2 129 /* gpio - SD Slot 2 */
743 static void blinkLEDs(void)
747 /* Alternately turn the LEDs on and off */
748 p = (unsigned long *)OMAP34XX_GPIO5_BASE;
750 /* turn LED1 on and LED2 off */
751 *(unsigned long *)(p + 0x94) = 1 << (DEBUG_LED1 % 32);
752 *(unsigned long *)(p + 0x90) = 1 << (DEBUG_LED2 % 32);
754 /* delay for a while */
757 /* turn LED1 off and LED2 on */
758 *(unsigned long *)(p + 0x90) = 1 << (DEBUG_LED1 % 32);
759 *(unsigned long *)(p + 0x94) = 1 << (DEBUG_LED2 % 32);
761 /* delay for a while */
766 /* optionally do something like blinking LED */
767 void board_hang(void)
773 /******************************************************************************
774 * Dummy function to handle errors for EABI incompatibility
775 *****************************************************************************/
780 /******************************************************************************
781 * Dummy function to handle errors for EABI incompatibility
782 *****************************************************************************/