Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Board specific initialization for AM62x platforms |
| 4 | * |
| 5 | * Copyright (C) 2020-2022 Texas Instruments Incorporated - https://www.ti.com/ |
| 6 | * Suman Anna <s-anna@ti.com> |
| 7 | * |
| 8 | */ |
| 9 | |
Jonathan Humphreys | e7aade5 | 2024-06-14 11:35:40 -0500 | [diff] [blame] | 10 | #include <efi_loader.h> |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 11 | #include <env.h> |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 12 | #include <spl.h> |
Nikhil M Jain | 57a531b | 2023-04-10 14:19:12 +0530 | [diff] [blame] | 13 | #include <init.h> |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 14 | #include <video.h> |
| 15 | #include <splash.h> |
Nikhil M Jain | 3ad584b | 2023-06-21 16:29:52 +0530 | [diff] [blame] | 16 | #include <cpu_func.h> |
Georgi Vlaev | 18c0fbf | 2022-06-14 17:45:33 +0300 | [diff] [blame] | 17 | #include <k3-ddrss.h> |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 18 | #include <fdt_support.h> |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 19 | #include <asm/io.h> |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 20 | #include <asm/arch/hardware.h> |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 21 | #include <dm/uclass.h> |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 22 | |
Nishanth Menon | 6850daf | 2024-02-12 13:47:19 -0600 | [diff] [blame] | 23 | #include "../common/fdt_ops.h" |
| 24 | |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 25 | DECLARE_GLOBAL_DATA_PTR; |
| 26 | |
Nikhil M Jain | 1ff64a2 | 2023-04-20 17:41:11 +0530 | [diff] [blame] | 27 | #if CONFIG_IS_ENABLED(SPLASH_SCREEN) |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 28 | static struct splash_location default_splash_locations[] = { |
| 29 | { |
Nikhil M Jain | 1ff64a2 | 2023-04-20 17:41:11 +0530 | [diff] [blame] | 30 | .name = "sf", |
| 31 | .storage = SPLASH_STORAGE_SF, |
| 32 | .flags = SPLASH_STORAGE_RAW, |
| 33 | .offset = 0x700000, |
| 34 | }, |
| 35 | { |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 36 | .name = "mmc", |
| 37 | .storage = SPLASH_STORAGE_MMC, |
| 38 | .flags = SPLASH_STORAGE_FS, |
| 39 | .devpart = "1:1", |
| 40 | }, |
| 41 | }; |
| 42 | |
| 43 | int splash_screen_prepare(void) |
| 44 | { |
| 45 | return splash_source_load(default_splash_locations, |
| 46 | ARRAY_SIZE(default_splash_locations)); |
| 47 | } |
| 48 | #endif |
| 49 | |
Jonathan Humphreys | e7aade5 | 2024-06-14 11:35:40 -0500 | [diff] [blame] | 50 | struct efi_fw_image fw_images[] = { |
| 51 | { |
| 52 | .image_type_id = AM62X_SK_TIBOOT3_IMAGE_GUID, |
| 53 | .fw_name = u"AM62X_SK_TIBOOT3", |
| 54 | .image_index = 1, |
| 55 | }, |
| 56 | { |
| 57 | .image_type_id = AM62X_SK_SPL_IMAGE_GUID, |
| 58 | .fw_name = u"AM62X_SK_SPL", |
| 59 | .image_index = 2, |
| 60 | }, |
| 61 | { |
| 62 | .image_type_id = AM62X_SK_UBOOT_IMAGE_GUID, |
| 63 | .fw_name = u"AM62X_SK_UBOOT", |
| 64 | .image_index = 3, |
| 65 | } |
| 66 | }; |
| 67 | |
| 68 | struct efi_capsule_update_info update_info = { |
| 69 | .dfu_string = "sf 0:0=tiboot3.bin raw 0 80000;" |
| 70 | "tispl.bin raw 80000 200000;u-boot.img raw 280000 400000", |
| 71 | .num_images = ARRAY_SIZE(fw_images), |
| 72 | .images = fw_images, |
| 73 | }; |
| 74 | |
| 75 | #if IS_ENABLED(CONFIG_SET_DFU_ALT_INFO) |
| 76 | void set_dfu_alt_info(char *interface, char *devstr) |
| 77 | { |
| 78 | if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)) |
| 79 | env_set("dfu_alt_info", update_info.dfu_string); |
| 80 | } |
| 81 | #endif |
| 82 | |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 83 | int board_init(void) |
| 84 | { |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | int dram_init(void) |
| 89 | { |
Georgi Vlaev | 8a9ceb4 | 2022-06-14 17:45:32 +0300 | [diff] [blame] | 90 | return fdtdec_setup_mem_size_base(); |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 91 | } |
Nishanth Menon | 6850daf | 2024-02-12 13:47:19 -0600 | [diff] [blame] | 92 | |
| 93 | #ifdef CONFIG_BOARD_LATE_INIT |
| 94 | int board_late_init(void) |
| 95 | { |
| 96 | ti_set_fdt_env(NULL, NULL); |
| 97 | return 0; |
| 98 | } |
| 99 | #endif |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 100 | |
| 101 | int dram_init_banksize(void) |
| 102 | { |
Georgi Vlaev | 8a9ceb4 | 2022-06-14 17:45:32 +0300 | [diff] [blame] | 103 | return fdtdec_setup_memory_banksize(); |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 104 | } |
Georgi Vlaev | 18c0fbf | 2022-06-14 17:45:33 +0300 | [diff] [blame] | 105 | |
| 106 | #if defined(CONFIG_SPL_BUILD) |
Nikhil M Jain | 57a531b | 2023-04-10 14:19:12 +0530 | [diff] [blame] | 107 | |
Nikhil M Jain | 57a531b | 2023-04-10 14:19:12 +0530 | [diff] [blame] | 108 | void spl_board_init(void) |
| 109 | { |
Nikhil M Jain | 57a531b | 2023-04-10 14:19:12 +0530 | [diff] [blame] | 110 | enable_caches(); |
Nikhil M Jain | dafda90 | 2023-07-18 14:27:29 +0530 | [diff] [blame] | 111 | if (IS_ENABLED(CONFIG_SPL_SPLASH_SCREEN) && IS_ENABLED(CONFIG_SPL_BMP)) |
| 112 | splash_display(); |
| 113 | |
Nikhil M Jain | 57a531b | 2023-04-10 14:19:12 +0530 | [diff] [blame] | 114 | } |
| 115 | |
Georgi Vlaev | 18c0fbf | 2022-06-14 17:45:33 +0300 | [diff] [blame] | 116 | #if defined(CONFIG_K3_AM64_DDRSS) |
| 117 | static void fixup_ddr_driver_for_ecc(struct spl_image_info *spl_image) |
| 118 | { |
| 119 | struct udevice *dev; |
| 120 | int ret; |
| 121 | |
| 122 | dram_init_banksize(); |
| 123 | |
| 124 | ret = uclass_get_device(UCLASS_RAM, 0, &dev); |
| 125 | if (ret) |
| 126 | panic("Cannot get RAM device for ddr size fixup: %d\n", ret); |
| 127 | |
| 128 | ret = k3_ddrss_ddr_fdt_fixup(dev, spl_image->fdt_addr, gd->bd); |
| 129 | if (ret) |
| 130 | printf("Error fixing up ddr node for ECC use! %d\n", ret); |
| 131 | } |
| 132 | #else |
| 133 | static void fixup_memory_node(struct spl_image_info *spl_image) |
| 134 | { |
| 135 | u64 start[CONFIG_NR_DRAM_BANKS]; |
| 136 | u64 size[CONFIG_NR_DRAM_BANKS]; |
| 137 | int bank; |
| 138 | int ret; |
| 139 | |
| 140 | dram_init(); |
| 141 | dram_init_banksize(); |
| 142 | |
| 143 | for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { |
| 144 | start[bank] = gd->bd->bi_dram[bank].start; |
| 145 | size[bank] = gd->bd->bi_dram[bank].size; |
| 146 | } |
| 147 | |
| 148 | /* dram_init functions use SPL fdt, and we must fixup u-boot fdt */ |
| 149 | ret = fdt_fixup_memory_banks(spl_image->fdt_addr, start, size, |
| 150 | CONFIG_NR_DRAM_BANKS); |
| 151 | if (ret) |
| 152 | printf("Error fixing up memory node! %d\n", ret); |
| 153 | } |
| 154 | #endif |
| 155 | |
| 156 | void spl_perform_fixups(struct spl_image_info *spl_image) |
| 157 | { |
| 158 | #if defined(CONFIG_K3_AM64_DDRSS) |
| 159 | fixup_ddr_driver_for_ecc(spl_image); |
| 160 | #else |
| 161 | fixup_memory_node(spl_image); |
| 162 | #endif |
| 163 | } |
| 164 | #endif |