blob: 0d37ce83c8418a70d4d541db4e0899a4b9a1a9f1 [file] [log] [blame]
Allen Martine60ab6e2012-08-31 08:30:09 +00001/*
2 * (C) Copyright 2012
3 * NVIDIA Inc, <www.nvidia.com>
4 *
5 * Allen Martin <amartin@nvidia.com>
6 *
7 * See file CREDITS for list of people who contributed to this
8 * project.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25#include <common.h>
26#include <asm/u-boot.h>
27#include <asm/utils.h>
Allen Martine60ab6e2012-08-31 08:30:09 +000028#include <nand.h>
29#include <mmc.h>
30#include <fat.h>
31#include <version.h>
32#include <i2c.h>
33#include <image.h>
34#include <malloc.h>
35#include <linux/compiler.h>
Allen Martine60ab6e2012-08-31 08:30:09 +000036#include "cpu.h"
37
38#include <asm/io.h>
Allen Martine60ab6e2012-08-31 08:30:09 +000039#include <asm/arch/clock.h>
Allen Martine60ab6e2012-08-31 08:30:09 +000040#include <asm/arch/pinmux.h>
Tom Warrenab371962012-09-19 15:50:56 -070041#include <asm/arch/tegra.h>
Lucas Stache80f7ca2012-09-29 10:02:08 +000042#include <asm/arch-tegra/board.h>
Tom Warrenab371962012-09-19 15:50:56 -070043#include <asm/arch-tegra/clk_rst.h>
44#include <asm/arch-tegra/pmc.h>
45#include <asm/arch-tegra/scu.h>
46#include <asm/arch-tegra/sys_proto.h>
Allen Martine60ab6e2012-08-31 08:30:09 +000047
48DECLARE_GLOBAL_DATA_PTR;
49
50/* Define global data structure pointer to it*/
51static gd_t gdata __attribute__ ((section(".data")));
52static bd_t bdata __attribute__ ((section(".data")));
53
54inline void hang(void)
55{
56 puts("### ERROR ### Please RESET the board ###\n");
57 for (;;)
58 ;
59}
60
61void board_init_f(ulong dummy)
62{
63 board_init_uart_f();
64
65 /* Initialize periph GPIOs */
Allen Martine60ab6e2012-08-31 08:30:09 +000066 gpio_early_init_uart();
Allen Martine60ab6e2012-08-31 08:30:09 +000067
68 /*
69 * We call relocate_code() with relocation target same as the
70 * CONFIG_SYS_SPL_TEXT_BASE. This will result in relocation getting
71 * skipped. Instead, only .bss initialization will happen. That's
72 * all we need
73 */
74 debug(">>board_init_f()\n");
75 relocate_code(CONFIG_SPL_STACK, &gdata, CONFIG_SPL_TEXT_BASE);
76}
77
78/* This requires UART clocks to be enabled */
79static void preloader_console_init(void)
80{
81 const char *u_boot_rev = U_BOOT_VERSION;
82
83 gd = &gdata;
84 gd->bd = &bdata;
85 gd->flags |= GD_FLG_RELOC;
86 gd->baudrate = CONFIG_BAUDRATE;
87
88 serial_init(); /* serial communications setup */
89
90 gd->have_console = 1;
91
92 /* Avoid a second "U-Boot" coming from this string */
93 u_boot_rev = &u_boot_rev[7];
94
95 printf("\nU-Boot SPL %s (%s - %s)\n", u_boot_rev, U_BOOT_DATE,
96 U_BOOT_TIME);
97}
98
99void board_init_r(gd_t *id, ulong dummy)
100{
101 struct pmux_tri_ctlr *pmt = (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
102
103 /* enable JTAG */
104 writel(0xC0, &pmt->pmt_cfg_ctl);
105
106 debug(">>spl:board_init_r()\n");
107
108 mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
109 CONFIG_SYS_SPL_MALLOC_SIZE);
110
111#ifdef CONFIG_SPL_BOARD_INIT
112 spl_board_init();
113#endif
114
115 clock_early_init();
116 serial_init();
117 preloader_console_init();
118
119 start_cpu((u32)CONFIG_SYS_TEXT_BASE);
120 halt_avp();
121 /* not reached */
122}
123
124int board_usb_init(const void *blob)
125{
126 return 0;
127}