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 | |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 10 | #include <env.h> |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 11 | #include <spl.h> |
Nikhil M Jain | 57a531b | 2023-04-10 14:19:12 +0530 | [diff] [blame] | 12 | #include <init.h> |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 13 | #include <video.h> |
| 14 | #include <splash.h> |
Nikhil M Jain | 3ad584b | 2023-06-21 16:29:52 +0530 | [diff] [blame] | 15 | #include <cpu_func.h> |
Georgi Vlaev | 18c0fbf | 2022-06-14 17:45:33 +0300 | [diff] [blame] | 16 | #include <k3-ddrss.h> |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 17 | #include <fdt_support.h> |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 18 | #include <asm/io.h> |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 19 | #include <asm/arch/hardware.h> |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 20 | #include <dm/uclass.h> |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 21 | |
| 22 | DECLARE_GLOBAL_DATA_PTR; |
| 23 | |
Nikhil M Jain | 1ff64a2 | 2023-04-20 17:41:11 +0530 | [diff] [blame] | 24 | #if CONFIG_IS_ENABLED(SPLASH_SCREEN) |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 25 | static struct splash_location default_splash_locations[] = { |
| 26 | { |
Nikhil M Jain | 1ff64a2 | 2023-04-20 17:41:11 +0530 | [diff] [blame] | 27 | .name = "sf", |
| 28 | .storage = SPLASH_STORAGE_SF, |
| 29 | .flags = SPLASH_STORAGE_RAW, |
| 30 | .offset = 0x700000, |
| 31 | }, |
| 32 | { |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 33 | .name = "mmc", |
| 34 | .storage = SPLASH_STORAGE_MMC, |
| 35 | .flags = SPLASH_STORAGE_FS, |
| 36 | .devpart = "1:1", |
| 37 | }, |
| 38 | }; |
| 39 | |
| 40 | int splash_screen_prepare(void) |
| 41 | { |
| 42 | return splash_source_load(default_splash_locations, |
| 43 | ARRAY_SIZE(default_splash_locations)); |
| 44 | } |
| 45 | #endif |
| 46 | |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 47 | int board_init(void) |
| 48 | { |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | int dram_init(void) |
| 53 | { |
Georgi Vlaev | 8a9ceb4 | 2022-06-14 17:45:32 +0300 | [diff] [blame] | 54 | return fdtdec_setup_mem_size_base(); |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | int dram_init_banksize(void) |
| 58 | { |
Georgi Vlaev | 8a9ceb4 | 2022-06-14 17:45:32 +0300 | [diff] [blame] | 59 | return fdtdec_setup_memory_banksize(); |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 60 | } |
Georgi Vlaev | 18c0fbf | 2022-06-14 17:45:33 +0300 | [diff] [blame] | 61 | |
| 62 | #if defined(CONFIG_SPL_BUILD) |
Nikhil M Jain | 57a531b | 2023-04-10 14:19:12 +0530 | [diff] [blame] | 63 | static int video_setup(void) |
| 64 | { |
Nikhil M Jain | dafda90 | 2023-07-18 14:27:29 +0530 | [diff] [blame] | 65 | if (CONFIG_IS_ENABLED(VIDEO)) { |
| 66 | ulong addr; |
| 67 | int ret; |
Nikhil M Jain | 57a531b | 2023-04-10 14:19:12 +0530 | [diff] [blame] | 68 | |
Nikhil M Jain | dafda90 | 2023-07-18 14:27:29 +0530 | [diff] [blame] | 69 | addr = gd->relocaddr; |
| 70 | ret = video_reserve(&addr); |
| 71 | if (ret) |
| 72 | return ret; |
| 73 | debug("Reserving %luk for video at: %08lx\n", |
| 74 | ((unsigned long)gd->relocaddr - addr) >> 10, addr); |
| 75 | gd->relocaddr = addr; |
| 76 | } |
| 77 | |
Nikhil M Jain | 57a531b | 2023-04-10 14:19:12 +0530 | [diff] [blame] | 78 | return 0; |
| 79 | } |
| 80 | |
Nikhil M Jain | 57a531b | 2023-04-10 14:19:12 +0530 | [diff] [blame] | 81 | void spl_board_init(void) |
| 82 | { |
Nikhil M Jain | 57a531b | 2023-04-10 14:19:12 +0530 | [diff] [blame] | 83 | video_setup(); |
| 84 | enable_caches(); |
Nikhil M Jain | dafda90 | 2023-07-18 14:27:29 +0530 | [diff] [blame] | 85 | if (IS_ENABLED(CONFIG_SPL_SPLASH_SCREEN) && IS_ENABLED(CONFIG_SPL_BMP)) |
| 86 | splash_display(); |
| 87 | |
Nikhil M Jain | 57a531b | 2023-04-10 14:19:12 +0530 | [diff] [blame] | 88 | } |
| 89 | |
Georgi Vlaev | 18c0fbf | 2022-06-14 17:45:33 +0300 | [diff] [blame] | 90 | #if defined(CONFIG_K3_AM64_DDRSS) |
| 91 | static void fixup_ddr_driver_for_ecc(struct spl_image_info *spl_image) |
| 92 | { |
| 93 | struct udevice *dev; |
| 94 | int ret; |
| 95 | |
| 96 | dram_init_banksize(); |
| 97 | |
| 98 | ret = uclass_get_device(UCLASS_RAM, 0, &dev); |
| 99 | if (ret) |
| 100 | panic("Cannot get RAM device for ddr size fixup: %d\n", ret); |
| 101 | |
| 102 | ret = k3_ddrss_ddr_fdt_fixup(dev, spl_image->fdt_addr, gd->bd); |
| 103 | if (ret) |
| 104 | printf("Error fixing up ddr node for ECC use! %d\n", ret); |
| 105 | } |
| 106 | #else |
| 107 | static void fixup_memory_node(struct spl_image_info *spl_image) |
| 108 | { |
| 109 | u64 start[CONFIG_NR_DRAM_BANKS]; |
| 110 | u64 size[CONFIG_NR_DRAM_BANKS]; |
| 111 | int bank; |
| 112 | int ret; |
| 113 | |
| 114 | dram_init(); |
| 115 | dram_init_banksize(); |
| 116 | |
| 117 | for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { |
| 118 | start[bank] = gd->bd->bi_dram[bank].start; |
| 119 | size[bank] = gd->bd->bi_dram[bank].size; |
| 120 | } |
| 121 | |
| 122 | /* dram_init functions use SPL fdt, and we must fixup u-boot fdt */ |
| 123 | ret = fdt_fixup_memory_banks(spl_image->fdt_addr, start, size, |
| 124 | CONFIG_NR_DRAM_BANKS); |
| 125 | if (ret) |
| 126 | printf("Error fixing up memory node! %d\n", ret); |
| 127 | } |
| 128 | #endif |
| 129 | |
| 130 | void spl_perform_fixups(struct spl_image_info *spl_image) |
| 131 | { |
| 132 | #if defined(CONFIG_K3_AM64_DDRSS) |
| 133 | fixup_ddr_driver_for_ecc(spl_image); |
| 134 | #else |
| 135 | fixup_memory_node(spl_image); |
| 136 | #endif |
| 137 | } |
| 138 | #endif |