]> Git Repo - J-u-boot.git/blame - arch/arm/mach-stm32mp/spl.c
common: Drop init.h from common header
[J-u-boot.git] / arch / arm / mach-stm32mp / spl.c
CommitLineData
4549e789 1// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
2514c2d0
PD
2/*
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
2514c2d0
PD
4 */
5
6#include <common.h>
dc7e5f19 7#include <cpu_func.h>
2514c2d0 8#include <dm.h>
db41d65a 9#include <hang.h>
691d719d 10#include <init.h>
2514c2d0 11#include <spl.h>
90526e9f 12#include <asm/cache.h>
11dfd1a3 13#include <asm/io.h>
006ea189
PD
14#include <asm/arch/sys_proto.h>
15#include <linux/libfdt.h>
2514c2d0
PD
16
17u32 spl_boot_device(void)
18{
11dfd1a3
PD
19 u32 boot_mode;
20
7f63c1e6 21 boot_mode = get_bootmode();
11dfd1a3
PD
22
23 switch (boot_mode) {
24 case BOOT_FLASH_SD_1:
25 case BOOT_FLASH_EMMC_1:
26 return BOOT_DEVICE_MMC1;
27 case BOOT_FLASH_SD_2:
28 case BOOT_FLASH_EMMC_2:
29 return BOOT_DEVICE_MMC2;
7f63c1e6
PD
30 case BOOT_SERIAL_UART_1:
31 case BOOT_SERIAL_UART_2:
32 case BOOT_SERIAL_UART_3:
33 case BOOT_SERIAL_UART_4:
34 case BOOT_SERIAL_UART_5:
35 case BOOT_SERIAL_UART_6:
36 case BOOT_SERIAL_UART_7:
37 case BOOT_SERIAL_UART_8:
38 return BOOT_DEVICE_UART;
39 case BOOT_SERIAL_USB_OTG:
40 return BOOT_DEVICE_USB;
41 case BOOT_FLASH_NAND_FMC:
42 return BOOT_DEVICE_NAND;
43 case BOOT_FLASH_NOR_QSPI:
44 return BOOT_DEVICE_SPI;
b664a745
PD
45 case BOOT_FLASH_SPINAND_1:
46 return BOOT_DEVICE_NONE; /* SPINAND not supported in SPL */
11dfd1a3
PD
47 }
48
2514c2d0
PD
49 return BOOT_DEVICE_MMC1;
50}
51
e9759065 52u32 spl_mmc_boot_mode(const u32 boot_device)
2514c2d0
PD
53{
54 return MMCSD_MODE_RAW;
55}
56
c51b7518 57int spl_mmc_boot_partition(const u32 boot_device)
11dfd1a3
PD
58{
59 switch (boot_device) {
60 case BOOT_DEVICE_MMC1:
61 return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION;
62 case BOOT_DEVICE_MMC2:
63 return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2;
64 default:
65 return -EINVAL;
66 }
67}
68
006ea189
PD
69#ifdef CONFIG_SPL_DISPLAY_PRINT
70void spl_display_print(void)
71{
72 DECLARE_GLOBAL_DATA_PTR;
73 const char *model;
74
75 /* same code than show_board_info() but not compiled for SPL
76 * see CONFIG_DISPLAY_BOARDINFO & common/board_info.c
77 */
78 model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
79 if (model)
80 printf("Model: %s\n", model);
81}
82#endif
83
65e38e81
MV
84__weak int board_early_init_f(void)
85{
86 return 0;
87}
88
2514c2d0
PD
89void board_init_f(ulong dummy)
90{
91 struct udevice *dev;
92 int ret;
93
94 arch_cpu_init();
95
96 ret = spl_early_init();
97 if (ret) {
98 debug("spl_early_init() failed: %d\n", ret);
99 hang();
100 }
101
102 ret = uclass_get_device(UCLASS_CLK, 0, &dev);
103 if (ret) {
104 debug("Clock init failed: %d\n", ret);
eaec1f9e 105 hang();
2514c2d0
PD
106 }
107
108 ret = uclass_get_device(UCLASS_RESET, 0, &dev);
109 if (ret) {
110 debug("Reset init failed: %d\n", ret);
eaec1f9e 111 hang();
2514c2d0
PD
112 }
113
114 ret = uclass_get_device(UCLASS_PINCTRL, 0, &dev);
115 if (ret) {
116 debug("%s: Cannot find pinctrl device\n", __func__);
eaec1f9e 117 hang();
2514c2d0
PD
118 }
119
120 /* enable console uart printing */
121 preloader_console_init();
122
65e38e81
MV
123 ret = board_early_init_f();
124 if (ret) {
125 debug("board_early_init_f() failed: %d\n", ret);
126 hang();
127 }
128
2514c2d0
PD
129 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
130 if (ret) {
105a5ad6
PD
131 printf("DRAM init failed: %d\n", ret);
132 hang();
2514c2d0 133 }
dc7e5f19
PD
134
135 /*
136 * activate cache on DDR only when DDR is fully initialized
137 * to avoid speculative access and issue in get_ram_size()
138 */
139 if (!CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
140 mmu_set_region_dcache_behaviour(STM32_DDR_BASE, STM32_DDR_SIZE,
141 DCACHE_DEFAULT_OPTION);
142}
143
144void spl_board_prepare_for_boot(void)
145{
146 dcache_disable();
147}
148
149void spl_board_prepare_for_boot_linux(void)
150{
151 dcache_disable();
2514c2d0 152}
This page took 0.146083 seconds and 4 git commands to generate.