1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2014-2016 Stefan Roese <sr@denx.de>
8 #include <debug_uart.h>
15 #include <asm/arch/cpu.h>
16 #include <asm/arch/soc.h>
18 static u32 get_boot_device(void)
24 * First check, if UART boot-mode is active. This can only
25 * be done, via the bootrom error register. Here the
26 * MSB marks if the UART mode is active.
28 val = readl(CONFIG_BOOTROM_ERR_REG);
29 boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
30 debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
31 if (boot_device == BOOTROM_ERR_MODE_UART)
32 return BOOT_DEVICE_UART;
34 #ifdef CONFIG_ARMADA_38X
36 * If the bootrom error code contains any other than zeros it's an
37 * error condition and the bootROM has fallen back to UART boot
39 boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
41 return BOOT_DEVICE_UART;
45 * Now check the SAR register for the strapped boot-device
47 val = readl(CONFIG_SAR_REG); /* SAR - Sample At Reset */
48 boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS;
49 debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device);
50 switch (boot_device) {
51 #if defined(CONFIG_ARMADA_38X)
53 return BOOT_DEVICE_NAND;
55 #ifdef CONFIG_SPL_MMC_SUPPORT
57 case BOOT_FROM_MMC_ALT:
58 return BOOT_DEVICE_MMC1;
61 #ifdef BOOT_FROM_UART_ALT
62 case BOOT_FROM_UART_ALT:
64 return BOOT_DEVICE_UART;
67 case BOOT_FROM_SATA_ALT:
68 return BOOT_DEVICE_SATA;
72 return BOOT_DEVICE_SPI;
76 u32 spl_boot_device(void)
78 return get_boot_device();
81 void board_init_f(ulong dummy)
86 * Pin muxing needs to be done before UART output, since
87 * on A38x the UART pins need some re-muxing for output
92 /* Example code showing how to enable the debug UART on MVEBU */
95 * Debug UART can be used from here if required:
100 * printascii("string");
105 * Use special translation offset for SPL. This needs to be
106 * configured *before* spl_init() is called as this function
107 * calls dm_init() which calls the bind functions of the
108 * device drivers. Here the base address needs to be configured
109 * (translated) correctly.
111 gd->translation_offset = 0xd0000000 - 0xf1000000;
115 debug("spl_init() failed: %d\n", ret);
119 preloader_console_init();
123 /* Armada 375 does not support SerDes and DDR3 init yet */
124 #if !defined(CONFIG_ARMADA_375)
125 /* First init the serdes PHY's */
132 /* Initialize Auto Voltage Scaling */
135 /* Update read timing control for PCIe */
139 * Return to the BootROM to continue the Marvell xmodem
140 * UART boot protocol. As initiated by the kwboot tool.
142 * This can only be done by the BootROM and not by the
143 * U-Boot SPL infrastructure, since the beginning of the
144 * image is already read and interpreted by the BootROM.
145 * SPL has no chance to receive this information. So we
146 * need to return to the BootROM to enable this xmodem
149 * If booting from NAND lets let the BootROM load the
150 * rest of the bootloader.
152 switch (get_boot_device()) {
153 case BOOT_DEVICE_UART:
154 #if defined(CONFIG_ARMADA_38X)
155 case BOOT_DEVICE_NAND: