4 * Common board functions for AM33XX based boards
6 * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
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.
20 #include <asm/arch/cpu.h>
21 #include <asm/arch/hardware.h>
22 #include <asm/arch/omap.h>
23 #include <asm/arch/ddr_defs.h>
24 #include <asm/arch/clock.h>
25 #include <asm/arch/mmc_host_def.h>
26 #include <asm/arch/common_def.h>
28 #include <asm/omap_common.h>
30 DECLARE_GLOBAL_DATA_PTR;
33 #ifdef CONFIG_SPL_BUILD
34 #define UART_RESET (0x1 << 1)
35 #define UART_CLK_RUNNING_MASK 0x1
36 #define UART_SMART_IDLE_EN (0x1 << 0x3)
39 void reset_cpu(unsigned long ignored)
41 /* clear RESET flags */
42 writel(~0, PRM_RSTST);
43 writel(PRM_RSTCTRL_RESET, PRM_RSTCTRL);
46 #ifdef CONFIG_HW_WATCHDOG
47 void hw_watchdog_reset(void)
49 struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;
50 static int trg __attribute__((section(".data")));
55 if (readl(&wdtimer->wdtwwps) & (1 << 4))
57 writel(trg ? 0x5555 : 0xaaaa, &wdtimer->wdtwspr);
60 if (readl(&wdtimer->wdtwwps) & (1 << 2))
63 writel(-32768 * 10, &wdtimer->wdtwldr);
65 if (readl(&wdtimer->wdtwwps) & (1 << 0))
68 writel(0, &wdtimer->wdtwclr);
74 if (readl(&wdtimer->wdtwwps) & (1 << 4))
76 writel((trg & 1) ? 0xBBBB : 0x4444, &wdtimer->wdtwspr);
80 /* retrigger watchdog */
81 if (readl(&wdtimer->wdtwwps) & (1 << 3))
84 writel(trg, &wdtimer->wdtwtgr);
93 * early system init of muxing and clocks.
97 #ifdef CONFIG_SPL_BUILD
98 #ifndef CONFIG_HW_WATCHDOG
99 struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;
101 /* WDT1 is already running when the bootloader gets control
102 * Disable it to avoid "random" resets
104 writel(0xAAAA, &wdtimer->wdtwspr);
105 while (readl(&wdtimer->wdtwwps) != 0x0)
107 writel(0x5555, &wdtimer->wdtwspr);
108 while (readl(&wdtimer->wdtwwps) != 0x0)
111 /* Setup the PLLs and the clocks for the peripherals */
116 struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE;
118 enable_uart0_pin_mux();
120 regVal = readl(&uart_base->uartsyscfg);
121 regVal |= UART_RESET;
122 writel(regVal, &uart_base->uartsyscfg);
123 while ((readl(&uart_base->uartsyssts) &
124 UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK)
127 /* Disable smart idle */
128 regVal = readl(&uart_base->uartsyscfg);
129 regVal |= UART_SMART_IDLE_EN;
130 writel(regVal, &uart_base->uartsyscfg);
132 /* Initialize the Timer */
135 preloader_console_init();
140 enable_mmc0_pin_mux();
144 #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
145 int board_mmc_init(bd_t *bis)
148 #ifdef CONFIG_OMAP_MMC_DEV_0
149 ret = omap_mmc_init(0, 0, 0);
151 printf("Error %d while initializing MMC dev 0\n", ret);
153 #ifdef CONFIG_OMAP_MMC_DEV_1
154 ret = omap_mmc_init(1, 0, 0);
156 printf("Error %d while initializing MMC dev 1\n", ret);
162 #ifndef CONFIG_SYS_DCACHE_OFF
163 void enable_caches(void)
165 /* Enable D-cache. I-cache is already enabled in start.S */
170 static u32 cortex_rev(void)
175 /* Read Main ID Register (MIDR) */
176 asm ("mrc p15, 0, %0, c0, c0, 0" : "=r" (rev));
181 void omap_rev_string(void)
183 u32 omap_rev = cortex_rev();
184 u32 omap_variant = (omap_rev & 0xFFFF0000) >> 16;
185 u32 major_rev = (omap_rev & 0x00000F00) >> 8;
186 u32 minor_rev = (omap_rev & 0x000000F0) >> 4;
188 printf("OMAP%x ES%x.%x\n", omap_variant, major_rev,