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