1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2014-2016 Stefan Roese <sr@denx.de>
8 #include <debug_uart.h>
13 #include <asm/arch/cpu.h>
14 #include <asm/arch/soc.h>
16 static u32 get_boot_device(void)
22 * First check, if UART boot-mode is active. This can only
23 * be done, via the bootrom error register. Here the
24 * MSB marks if the UART mode is active.
26 val = readl(CONFIG_BOOTROM_ERR_REG);
27 boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
28 debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
29 if (boot_device == BOOTROM_ERR_MODE_UART)
30 return BOOT_DEVICE_UART;
32 #ifdef CONFIG_ARMADA_38X
34 * If the bootrom error code contains any other than zeros it's an
35 * error condition and the bootROM has fallen back to UART boot
37 boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
39 return BOOT_DEVICE_UART;
43 * Now check the SAR register for the strapped boot-device
45 val = readl(CONFIG_SAR_REG); /* SAR - Sample At Reset */
46 boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS;
47 debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device);
48 switch (boot_device) {
49 #if defined(CONFIG_ARMADA_38X)
51 return BOOT_DEVICE_NAND;
53 #ifdef CONFIG_SPL_MMC_SUPPORT
55 case BOOT_FROM_MMC_ALT:
56 return BOOT_DEVICE_MMC1;
59 #ifdef BOOT_FROM_UART_ALT
60 case BOOT_FROM_UART_ALT:
62 return BOOT_DEVICE_UART;
65 case BOOT_FROM_SATA_ALT:
66 return BOOT_DEVICE_SATA;
70 return BOOT_DEVICE_SPI;
74 u32 spl_boot_device(void)
76 return get_boot_device();
79 void board_init_f(ulong dummy)
84 * Pin muxing needs to be done before UART output, since
85 * on A38x the UART pins need some re-muxing for output
90 /* Example code showing how to enable the debug UART on MVEBU */
93 * Debug UART can be used from here if required:
98 * printascii("string");
103 * Use special translation offset for SPL. This needs to be
104 * configured *before* spl_init() is called as this function
105 * calls dm_init() which calls the bind functions of the
106 * device drivers. Here the base address needs to be configured
107 * (translated) correctly.
109 gd->translation_offset = 0xd0000000 - 0xf1000000;
113 debug("spl_init() failed: %d\n", ret);
117 preloader_console_init();
121 /* Armada 375 does not support SerDes and DDR3 init yet */
122 #if !defined(CONFIG_ARMADA_375)
123 /* First init the serdes PHY's */
130 /* Initialize Auto Voltage Scaling */
134 * Return to the BootROM to continue the Marvell xmodem
135 * UART boot protocol. As initiated by the kwboot tool.
137 * This can only be done by the BootROM and not by the
138 * U-Boot SPL infrastructure, since the beginning of the
139 * image is already read and interpreted by the BootROM.
140 * SPL has no chance to receive this information. So we
141 * need to return to the BootROM to enable this xmodem
144 * If booting from NAND lets let the BootROM load the
145 * rest of the bootloader.
147 switch (get_boot_device()) {
148 case BOOT_DEVICE_UART:
149 #if defined(CONFIG_ARMADA_38X)
150 case BOOT_DEVICE_NAND: