blob: 41e70505774d7f2f807ff9cbdeae9f58a191f143 [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>
16#include <dm/device.h>
17#include <dm/uclass.h>
18
19int spl_board_boot_device(enum boot_device boot_dev_spl)
20{
21 return BOOT_DEVICE_BOOTROM;
22}
23
24void spl_dram_init(void)
25{
26 ddr_init(&dram_timing);
27}
28
29void spl_board_init(void)
30{
31 struct udevice *dev;
32 int ret;
33
34 debug("Normal Boot\n");
35
36 ret = uclass_get_device_by_name(UCLASS_CLK,
37 "clock-controller@30380000",
38 &dev);
39 if (ret < 0)
40 puts("Failed to find clock node. Check device tree\n");
41}
42
Ariel D'Alessandrob6d5e132021-11-23 13:33:30 -030043int board_early_init_f(void)
44{
Ariel D'Alessandrob6d5e132021-11-23 13:33:30 -030045 init_uart_clk(3);
46
47 return 0;
48}
49
50void board_init_f(ulong dummy)
51{
52 int ret;
53
54 /* Clear the BSS. */
55 memset(__bss_start, 0, __bss_end - __bss_start);
56
57 arch_cpu_init();
58
59 board_early_init_f();
60
61 timer_init();
62
Ariel D'Alessandrob6d5e132021-11-23 13:33:30 -030063 ret = spl_init();
64 if (ret) {
65 debug("spl_init() failed: %d\n", ret);
66 hang();
67 }
68
Peng Fana1190932022-06-11 20:20:59 +080069 preloader_console_init();
70
Ariel D'Alessandrob6d5e132021-11-23 13:33:30 -030071 /* DDR initialization */
72 spl_dram_init();
73
74 board_init_r(NULL, 0);
75}