Hi Santhosh,

Am 21.10.24 um 06:40 schrieb Santhosh Kumar K:
As there are few redundant functions in board/ti/*/evm.c files, pull
them to a common location of access to reuse and include the common file
to access the functions.

Call k3-ddrss driver through fixup_ddr_driver_for_ecc() to fixup the
device tree and resize the available amount of DDR, if ECC is enabled.
Otherwise, fixup the device tree using the regular
fdt_fixup_memory_banks().

Also call dram_init_banksize() after every call to
fixup_ddr_driver_for_ecc() is made so that gd->bd is populated
correctly.

Ensure that fixup_ddr_driver_for_ecc() is agnostic to the number of DDR
controllers present.

Signed-off-by: Santhosh Kumar K <s...@ti.com>
Signed-off-by: Neha Malcom Francis <n-fran...@ti.com>
---
<snip>

+obj-y += common.o security.o k3-ddr.o
  obj-$(CONFIG_SOC_K3_AM62A7) += am62ax/
  obj-$(CONFIG_SOC_K3_AM62P5) += am62px/
  obj-$(CONFIG_SOC_K3_AM625) += am62x/
diff --git a/arch/arm/mach-k3/include/mach/k3-ddr.h 
b/arch/arm/mach-k3/include/mach/k3-ddr.h
new file mode 100644
index 000000000000..754e9ba29dac
--- /dev/null
<snip>

+#include <fdt_support.h>
+#include <dm/uclass.h>
+#include <k3-ddrss.h>
+#include <spl.h>
+
+#include <asm/arch/k3-ddr.h>
+
+int dram_init(void)
+{
+        s32 ret;
+
+        ret = fdtdec_setup_mem_size_base_lowest();
+        if (ret)
+                printf("Error setting up mem size and base. %d\n", ret);
+
+        return ret;
+}
+
+int dram_init_banksize(void)
+{
+        s32 ret;
+
+        ret = fdtdec_setup_memory_banksize();
+        if (ret)
+                printf("Error setting up memory banksize. %d\n", ret);
+
+        return ret;
+}
+Moving dram_init() and dram_init_banksize() into a generic part forces
every K3 based board to use your implementation.

This also breaks the builds for phycore_am62x, phycore_am64x and also the verdin-am62,

  phycore-am62x.c:49: multiple definition of `dram_init'
  phycore-am62x.c:97: multiple definition of `dram_init_banksize

Regards,
Wadim

Reply via email to