2 * Copyright (C) 2014-2016 Stefan Roese <sr@denx.de>
4 * SPDX-License-Identifier: GPL-2.0+
9 #include <debug_uart.h>
13 #include <asm/arch/cpu.h>
14 #include <asm/arch/soc.h>
16 DECLARE_GLOBAL_DATA_PTR;
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;
35 * Now check the SAR register for the strapped boot-device
37 val = readl(CONFIG_SAR_REG); /* SAR - Sample At Reset */
38 boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS;
39 debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device);
40 switch (boot_device) {
41 #ifdef CONFIG_SPL_MMC_SUPPORT
43 case BOOT_FROM_MMC_ALT:
44 return BOOT_DEVICE_MMC1;
47 return BOOT_DEVICE_UART;
50 return BOOT_DEVICE_SPI;
54 u32 spl_boot_device(void)
56 return get_boot_device();
59 #ifdef CONFIG_SPL_MMC_SUPPORT
60 u32 spl_boot_mode(const u32 boot_device)
62 return MMCSD_MODE_RAW;
66 void board_init_f(ulong dummy)
71 * Pin muxing needs to be done before UART output, since
72 * on A38x the UART pins need some re-muxing for output
77 /* Example code showing how to enable the debug UART on MVEBU */
80 * Debug UART can be used from here if required:
85 * printascii("string");
91 debug("spl_init() failed: %d\n", ret);
95 /* Use special translation offset for SPL */
96 dm_set_translation_offset(0xd0000000 - 0xf1000000);
98 preloader_console_init();
102 /* Armada 375 does not support SerDes and DDR3 init yet */
103 #if !defined(CONFIG_ARMADA_375)
104 /* First init the serdes PHY's */
112 * Return to the BootROM to continue the Marvell xmodem
113 * UART boot protocol. As initiated by the kwboot tool.
115 * This can only be done by the BootROM and not by the
116 * U-Boot SPL infrastructure, since the beginning of the
117 * image is already read and interpreted by the BootROM.
118 * SPL has no chance to receive this information. So we
119 * need to return to the BootROM to enable this xmodem
122 if (get_boot_device() == BOOT_DEVICE_UART)