blob: 6c16dce299dd94e9e4b377534dffe4879ec08fdf [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>
28#include <asm/arch/sys_proto.h>
29#include <asm/arch/clock.h>
30#include <nand.h>
31#include <mmc.h>
32#include <fat.h>
33#include <version.h>
34#include <i2c.h>
35#include <image.h>
36#include <malloc.h>
37#include <linux/compiler.h>
38#include "board.h"
39#include "cpu.h"
40
41#include <asm/io.h>
42#include <asm/arch/tegra20.h>
43#include <asm/arch/clk_rst.h>
44#include <asm/arch/clock.h>
45#include <asm/arch/pmc.h>
46#include <asm/arch/pinmux.h>
47#include <asm/arch/scu.h>
48#include <common.h>
49
50DECLARE_GLOBAL_DATA_PTR;
51
52/* Define global data structure pointer to it*/
53static gd_t gdata __attribute__ ((section(".data")));
54static bd_t bdata __attribute__ ((section(".data")));
55
56inline void hang(void)
57{
58 puts("### ERROR ### Please RESET the board ###\n");
59 for (;;)
60 ;
61}
62
63void board_init_f(ulong dummy)
64{
65 board_init_uart_f();
66
67 /* Initialize periph GPIOs */
68#ifdef CONFIG_SPI_UART_SWITCH
69 gpio_early_init_uart();
70#else
71 gpio_config_uart();
72#endif
73
74 /*
75 * We call relocate_code() with relocation target same as the
76 * CONFIG_SYS_SPL_TEXT_BASE. This will result in relocation getting
77 * skipped. Instead, only .bss initialization will happen. That's
78 * all we need
79 */
80 debug(">>board_init_f()\n");
81 relocate_code(CONFIG_SPL_STACK, &gdata, CONFIG_SPL_TEXT_BASE);
82}
83
84/* This requires UART clocks to be enabled */
85static void preloader_console_init(void)
86{
87 const char *u_boot_rev = U_BOOT_VERSION;
88
89 gd = &gdata;
90 gd->bd = &bdata;
91 gd->flags |= GD_FLG_RELOC;
92 gd->baudrate = CONFIG_BAUDRATE;
93
94 serial_init(); /* serial communications setup */
95
96 gd->have_console = 1;
97
98 /* Avoid a second "U-Boot" coming from this string */
99 u_boot_rev = &u_boot_rev[7];
100
101 printf("\nU-Boot SPL %s (%s - %s)\n", u_boot_rev, U_BOOT_DATE,
102 U_BOOT_TIME);
103}
104
105void board_init_r(gd_t *id, ulong dummy)
106{
107 struct pmux_tri_ctlr *pmt = (struct pmux_tri_ctlr *)NV_PA_APB_MISC_BASE;
108
109 /* enable JTAG */
110 writel(0xC0, &pmt->pmt_cfg_ctl);
111
112 debug(">>spl:board_init_r()\n");
113
114 mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
115 CONFIG_SYS_SPL_MALLOC_SIZE);
116
117#ifdef CONFIG_SPL_BOARD_INIT
118 spl_board_init();
119#endif
120
121 clock_early_init();
122 serial_init();
123 preloader_console_init();
124
125 start_cpu((u32)CONFIG_SYS_TEXT_BASE);
126 halt_avp();
127 /* not reached */
128}
129
130int board_usb_init(const void *blob)
131{
132 return 0;
133}