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/gpio.h>
26 #include <asm/arch/mmc_host_def.h>
27 #include <asm/arch/common_def.h>
29 #include <asm/omap_common.h>
32 DECLARE_GLOBAL_DATA_PTR;
34 struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;
35 struct gptimer *timer_base = (struct gptimer *)CONFIG_SYS_TIMERBASE;
36 struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE;
38 static const struct gpio_bank gpio_bank_am33xx[4] = {
39 { (void *)AM33XX_GPIO0_BASE, METHOD_GPIO_24XX },
40 { (void *)AM33XX_GPIO1_BASE, METHOD_GPIO_24XX },
41 { (void *)AM33XX_GPIO2_BASE, METHOD_GPIO_24XX },
42 { (void *)AM33XX_GPIO3_BASE, METHOD_GPIO_24XX },
45 const struct gpio_bank *const omap_gpio_bank = gpio_bank_am33xx;
48 #ifdef CONFIG_SPL_BUILD
49 #define UART_RESET (0x1 << 1)
50 #define UART_CLK_RUNNING_MASK 0x1
51 #define UART_SMART_IDLE_EN (0x1 << 0x3)
54 #ifdef CONFIG_SPL_BUILD
55 /* Initialize timer */
56 static void init_timer(void)
59 writel(0x2, (&timer_base->tscir));
61 /* Wait until the reset is done */
62 while (readl(&timer_base->tiocp_cfg) & 1)
66 writel(0x1, (&timer_base->tclr));
71 * early system init of muxing and clocks.
75 /* WDT1 is already running when the bootloader gets control
76 * Disable it to avoid "random" resets
78 writel(0xAAAA, &wdtimer->wdtwspr);
79 while (readl(&wdtimer->wdtwwps) != 0x0)
81 writel(0x5555, &wdtimer->wdtwspr);
82 while (readl(&wdtimer->wdtwwps) != 0x0)
85 #ifdef CONFIG_SPL_BUILD
86 /* Setup the PLLs and the clocks for the peripherals */
92 enable_uart0_pin_mux();
94 regVal = readl(&uart_base->uartsyscfg);
96 writel(regVal, &uart_base->uartsyscfg);
97 while ((readl(&uart_base->uartsyssts) &
98 UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK)
101 /* Disable smart idle */
102 regVal = readl(&uart_base->uartsyscfg);
103 regVal |= UART_SMART_IDLE_EN;
104 writel(regVal, &uart_base->uartsyscfg);
106 /* Initialize the Timer */
109 preloader_console_init();
111 config_ddr(EMIF_REG_SDRAM_TYPE_DDR2);
115 enable_mmc0_pin_mux();
118 #if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
119 int board_mmc_init(bd_t *bis)
121 return omap_mmc_init(0, 0, 0);
125 void setup_clocks_for_console(void)
127 /* Not yet implemented */