blob: 790973e8b6e9101bcfb9a10f896f36c68776c8cc [file] [log] [blame]
Tom Rini8b0c8a12018-05-06 18:27:01 -04001// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
Patrick Delaunay85b53972018-03-12 10:46:10 +01002/*
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
Patrick Delaunay85b53972018-03-12 10:46:10 +01004 */
5
6#include <common.h>
7#include <dm.h>
8#include <spl.h>
Patrick Delaunayfc69c682018-03-20 10:54:54 +01009#include <asm/io.h>
Patrick Delaunay85b53972018-03-12 10:46:10 +010010
11u32 spl_boot_device(void)
12{
Patrick Delaunayfc69c682018-03-20 10:54:54 +010013 u32 boot_mode;
14
15 boot_mode = (readl(TAMP_BOOT_CONTEXT) & TAMP_BOOT_MODE_MASK) >>
16 TAMP_BOOT_MODE_SHIFT;
Patrick Delaunayfc69c682018-03-20 10:54:54 +010017
18 switch (boot_mode) {
19 case BOOT_FLASH_SD_1:
20 case BOOT_FLASH_EMMC_1:
21 return BOOT_DEVICE_MMC1;
22 case BOOT_FLASH_SD_2:
23 case BOOT_FLASH_EMMC_2:
24 return BOOT_DEVICE_MMC2;
25 }
26
Patrick Delaunay85b53972018-03-12 10:46:10 +010027 return BOOT_DEVICE_MMC1;
28}
29
30u32 spl_boot_mode(const u32 boot_device)
31{
32 return MMCSD_MODE_RAW;
33}
34
Patrick Delaunayfc69c682018-03-20 10:54:54 +010035int spl_boot_partition(const u32 boot_device)
36{
37 switch (boot_device) {
38 case BOOT_DEVICE_MMC1:
39 return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
40 case BOOT_DEVICE_MMC2:
41 return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2;
42 default:
43 return -EINVAL;
44 }
45}
46
Patrick Delaunay85b53972018-03-12 10:46:10 +010047void board_init_f(ulong dummy)
48{
49 struct udevice *dev;
50 int ret;
51
52 arch_cpu_init();
53
54 ret = spl_early_init();
55 if (ret) {
56 debug("spl_early_init() failed: %d\n", ret);
57 hang();
58 }
59
60 ret = uclass_get_device(UCLASS_CLK, 0, &dev);
61 if (ret) {
62 debug("Clock init failed: %d\n", ret);
63 return;
64 }
65
66 ret = uclass_get_device(UCLASS_RESET, 0, &dev);
67 if (ret) {
68 debug("Reset init failed: %d\n", ret);
69 return;
70 }
71
72 ret = uclass_get_device(UCLASS_PINCTRL, 0, &dev);
73 if (ret) {
74 debug("%s: Cannot find pinctrl device\n", __func__);
75 return;
76 }
77
78 /* enable console uart printing */
79 preloader_console_init();
80
81 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
82 if (ret) {
83 debug("DRAM init failed: %d\n", ret);
84 return;
85 }
86}