blob: b56f0c5381c3b5b8ffdddddb7305a61fcdceea29 [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
15 boot_mode = (readl(TAMP_BOOT_CONTEXT) & TAMP_BOOT_MODE_MASK) >>
16 TAMP_BOOT_MODE_SHIFT;
17 clrsetbits_le32(TAMP_BOOT_CONTEXT,
18 TAMP_BOOT_MODE_MASK,
19 boot_mode << TAMP_BOOT_MODE_SHIFT);
20
21 switch (boot_mode) {
22 case BOOT_FLASH_SD_1:
23 case BOOT_FLASH_EMMC_1:
24 return BOOT_DEVICE_MMC1;
25 case BOOT_FLASH_SD_2:
26 case BOOT_FLASH_EMMC_2:
27 return BOOT_DEVICE_MMC2;
28 }
29
Patrick Delaunay2514c2d2018-03-12 10:46:10 +010030 return BOOT_DEVICE_MMC1;
31}
32
33u32 spl_boot_mode(const u32 boot_device)
34{
35 return MMCSD_MODE_RAW;
36}
37
Patrick Delaunay11dfd1a2018-03-20 10:54:54 +010038int spl_boot_partition(const u32 boot_device)
39{
40 switch (boot_device) {
41 case BOOT_DEVICE_MMC1:
42 return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
43 case BOOT_DEVICE_MMC2:
44 return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2;
45 default:
46 return -EINVAL;
47 }
48}
49
Patrick Delaunay2514c2d2018-03-12 10:46:10 +010050void board_init_f(ulong dummy)
51{
52 struct udevice *dev;
53 int ret;
54
55 arch_cpu_init();
56
57 ret = spl_early_init();
58 if (ret) {
59 debug("spl_early_init() failed: %d\n", ret);
60 hang();
61 }
62
63 ret = uclass_get_device(UCLASS_CLK, 0, &dev);
64 if (ret) {
65 debug("Clock init failed: %d\n", ret);
66 return;
67 }
68
69 ret = uclass_get_device(UCLASS_RESET, 0, &dev);
70 if (ret) {
71 debug("Reset init failed: %d\n", ret);
72 return;
73 }
74
75 ret = uclass_get_device(UCLASS_PINCTRL, 0, &dev);
76 if (ret) {
77 debug("%s: Cannot find pinctrl device\n", __func__);
78 return;
79 }
80
81 /* enable console uart printing */
82 preloader_console_init();
83
84 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
85 if (ret) {
86 debug("DRAM init failed: %d\n", ret);
87 return;
88 }
89}