blob: 01a63c69641fa1cf275397c2f81701e07cf64197 [file] [log] [blame]
Ariel D'Alessandrob6d5e132021-11-23 13:33:30 -03001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2021 Collabora Ltd.
4 *
5 */
6
7#include <hang.h>
8#include <init.h>
9#include <spl.h>
10#include <asm/arch/clock.h>
11#include <asm/arch/ddr.h>
12#include <asm/arch/imx8mn_pins.h>
13#include <asm/arch/sys_proto.h>
14#include <asm/mach-imx/boot_mode.h>
15#include <asm/mach-imx/gpio.h>
Shiji Yangbb112342023-08-03 09:47:16 +080016#include <asm/sections.h>
Ariel D'Alessandrob6d5e132021-11-23 13:33:30 -030017#include <dm/device.h>
18#include <dm/uclass.h>
19
20int spl_board_boot_device(enum boot_device boot_dev_spl)
21{
22 return BOOT_DEVICE_BOOTROM;
23}
24
25void spl_dram_init(void)
26{
27 ddr_init(&dram_timing);
28}
29
30void spl_board_init(void)
31{
32 struct udevice *dev;
33 int ret;
34
35 debug("Normal Boot\n");
36
37 ret = uclass_get_device_by_name(UCLASS_CLK,
38 "clock-controller@30380000",
39 &dev);
40 if (ret < 0)
41 puts("Failed to find clock node. Check device tree\n");
42}
43
Ariel D'Alessandrob6d5e132021-11-23 13:33:30 -030044int board_early_init_f(void)
45{
Ariel D'Alessandrob6d5e132021-11-23 13:33:30 -030046 init_uart_clk(3);
47
48 return 0;
49}
50
51void board_init_f(ulong dummy)
52{
53 int ret;
54
55 /* Clear the BSS. */
56 memset(__bss_start, 0, __bss_end - __bss_start);
57
58 arch_cpu_init();
59
60 board_early_init_f();
61
62 timer_init();
63
Ariel D'Alessandrob6d5e132021-11-23 13:33:30 -030064 ret = spl_init();
65 if (ret) {
66 debug("spl_init() failed: %d\n", ret);
67 hang();
68 }
69
Peng Fana1190932022-06-11 20:20:59 +080070 preloader_console_init();
71
Ariel D'Alessandrob6d5e132021-11-23 13:33:30 -030072 /* DDR initialization */
73 spl_dram_init();
74
75 board_init_r(NULL, 0);
76}