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 | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 12 | #include <video.h> |
| 13 | #include <splash.h> |
Georgi Vlaev | 18c0fbf | 2022-06-14 17:45:33 +0300 | [diff] [blame] | 14 | #include <k3-ddrss.h> |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 15 | #include <fdt_support.h> |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 16 | #include <asm/io.h> |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 17 | #include <asm/arch/hardware.h> |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 18 | #include <dm/uclass.h> |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 19 | |
| 20 | DECLARE_GLOBAL_DATA_PTR; |
| 21 | |
Nikhil M Jain | 155a082 | 2023-01-31 15:35:19 +0530 | [diff] [blame] | 22 | #ifdef CONFIG_SPLASH_SCREEN |
| 23 | static struct splash_location default_splash_locations[] = { |
| 24 | { |
| 25 | .name = "mmc", |
| 26 | .storage = SPLASH_STORAGE_MMC, |
| 27 | .flags = SPLASH_STORAGE_FS, |
| 28 | .devpart = "1:1", |
| 29 | }, |
| 30 | }; |
| 31 | |
| 32 | int splash_screen_prepare(void) |
| 33 | { |
| 34 | return splash_source_load(default_splash_locations, |
| 35 | ARRAY_SIZE(default_splash_locations)); |
| 36 | } |
| 37 | #endif |
| 38 | |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 39 | int board_init(void) |
| 40 | { |
| 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | int dram_init(void) |
| 45 | { |
Georgi Vlaev | 8a9ceb4 | 2022-06-14 17:45:32 +0300 | [diff] [blame] | 46 | return fdtdec_setup_mem_size_base(); |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | int dram_init_banksize(void) |
| 50 | { |
Georgi Vlaev | 8a9ceb4 | 2022-06-14 17:45:32 +0300 | [diff] [blame] | 51 | return fdtdec_setup_memory_banksize(); |
Suman Anna | 3b43110 | 2022-05-25 13:38:47 +0530 | [diff] [blame] | 52 | } |
Georgi Vlaev | 18c0fbf | 2022-06-14 17:45:33 +0300 | [diff] [blame] | 53 | |
| 54 | #if defined(CONFIG_SPL_BUILD) |
| 55 | #if defined(CONFIG_K3_AM64_DDRSS) |
| 56 | static void fixup_ddr_driver_for_ecc(struct spl_image_info *spl_image) |
| 57 | { |
| 58 | struct udevice *dev; |
| 59 | int ret; |
| 60 | |
| 61 | dram_init_banksize(); |
| 62 | |
| 63 | ret = uclass_get_device(UCLASS_RAM, 0, &dev); |
| 64 | if (ret) |
| 65 | panic("Cannot get RAM device for ddr size fixup: %d\n", ret); |
| 66 | |
| 67 | ret = k3_ddrss_ddr_fdt_fixup(dev, spl_image->fdt_addr, gd->bd); |
| 68 | if (ret) |
| 69 | printf("Error fixing up ddr node for ECC use! %d\n", ret); |
| 70 | } |
| 71 | #else |
| 72 | static void fixup_memory_node(struct spl_image_info *spl_image) |
| 73 | { |
| 74 | u64 start[CONFIG_NR_DRAM_BANKS]; |
| 75 | u64 size[CONFIG_NR_DRAM_BANKS]; |
| 76 | int bank; |
| 77 | int ret; |
| 78 | |
| 79 | dram_init(); |
| 80 | dram_init_banksize(); |
| 81 | |
| 82 | for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { |
| 83 | start[bank] = gd->bd->bi_dram[bank].start; |
| 84 | size[bank] = gd->bd->bi_dram[bank].size; |
| 85 | } |
| 86 | |
| 87 | /* dram_init functions use SPL fdt, and we must fixup u-boot fdt */ |
| 88 | ret = fdt_fixup_memory_banks(spl_image->fdt_addr, start, size, |
| 89 | CONFIG_NR_DRAM_BANKS); |
| 90 | if (ret) |
| 91 | printf("Error fixing up memory node! %d\n", ret); |
| 92 | } |
| 93 | #endif |
| 94 | |
| 95 | void spl_perform_fixups(struct spl_image_info *spl_image) |
| 96 | { |
| 97 | #if defined(CONFIG_K3_AM64_DDRSS) |
| 98 | fixup_ddr_driver_for_ecc(spl_image); |
| 99 | #else |
| 100 | fixup_memory_node(spl_image); |
| 101 | #endif |
| 102 | } |
| 103 | #endif |