2018-05-06 22:27:01 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
|
2018-03-12 09:46:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018, STMicroelectronics - All Rights Reserved
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <spl.h>
|
2018-03-20 09:54:54 +00:00
|
|
|
#include <asm/io.h>
|
2018-03-12 09:46:10 +00:00
|
|
|
|
|
|
|
u32 spl_boot_device(void)
|
|
|
|
{
|
2018-03-20 09:54:54 +00:00
|
|
|
u32 boot_mode;
|
|
|
|
|
2019-02-27 16:01:12 +00:00
|
|
|
boot_mode = get_bootmode();
|
2018-03-20 09:54:54 +00:00
|
|
|
|
|
|
|
switch (boot_mode) {
|
|
|
|
case BOOT_FLASH_SD_1:
|
|
|
|
case BOOT_FLASH_EMMC_1:
|
|
|
|
return BOOT_DEVICE_MMC1;
|
|
|
|
case BOOT_FLASH_SD_2:
|
|
|
|
case BOOT_FLASH_EMMC_2:
|
|
|
|
return BOOT_DEVICE_MMC2;
|
2019-02-27 16:01:12 +00:00
|
|
|
case BOOT_SERIAL_UART_1:
|
|
|
|
case BOOT_SERIAL_UART_2:
|
|
|
|
case BOOT_SERIAL_UART_3:
|
|
|
|
case BOOT_SERIAL_UART_4:
|
|
|
|
case BOOT_SERIAL_UART_5:
|
|
|
|
case BOOT_SERIAL_UART_6:
|
|
|
|
case BOOT_SERIAL_UART_7:
|
|
|
|
case BOOT_SERIAL_UART_8:
|
|
|
|
return BOOT_DEVICE_UART;
|
|
|
|
case BOOT_SERIAL_USB_OTG:
|
|
|
|
return BOOT_DEVICE_USB;
|
|
|
|
case BOOT_FLASH_NAND_FMC:
|
|
|
|
return BOOT_DEVICE_NAND;
|
|
|
|
case BOOT_FLASH_NOR_QSPI:
|
|
|
|
return BOOT_DEVICE_SPI;
|
2018-03-20 09:54:54 +00:00
|
|
|
}
|
|
|
|
|
2018-03-12 09:46:10 +00:00
|
|
|
return BOOT_DEVICE_MMC1;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 spl_boot_mode(const u32 boot_device)
|
|
|
|
{
|
|
|
|
return MMCSD_MODE_RAW;
|
|
|
|
}
|
|
|
|
|
2018-03-20 09:54:54 +00:00
|
|
|
int spl_boot_partition(const u32 boot_device)
|
|
|
|
{
|
|
|
|
switch (boot_device) {
|
|
|
|
case BOOT_DEVICE_MMC1:
|
|
|
|
return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
|
|
|
|
case BOOT_DEVICE_MMC2:
|
|
|
|
return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-12 09:46:10 +00:00
|
|
|
void board_init_f(ulong dummy)
|
|
|
|
{
|
|
|
|
struct udevice *dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
arch_cpu_init();
|
|
|
|
|
|
|
|
ret = spl_early_init();
|
|
|
|
if (ret) {
|
|
|
|
debug("spl_early_init() failed: %d\n", ret);
|
|
|
|
hang();
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = uclass_get_device(UCLASS_CLK, 0, &dev);
|
|
|
|
if (ret) {
|
|
|
|
debug("Clock init failed: %d\n", ret);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = uclass_get_device(UCLASS_RESET, 0, &dev);
|
|
|
|
if (ret) {
|
|
|
|
debug("Reset init failed: %d\n", ret);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = uclass_get_device(UCLASS_PINCTRL, 0, &dev);
|
|
|
|
if (ret) {
|
|
|
|
debug("%s: Cannot find pinctrl device\n", __func__);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* enable console uart printing */
|
|
|
|
preloader_console_init();
|
|
|
|
|
|
|
|
ret = uclass_get_device(UCLASS_RAM, 0, &dev);
|
|
|
|
if (ret) {
|
|
|
|
debug("DRAM init failed: %d\n", ret);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|