1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2014-2016 Stefan Roese <sr@denx.de>
8 #include <debug_uart.h>
12 #include <asm/arch/cpu.h>
13 #include <asm/arch/soc.h>
15 static u32 get_boot_device(void)
21 * First check, if UART boot-mode is active. This can only
22 * be done, via the bootrom error register. Here the
23 * MSB marks if the UART mode is active.
25 val = readl(CONFIG_BOOTROM_ERR_REG);
26 boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
27 debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
28 if (boot_device == BOOTROM_ERR_MODE_UART)
29 return BOOT_DEVICE_UART;
31 #ifdef CONFIG_ARMADA_38X
33 * If the bootrom error code contains any other than zeros it's an
34 * error condition and the bootROM has fallen back to UART boot
36 boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
38 return BOOT_DEVICE_UART;
42 * Now check the SAR register for the strapped boot-device
44 val = readl(CONFIG_SAR_REG); /* SAR - Sample At Reset */
45 boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS;
46 debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device);
47 switch (boot_device) {
48 #if defined(CONFIG_ARMADA_38X)
50 return BOOT_DEVICE_NAND;
52 #ifdef CONFIG_SPL_MMC_SUPPORT
54 case BOOT_FROM_MMC_ALT:
55 return BOOT_DEVICE_MMC1;
58 #ifdef BOOT_FROM_UART_ALT
59 case BOOT_FROM_UART_ALT:
61 return BOOT_DEVICE_UART;
64 case BOOT_FROM_SATA_ALT:
65 return BOOT_DEVICE_SATA;
69 return BOOT_DEVICE_SPI;
73 u32 spl_boot_device(void)
75 return get_boot_device();
78 void board_init_f(ulong dummy)
83 * Pin muxing needs to be done before UART output, since
84 * on A38x the UART pins need some re-muxing for output
89 /* Example code showing how to enable the debug UART on MVEBU */
92 * Debug UART can be used from here if required:
97 * printascii("string");
102 * Use special translation offset for SPL. This needs to be
103 * configured *before* spl_init() is called as this function
104 * calls dm_init() which calls the bind functions of the
105 * device drivers. Here the base address needs to be configured
106 * (translated) correctly.
108 gd->translation_offset = 0xd0000000 - 0xf1000000;
112 debug("spl_init() failed: %d\n", ret);
116 preloader_console_init();
120 /* Armada 375 does not support SerDes and DDR3 init yet */
121 #if !defined(CONFIG_ARMADA_375)
122 /* First init the serdes PHY's */
129 /* Initialize Auto Voltage Scaling */
133 * Return to the BootROM to continue the Marvell xmodem
134 * UART boot protocol. As initiated by the kwboot tool.
136 * This can only be done by the BootROM and not by the
137 * U-Boot SPL infrastructure, since the beginning of the
138 * image is already read and interpreted by the BootROM.
139 * SPL has no chance to receive this information. So we
140 * need to return to the BootROM to enable this xmodem
143 * If booting from NAND lets let the BootROM load the
144 * rest of the bootloader.
146 switch (get_boot_device()) {
147 case BOOT_DEVICE_UART:
148 #if defined(CONFIG_ARMADA_38X)
149 case BOOT_DEVICE_NAND: