[PATCH 4/7] ARM: i.MX93: add imx93_barebox_entry()

Sascha Hauer s.hauer at pengutronix.de
Fri Jan 19 06:24:10 PST 2024


We already have support for detecting the DDR size automatically on
i.MX93. Create imx93_barebox_entry() from it and use it instead of
the hardcoded DDR size in the tqmba9xxxca board.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/boards/tqmba9xxxca/lowlevel.c |  4 +++-
 arch/arm/mach-imx/esdctl.c             | 15 ++++++++++++---
 include/mach/imx/esdctl.h              |  1 +
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boards/tqmba9xxxca/lowlevel.c b/arch/arm/boards/tqmba9xxxca/lowlevel.c
index 0a57d02451..64913b8de9 100644
--- a/arch/arm/boards/tqmba9xxxca/lowlevel.c
+++ b/arch/arm/boards/tqmba9xxxca/lowlevel.c
@@ -4,11 +4,13 @@
 #include <debug_ll.h>
 #include <mach/imx/debug_ll.h>
 #include <mach/imx/generic.h>
+#include <mach/imx/xload.h>
 #include <asm/barebox-arm.h>
 #include <soc/imx9/ddr.h>
 #include <mach/imx/atf.h>
 #include <mach/imx/xload.h>
 #include <mach/imx/romapi.h>
+#include <mach/imx/esdctl.h>
 
 extern char __dtb_z_imx93_tqma9352_mba93xxca_start[];
 extern struct dram_timing_info tqma93xxca_dram_timing;
@@ -29,7 +31,7 @@ static noinline void tqma9352_mba93xxca_continue(void)
 		imx93_load_and_start_image_via_tfa();
 	}
 
-	barebox_arm_entry(0x80000000, 0x40000000, __dtb_z_imx93_tqma9352_mba93xxca_start);
+	imx93_barebox_entry(__dtb_z_imx93_tqma9352_mba93xxca_start);
 }
 
 ENTRY_FUNCTION(start_imx93_tqma9352_mba93xxca, r0, r1, r2)
diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
index 1bd22cc6ef..2dc858c87f 100644
--- a/arch/arm/mach-imx/esdctl.c
+++ b/arch/arm/mach-imx/esdctl.c
@@ -563,7 +563,7 @@ static int imx8mn_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
 #define IMX9_DDRC_CS_COL_BITS	GENMASK(2, 0)
 #define IMX9_DDRC_CS_EN		BIT(31)
 
-static int imx9_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
+static resource_size_t imx9_ddrc_sdram_size(void __iomem *mmdcbase)
 {
 	int width = 2;
 	int banks = 8;
@@ -588,7 +588,12 @@ static int imx9_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
 		mem += memory_sdram_size(cols, rows, banks, width);
 	}
 
-	return arm_add_mem_device("ram0", data->base0, mem);
+	return mem;
+}
+
+static int imx9_ddrc_add_mem(void *mmdcbase, struct imx_esdctl_data *data)
+{
+	return arm_add_mem_device("ram0", data->base0, imx9_ddrc_sdram_size(mmdcbase));
 }
 
 static resource_size_t imx7d_ddrc_sdram_size(void __iomem *ddrc)
@@ -1039,4 +1044,8 @@ void __noreturn imx7d_barebox_entry(void *boarddata)
 			  boarddata);
 }
 
-
+void __noreturn imx93_barebox_entry(void *boarddata)
+{
+	barebox_arm_entry(MX9_DDR_CSD1_BASE_ADDR,
+			  imx9_ddrc_sdram_size(IOMEM(MX9_DDR_CTL_BASE)), boarddata);
+}
diff --git a/include/mach/imx/esdctl.h b/include/mach/imx/esdctl.h
index 01533478cc..4898a3e682 100644
--- a/include/mach/imx/esdctl.h
+++ b/include/mach/imx/esdctl.h
@@ -148,6 +148,7 @@ void __noreturn imx8mn_barebox_entry(void *boarddata);
 void __noreturn imx8mp_barebox_entry(void *boarddata);
 void __noreturn imx8mq_barebox_entry(void *boarddata);
 void __noreturn imx7d_barebox_entry(void *boarddata);
+void __noreturn imx93_barebox_entry(void *boarddata);
 #define imx6sx_barebox_entry(boarddata) imx6ul_barebox_entry(boarddata)
 void imx_esdctl_disable(void);
 resource_size_t imx8m_barebox_earlymem_size(unsigned buswidth);
-- 
2.39.2




More information about the barebox mailing list