]> git.sur5r.net Git - u-boot/blob - arch/arm/mach-mvebu/spl.c
778996eff54b78e3f2d85325a7a91246b46e0649
[u-boot] / arch / arm / mach-mvebu / spl.c
1 /*
2  * Copyright (C) 2014-2016 Stefan Roese <sr@denx.de>
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #include <common.h>
8 #include <dm.h>
9 #include <debug_uart.h>
10 #include <fdtdec.h>
11 #include <spl.h>
12 #include <asm/io.h>
13 #include <asm/arch/cpu.h>
14 #include <asm/arch/soc.h>
15
16 DECLARE_GLOBAL_DATA_PTR;
17
18 static u32 get_boot_device(void)
19 {
20         u32 val;
21         u32 boot_device;
22
23         val = readl(CONFIG_SAR_REG);    /* SAR - Sample At Reset */
24         boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS;
25         switch (boot_device) {
26 #ifdef CONFIG_SPL_MMC_SUPPORT
27         case BOOT_FROM_MMC:
28         case BOOT_FROM_MMC_ALT:
29                 return BOOT_DEVICE_MMC1;
30 #endif
31         case BOOT_FROM_UART:
32                 return BOOT_DEVICE_UART;
33         case BOOT_FROM_SPI:
34         default:
35                 return BOOT_DEVICE_SPI;
36         };
37 }
38
39 u32 spl_boot_device(void)
40 {
41         return get_boot_device();
42 }
43
44 #ifdef CONFIG_SPL_MMC_SUPPORT
45 u32 spl_boot_mode(void)
46 {
47         return MMCSD_MODE_RAW;
48 }
49 #endif
50
51 void board_init_f(ulong dummy)
52 {
53         int ret;
54
55         /*
56          * Pin muxing needs to be done before UART output, since
57          * on A38x the UART pins need some re-muxing for output
58          * to work.
59          */
60         board_early_init_f();
61
62         /* Example code showing how to enable the debug UART on MVEBU */
63 #ifdef EARLY_UART
64         /*
65          * Debug UART can be used from here if required:
66          *
67          * debug_uart_init();
68          * printch('a');
69          * printhex8(0x1234);
70          * printascii("string");
71          */
72 #endif
73
74         ret = spl_init();
75         if (ret) {
76                 debug("spl_init() failed: %d\n", ret);
77                 hang();
78         }
79
80         /* Use special translation offset for SPL */
81         dm_set_translation_offset(0xd0000000 - 0xf1000000);
82
83         preloader_console_init();
84
85         timer_init();
86
87         /* First init the serdes PHY's */
88         serdes_phy_config();
89
90         /* Setup DDR */
91         ddr3_init();
92
93 #ifdef CONFIG_MVEBU_BOOTROM_UARTBOOT
94         /*
95          * Return to the BootROM to continue the Marvell xmodem
96          * UART boot protocol. As initiated by the kwboot tool.
97          *
98          * This can only be done by the BootROM and not by the
99          * U-Boot SPL infrastructure, since the beginning of the
100          * image is already read and interpreted by the BootROM.
101          * SPL has no chance to receive this information. So we
102          * need to return to the BootROM to enable this xmodem
103          * UART download.
104          */
105         return_to_bootrom();
106 #endif
107 }