arm: mvebu: Add DM and OF_CONTROL support to SPL
[oweals/u-boot.git] / arch / arm / mach-mvebu / spl.c
1 /*
2  * Copyright (C) 2014-2015 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 u32 spl_boot_device(void)
19 {
20 #if defined(CONFIG_SPL_SPI_FLASH_SUPPORT)
21         return BOOT_DEVICE_SPI;
22 #endif
23 #if defined(CONFIG_SPL_MMC_SUPPORT)
24         return BOOT_DEVICE_MMC1;
25 #endif
26 }
27
28 #ifdef CONFIG_SPL_MMC_SUPPORT
29 u32 spl_boot_mode(void)
30 {
31         return MMCSD_MODE_RAW;
32 }
33 #endif
34
35 void board_init_f(ulong dummy)
36 {
37         int ret;
38
39 #ifndef CONFIG_MVEBU_BOOTROM_UARTBOOT
40         /*
41          * Only call arch_cpu_init() when not returning to the
42          * Marvell BootROM, which is done when booting via
43          * the xmodem protocol (kwboot tool). Otherwise the
44          * internal register will get remapped and the BootROM
45          * can't continue to run correctly.
46          */
47
48         /* Linux expects the internal registers to be at 0xf1000000 */
49         arch_cpu_init();
50 #endif
51
52         /*
53          * Pin muxing needs to be done before UART output, since
54          * on A38x the UART pins need some re-muxing for output
55          * to work.
56          */
57         board_early_init_f();
58
59         /* Example code showing how to enable the debug UART on MVEBU */
60 #ifdef EARLY_UART
61         /*
62          * Debug UART can be used from here if required:
63          *
64          * debug_uart_init();
65          * printch('a');
66          * printhex8(0x1234);
67          * printascii("string");
68          */
69 #endif
70
71         ret = spl_init();
72         if (ret) {
73                 debug("spl_init() failed: %d\n", ret);
74                 hang();
75         }
76
77         /* Use special translation offset for SPL */
78         dm_set_translation_offset(0xd0000000 - 0xf1000000);
79
80         preloader_console_init();
81
82         timer_init();
83
84         /* First init the serdes PHY's */
85         serdes_phy_config();
86
87         /* Setup DDR */
88         ddr3_init();
89
90 #ifdef CONFIG_MVEBU_BOOTROM_UARTBOOT
91         /*
92          * Return to the BootROM to continue the Marvell xmodem
93          * UART boot protocol. As initiated by the kwboot tool.
94          *
95          * This can only be done by the BootROM and not by the
96          * U-Boot SPL infrastructure, since the beginning of the
97          * image is already read and interpreted by the BootROM.
98          * SPL has no chance to receive this information. So we
99          * need to return to the BootROM to enable this xmodem
100          * UART download.
101          */
102         return_to_bootrom();
103 #endif
104 }