blob: c6ae73d600be280188b1ac679437aeb323717b54 [file] [log] [blame]
Tom Rini4549e782018-05-06 18:27:01 -04001// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
Patrick Delaunay2514c2d2018-03-12 10:46:10 +01002/*
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
Patrick Delaunay2514c2d2018-03-12 10:46:10 +01004 */
5
6#include <common.h>
7#include <dm.h>
8#include <spl.h>
Patrick Delaunay11dfd1a2018-03-20 10:54:54 +01009#include <asm/io.h>
Patrick Delaunay2514c2d2018-03-12 10:46:10 +010010
11u32 spl_boot_device(void)
12{
Patrick Delaunay11dfd1a2018-03-20 10:54:54 +010013 u32 boot_mode;
14
Patrick Delaunay7f63c1e2019-02-27 17:01:12 +010015 boot_mode = get_bootmode();
Patrick Delaunay11dfd1a2018-03-20 10:54:54 +010016
17 switch (boot_mode) {
18 case BOOT_FLASH_SD_1:
19 case BOOT_FLASH_EMMC_1:
20 return BOOT_DEVICE_MMC1;
21 case BOOT_FLASH_SD_2:
22 case BOOT_FLASH_EMMC_2:
23 return BOOT_DEVICE_MMC2;
Patrick Delaunay7f63c1e2019-02-27 17:01:12 +010024 case BOOT_SERIAL_UART_1:
25 case BOOT_SERIAL_UART_2:
26 case BOOT_SERIAL_UART_3:
27 case BOOT_SERIAL_UART_4:
28 case BOOT_SERIAL_UART_5:
29 case BOOT_SERIAL_UART_6:
30 case BOOT_SERIAL_UART_7:
31 case BOOT_SERIAL_UART_8:
32 return BOOT_DEVICE_UART;
33 case BOOT_SERIAL_USB_OTG:
34 return BOOT_DEVICE_USB;
35 case BOOT_FLASH_NAND_FMC:
36 return BOOT_DEVICE_NAND;
37 case BOOT_FLASH_NOR_QSPI:
38 return BOOT_DEVICE_SPI;
Patrick Delaunay11dfd1a2018-03-20 10:54:54 +010039 }
40
Patrick Delaunay2514c2d2018-03-12 10:46:10 +010041 return BOOT_DEVICE_MMC1;
42}
43
44u32 spl_boot_mode(const u32 boot_device)
45{
46 return MMCSD_MODE_RAW;
47}
48
Patrick Delaunay11dfd1a2018-03-20 10:54:54 +010049int spl_boot_partition(const u32 boot_device)
50{
51 switch (boot_device) {
52 case BOOT_DEVICE_MMC1:
53 return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
54 case BOOT_DEVICE_MMC2:
55 return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2;
56 default:
57 return -EINVAL;
58 }
59}
60
Patrick Delaunay2514c2d2018-03-12 10:46:10 +010061void board_init_f(ulong dummy)
62{
63 struct udevice *dev;
64 int ret;
65
66 arch_cpu_init();
67
68 ret = spl_early_init();
69 if (ret) {
70 debug("spl_early_init() failed: %d\n", ret);
71 hang();
72 }
73
74 ret = uclass_get_device(UCLASS_CLK, 0, &dev);
75 if (ret) {
76 debug("Clock init failed: %d\n", ret);
77 return;
78 }
79
80 ret = uclass_get_device(UCLASS_RESET, 0, &dev);
81 if (ret) {
82 debug("Reset init failed: %d\n", ret);
83 return;
84 }
85
86 ret = uclass_get_device(UCLASS_PINCTRL, 0, &dev);
87 if (ret) {
88 debug("%s: Cannot find pinctrl device\n", __func__);
89 return;
90 }
91
92 /* enable console uart printing */
93 preloader_console_init();
94
95 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
96 if (ret) {
97 debug("DRAM init failed: %d\n", ret);
98 return;
99 }
100}