blob: f75f2dc634c758af2b48cbee04558bf018cd9a24 [file] [log] [blame]
Jagan Teki35049fe2021-04-26 18:23:48 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2020 Engicam s.r.l.
4 * Copyright (C) 2020 Amarula Solutions(India)
5 * Author: Jagan Teki <jagan@amarulasolutions.com>
6 */
7
8#include <common.h>
9#include <hang.h>
10#include <init.h>
11#include <log.h>
12#include <spl.h>
13#include <asm/mach-imx/iomux-v3.h>
14#include <asm/arch/clock.h>
15#include <asm/arch/imx8mm_pins.h>
16#include <asm/arch/sys_proto.h>
17#include <asm/mach-imx/boot_mode.h>
18#include <asm/arch/ddr.h>
19
20DECLARE_GLOBAL_DATA_PTR;
21
22int spl_board_boot_device(enum boot_device boot_dev_spl)
23{
24 switch (boot_dev_spl) {
25 case SD1_BOOT:
26 case SD2_BOOT:
27 case MMC2_BOOT:
28 return BOOT_DEVICE_MMC1;
29 case SD3_BOOT:
30 case MMC3_BOOT:
31 return BOOT_DEVICE_MMC2;
32 default:
33 return BOOT_DEVICE_NONE;
34 }
35}
36
37static void spl_dram_init(void)
38{
39 ddr_init(&dram_timing);
40}
41
42void spl_board_init(void)
43{
44 debug("Normal Boot\n");
45}
46
47#ifdef CONFIG_SPL_LOAD_FIT
48int board_fit_config_name_match(const char *name)
49{
50 /* Just empty function now - can't decide what to choose */
51 debug("%s: %s\n", __func__, name);
52
53 return 0;
54}
55#endif
56
Jagan Teki35049fe2021-04-26 18:23:48 +053057#define WDOG_PAD_CTRL (PAD_CTL_DSE6 | PAD_CTL_ODE | PAD_CTL_PUE | PAD_CTL_PE)
58
Jagan Teki35049fe2021-04-26 18:23:48 +053059int board_early_init_f(void)
60{
Peng Fan9f777272022-06-11 20:20:57 +080061 return 0;
Jagan Teki35049fe2021-04-26 18:23:48 +053062}
63
64void board_init_f(ulong dummy)
65{
66 int ret;
67
68 arch_cpu_init();
69
70 init_uart_clk(1);
71
72 board_early_init_f();
73
74 timer_init();
75
Jagan Teki35049fe2021-04-26 18:23:48 +053076 /* Clear the BSS. */
77 memset(__bss_start, 0, __bss_end - __bss_start);
78
79 ret = spl_early_init();
80 if (ret) {
81 debug("spl_early_init() failed: %d\n", ret);
82 hang();
83 }
84
Peng Fan9f777272022-06-11 20:20:57 +080085 preloader_console_init();
86
Jagan Teki35049fe2021-04-26 18:23:48 +053087 enable_tzc380();
88
89 /* DDR initialization */
90 spl_dram_init();
91
92 board_init_r(NULL, 0);
93}