Ariel D'Alessandro | b6d5e13 | 2021-11-23 13:33:30 -0300 | [diff] [blame] | 1 | // 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 Yang | bb11234 | 2023-08-03 09:47:16 +0800 | [diff] [blame] | 16 | #include <asm/sections.h> |
Ariel D'Alessandro | b6d5e13 | 2021-11-23 13:33:30 -0300 | [diff] [blame] | 17 | #include <dm/device.h> |
| 18 | #include <dm/uclass.h> |
| 19 | |
| 20 | int spl_board_boot_device(enum boot_device boot_dev_spl) |
| 21 | { |
| 22 | return BOOT_DEVICE_BOOTROM; |
| 23 | } |
| 24 | |
| 25 | void spl_dram_init(void) |
| 26 | { |
| 27 | ddr_init(&dram_timing); |
| 28 | } |
| 29 | |
| 30 | void 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'Alessandro | b6d5e13 | 2021-11-23 13:33:30 -0300 | [diff] [blame] | 44 | int board_early_init_f(void) |
| 45 | { |
Ariel D'Alessandro | b6d5e13 | 2021-11-23 13:33:30 -0300 | [diff] [blame] | 46 | init_uart_clk(3); |
| 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | void 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'Alessandro | b6d5e13 | 2021-11-23 13:33:30 -0300 | [diff] [blame] | 64 | ret = spl_init(); |
| 65 | if (ret) { |
| 66 | debug("spl_init() failed: %d\n", ret); |
| 67 | hang(); |
| 68 | } |
| 69 | |
Peng Fan | a119093 | 2022-06-11 20:20:59 +0800 | [diff] [blame] | 70 | preloader_console_init(); |
| 71 | |
Ariel D'Alessandro | b6d5e13 | 2021-11-23 13:33:30 -0300 | [diff] [blame] | 72 | /* DDR initialization */ |
| 73 | spl_dram_init(); |
| 74 | |
| 75 | board_init_r(NULL, 0); |
| 76 | } |