1 // SPDX-License-Identifier: GPL-2.0+
3 * Board specific initialization for AM62x platforms
5 * Copyright (C) 2020-2022 Texas Instruments Incorporated - https://www.ti.com/
6 * Suman Anna <s-anna@ti.com>
12 #include <dm/uclass.h>
14 #include <fdt_support.h>
15 #include <asm/arch/hardware.h>
16 #include <asm/arch/sys_proto.h>
19 DECLARE_GLOBAL_DATA_PTR;
28 return fdtdec_setup_mem_size_base();
31 int dram_init_banksize(void)
33 return fdtdec_setup_memory_banksize();
36 #if defined(CONFIG_SPL_BUILD)
37 #if defined(CONFIG_K3_AM64_DDRSS)
38 static void fixup_ddr_driver_for_ecc(struct spl_image_info *spl_image)
45 ret = uclass_get_device(UCLASS_RAM, 0, &dev);
47 panic("Cannot get RAM device for ddr size fixup: %d\n", ret);
49 ret = k3_ddrss_ddr_fdt_fixup(dev, spl_image->fdt_addr, gd->bd);
51 printf("Error fixing up ddr node for ECC use! %d\n", ret);
54 static void fixup_memory_node(struct spl_image_info *spl_image)
56 u64 start[CONFIG_NR_DRAM_BANKS];
57 u64 size[CONFIG_NR_DRAM_BANKS];
64 for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
65 start[bank] = gd->bd->bi_dram[bank].start;
66 size[bank] = gd->bd->bi_dram[bank].size;
69 /* dram_init functions use SPL fdt, and we must fixup u-boot fdt */
70 ret = fdt_fixup_memory_banks(spl_image->fdt_addr, start, size,
71 CONFIG_NR_DRAM_BANKS);
73 printf("Error fixing up memory node! %d\n", ret);
77 void spl_perform_fixups(struct spl_image_info *spl_image)
79 #if defined(CONFIG_K3_AM64_DDRSS)
80 fixup_ddr_driver_for_ecc(spl_image);
82 fixup_memory_node(spl_image);