1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2014-2016 Stefan Roese <sr@denx.de>
8 #include <debug_uart.h>
14 #include <asm/arch/cpu.h>
15 #include <asm/arch/soc.h>
17 static u32 get_boot_device(void)
23 * First check, if UART boot-mode is active. This can only
24 * be done, via the bootrom error register. Here the
25 * MSB marks if the UART mode is active.
27 val = readl(CONFIG_BOOTROM_ERR_REG);
28 boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
29 debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
30 if (boot_device == BOOTROM_ERR_MODE_UART)
31 return BOOT_DEVICE_UART;
33 #ifdef CONFIG_ARMADA_38X
35 * If the bootrom error code contains any other than zeros it's an
36 * error condition and the bootROM has fallen back to UART boot
38 boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
40 return BOOT_DEVICE_UART;
44 * Now check the SAR register for the strapped boot-device
46 val = readl(CONFIG_SAR_REG); /* SAR - Sample At Reset */
47 boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS;
48 debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device);
49 switch (boot_device) {
50 #if defined(CONFIG_ARMADA_38X)
52 return BOOT_DEVICE_NAND;
54 #ifdef CONFIG_SPL_MMC_SUPPORT
56 case BOOT_FROM_MMC_ALT:
57 return BOOT_DEVICE_MMC1;
60 #ifdef BOOT_FROM_UART_ALT
61 case BOOT_FROM_UART_ALT:
63 return BOOT_DEVICE_UART;
66 case BOOT_FROM_SATA_ALT:
67 return BOOT_DEVICE_SATA;
71 return BOOT_DEVICE_SPI;
75 u32 spl_boot_device(void)
77 return get_boot_device();
80 void board_init_f(ulong dummy)
85 * Pin muxing needs to be done before UART output, since
86 * on A38x the UART pins need some re-muxing for output
91 /* Example code showing how to enable the debug UART on MVEBU */
94 * Debug UART can be used from here if required:
99 * printascii("string");
104 * Use special translation offset for SPL. This needs to be
105 * configured *before* spl_init() is called as this function
106 * calls dm_init() which calls the bind functions of the
107 * device drivers. Here the base address needs to be configured
108 * (translated) correctly.
110 gd->translation_offset = 0xd0000000 - 0xf1000000;
114 debug("spl_init() failed: %d\n", ret);
118 preloader_console_init();
122 /* Armada 375 does not support SerDes and DDR3 init yet */
123 #if !defined(CONFIG_ARMADA_375)
124 /* First init the serdes PHY's */
131 /* Initialize Auto Voltage Scaling */
134 /* Update read timing control for PCIe */
138 * Return to the BootROM to continue the Marvell xmodem
139 * UART boot protocol. As initiated by the kwboot tool.
141 * This can only be done by the BootROM and not by the
142 * U-Boot SPL infrastructure, since the beginning of the
143 * image is already read and interpreted by the BootROM.
144 * SPL has no chance to receive this information. So we
145 * need to return to the BootROM to enable this xmodem
148 * If booting from NAND lets let the BootROM load the
149 * rest of the bootloader.
151 switch (get_boot_device()) {
152 case BOOT_DEVICE_UART:
153 #if defined(CONFIG_ARMADA_38X)
154 case BOOT_DEVICE_NAND: