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