Jagan Teki | 35049fe | 2021-04-26 18:23:48 +0530 | [diff] [blame] | 1 | // 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> |
Shiji Yang | bb11234 | 2023-08-03 09:47:16 +0800 | [diff] [blame] | 19 | #include <asm/sections.h> |
Jagan Teki | 35049fe | 2021-04-26 18:23:48 +0530 | [diff] [blame] | 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
| 23 | int spl_board_boot_device(enum boot_device boot_dev_spl) |
| 24 | { |
| 25 | switch (boot_dev_spl) { |
| 26 | case SD1_BOOT: |
| 27 | case SD2_BOOT: |
| 28 | case MMC2_BOOT: |
| 29 | return BOOT_DEVICE_MMC1; |
| 30 | case SD3_BOOT: |
| 31 | case MMC3_BOOT: |
| 32 | return BOOT_DEVICE_MMC2; |
| 33 | default: |
| 34 | return BOOT_DEVICE_NONE; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | static void spl_dram_init(void) |
| 39 | { |
| 40 | ddr_init(&dram_timing); |
| 41 | } |
| 42 | |
| 43 | void spl_board_init(void) |
| 44 | { |
| 45 | debug("Normal Boot\n"); |
| 46 | } |
| 47 | |
| 48 | #ifdef CONFIG_SPL_LOAD_FIT |
| 49 | int board_fit_config_name_match(const char *name) |
| 50 | { |
| 51 | /* Just empty function now - can't decide what to choose */ |
| 52 | debug("%s: %s\n", __func__, name); |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | #endif |
| 57 | |
Jagan Teki | 35049fe | 2021-04-26 18:23:48 +0530 | [diff] [blame] | 58 | int board_early_init_f(void) |
| 59 | { |
Peng Fan | 9f77727 | 2022-06-11 20:20:57 +0800 | [diff] [blame] | 60 | return 0; |
Jagan Teki | 35049fe | 2021-04-26 18:23:48 +0530 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | void board_init_f(ulong dummy) |
| 64 | { |
| 65 | int ret; |
| 66 | |
| 67 | arch_cpu_init(); |
| 68 | |
| 69 | init_uart_clk(1); |
| 70 | |
| 71 | board_early_init_f(); |
| 72 | |
| 73 | timer_init(); |
| 74 | |
Jagan Teki | 35049fe | 2021-04-26 18:23:48 +0530 | [diff] [blame] | 75 | /* Clear the BSS. */ |
| 76 | memset(__bss_start, 0, __bss_end - __bss_start); |
| 77 | |
| 78 | ret = spl_early_init(); |
| 79 | if (ret) { |
| 80 | debug("spl_early_init() failed: %d\n", ret); |
| 81 | hang(); |
| 82 | } |
| 83 | |
Peng Fan | 9f77727 | 2022-06-11 20:20:57 +0800 | [diff] [blame] | 84 | preloader_console_init(); |
| 85 | |
Jagan Teki | 35049fe | 2021-04-26 18:23:48 +0530 | [diff] [blame] | 86 | enable_tzc380(); |
| 87 | |
| 88 | /* DDR initialization */ |
| 89 | spl_dram_init(); |
| 90 | |
| 91 | board_init_r(NULL, 0); |
| 92 | } |