blob: 71309a7f479a587324165f794943d146b03ee264 [file] [log] [blame]
Chandan Nath5289e832011-10-14 02:58:26 +00001/*
2 * board.c
3 *
4 * Common board functions for AM33XX based boards
5 *
6 * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
7 *
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.
12 *
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.
17 */
18
19#include <common.h>
20#include <asm/arch/cpu.h>
21#include <asm/arch/hardware.h>
Chandan Nath8a8f0842012-01-09 20:38:59 +000022#include <asm/arch/omap.h>
Chandan Nath5289e832011-10-14 02:58:26 +000023#include <asm/arch/ddr_defs.h>
24#include <asm/arch/clock.h>
Chandan Nath8a8f0842012-01-09 20:38:59 +000025#include <asm/arch/mmc_host_def.h>
26#include <asm/arch/common_def.h>
Chandan Nath5289e832011-10-14 02:58:26 +000027#include <asm/io.h>
Chandan Nath8a8f0842012-01-09 20:38:59 +000028#include <asm/omap_common.h>
Chandan Nath5289e832011-10-14 02:58:26 +000029
30DECLARE_GLOBAL_DATA_PTR;
31
32struct wd_timer *wdtimer = (struct wd_timer *)WDT_BASE;
Chandan Nathfb072a32012-01-09 20:38:56 +000033struct gptimer *timer_base = (struct gptimer *)CONFIG_SYS_TIMERBASE;
Chandan Nath8a8f0842012-01-09 20:38:59 +000034struct uart_sys *uart_base = (struct uart_sys *)DEFAULT_UART_BASE;
35
36/* UART Defines */
37#ifdef CONFIG_SPL_BUILD
38#define UART_RESET (0x1 << 1)
39#define UART_CLK_RUNNING_MASK 0x1
40#define UART_SMART_IDLE_EN (0x1 << 0x3)
41#endif
Chandan Nath5289e832011-10-14 02:58:26 +000042
Tom Rini2ab28102012-05-14 12:38:18 +000043#ifdef CONFIG_SPL_BUILD
44/* Initialize timer */
45static void init_timer(void)
46{
47 /* Reset the Timer */
48 writel(0x2, (&timer_base->tscir));
49
50 /* Wait until the reset is done */
51 while (readl(&timer_base->tiocp_cfg) & 1)
52 ;
53
54 /* Start the Timer */
55 writel(0x1, (&timer_base->tclr));
56}
57#endif
58
Chandan Nath5289e832011-10-14 02:58:26 +000059/*
60 * early system init of muxing and clocks.
61 */
Chandan Nath8a8f0842012-01-09 20:38:59 +000062void s_init(void)
Chandan Nath5289e832011-10-14 02:58:26 +000063{
64 /* WDT1 is already running when the bootloader gets control
65 * Disable it to avoid "random" resets
66 */
67 writel(0xAAAA, &wdtimer->wdtwspr);
68 while (readl(&wdtimer->wdtwwps) != 0x0)
69 ;
70 writel(0x5555, &wdtimer->wdtwspr);
71 while (readl(&wdtimer->wdtwwps) != 0x0)
72 ;
73
Chandan Nath8a8f0842012-01-09 20:38:59 +000074#ifdef CONFIG_SPL_BUILD
Chandan Nath5289e832011-10-14 02:58:26 +000075 /* Setup the PLLs and the clocks for the peripherals */
Chandan Nath5289e832011-10-14 02:58:26 +000076 pll_init();
Chandan Nath8a8f0842012-01-09 20:38:59 +000077
78 /* UART softreset */
79 u32 regVal;
80
81 enable_uart0_pin_mux();
82
83 regVal = readl(&uart_base->uartsyscfg);
84 regVal |= UART_RESET;
85 writel(regVal, &uart_base->uartsyscfg);
86 while ((readl(&uart_base->uartsyssts) &
87 UART_CLK_RUNNING_MASK) != UART_CLK_RUNNING_MASK)
88 ;
89
90 /* Disable smart idle */
91 regVal = readl(&uart_base->uartsyscfg);
92 regVal |= UART_SMART_IDLE_EN;
93 writel(regVal, &uart_base->uartsyscfg);
94
95 /* Initialize the Timer */
96 init_timer();
97
98 preloader_console_init();
99
100 config_ddr();
Chandan Nath5289e832011-10-14 02:58:26 +0000101#endif
Chandan Nath8a8f0842012-01-09 20:38:59 +0000102
103 /* Enable MMC0 */
104 enable_mmc0_pin_mux();
Chandan Nath5289e832011-10-14 02:58:26 +0000105}
106
Chandan Nath876bdd62012-01-09 20:38:58 +0000107#if defined(CONFIG_OMAP_HSMMC) && !defined(CONFIG_SPL_BUILD)
108int board_mmc_init(bd_t *bis)
109{
Jonathan Solnitbbbc1ae2012-02-24 11:30:18 +0000110 return omap_mmc_init(0, 0, 0);
Chandan Nath876bdd62012-01-09 20:38:58 +0000111}
112#endif
Chandan Nath8a8f0842012-01-09 20:38:59 +0000113
114void setup_clocks_for_console(void)
115{
116 /* Not yet implemented */
117 return;
118}