summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kerkmann <s.kerkmann@pengutronix.de>2024-02-28 14:14:09 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2024-03-13 12:00:29 +0100
commit60a3fd36fa1eed2f58c627adddbe3492e70ebfe2 (patch)
tree1f82ad69d024ddf094e3c069dccb5896747d083d
parent05d5bf40afb7b6c0c5bb3636151709d5aa700998 (diff)
downloadbarebox-60a3fd36fa1eed2f58c627adddbe3492e70ebfe2.tar.gz
barebox-60a3fd36fa1eed2f58c627adddbe3492e70ebfe2.tar.xz
arm: mach-imx: set cpu type in pbl
In order to use the `cpu_is_imxxyz` macro family in the pbl, `__imx_cpu_type` has to be defined and initialized. As we don't have access to the devicetree at this point, we resort to manual assignment. Note: It is safe to build the same imx.o object file for both barebox pbl and proper as the `imx_init` function is discarded during linking as the whole `init_call` section is not linked into the final binary. Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de> Link: https://lore.barebox.org/20240228-v2024-02-0-topic-imx8m-n-p-tzac-v2-2-ee1ae48dc399@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/mach-imx/Makefile2
-rw-r--r--arch/arm/mach-imx/atf.c5
-rw-r--r--include/mach/imx/generic.h5
3 files changed, 11 insertions, 1 deletions
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index ce8af486ae..a2d9702bf4 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -28,7 +28,7 @@ obj-$(CONFIG_NAND_IMX) += nand.o
lwl-$(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND) += external-nand-boot.o
obj-y += devices.o imx.o
obj-$(CONFIG_CMD_BOOTROM) += bootrom-cmd.o
-obj-pbl-y += esdctl.o boot.o
+obj-pbl-y += esdctl.o boot.o imx.o
obj-$(CONFIG_BAREBOX_UPDATE) += imx-bbu-internal.o
obj-$(CONFIG_BAREBOX_UPDATE_IMX_EXTERNAL_NAND) += imx-bbu-external-nand.o
pbl-$(CONFIG_USB_GADGET_DRIVER_ARC_PBL) += imx-udc.o
diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c
index 2d8388e8e9..e8060ebd95 100644
--- a/arch/arm/mach-imx/atf.c
+++ b/arch/arm/mach-imx/atf.c
@@ -148,6 +148,7 @@ __noreturn void __imx8mm_load_and_start_image_via_tfa(void *bl33)
size_t bl31_size;
unsigned long endmem = MX8M_DDR_CSD1_BASE_ADDR + imx8m_barebox_earlymem_size(32);
+ imx_set_cpu_type(IMX_CPU_IMX8MM);
imx8mm_init_scratch_space();
imx8m_save_bootrom_log();
imx8mm_load_bl33(bl33);
@@ -218,6 +219,7 @@ __noreturn void __imx8mp_load_and_start_image_via_tfa(void *bl33)
size_t bl31_size;
unsigned long endmem = MX8M_DDR_CSD1_BASE_ADDR + imx8m_barebox_earlymem_size(32);
+ imx_set_cpu_type(IMX_CPU_IMX8MP);
imx8mp_init_scratch_space();
imx8m_save_bootrom_log();
imx8mp_load_bl33(bl33);
@@ -289,6 +291,7 @@ __noreturn void __imx8mn_load_and_start_image_via_tfa(void *bl33)
size_t bl31_size;
unsigned long endmem = MX8M_DDR_CSD1_BASE_ADDR + imx8m_barebox_earlymem_size(16);
+ imx_set_cpu_type(IMX_CPU_IMX8MN);
imx8mn_init_scratch_space();
imx8m_save_bootrom_log();
imx8mn_load_bl33(bl33);
@@ -353,6 +356,7 @@ __noreturn void __imx8mq_load_and_start_image_via_tfa(void *bl33)
size_t bl31_size;
unsigned long endmem = MX8M_DDR_CSD1_BASE_ADDR + imx8m_barebox_earlymem_size(32);
+ imx_set_cpu_type(IMX_CPU_IMX8MQ);
imx8mq_init_scratch_space();
imx8m_save_bootrom_log();
imx8mq_load_bl33(bl33);
@@ -388,6 +392,7 @@ void __noreturn imx93_load_and_start_image_via_tfa(void)
void *bl33 = (void *)MX93_ATF_BL33_BASE_ADDR;
unsigned long endmem = MX9_DDR_CSD1_BASE_ADDR + imx9_ddrc_sdram_size();
+ imx_set_cpu_type(IMX_CPU_IMX93);
imx93_init_scratch_space(true);
/*
diff --git a/include/mach/imx/generic.h b/include/mach/imx/generic.h
index 03f3695e60..04086a2ea8 100644
--- a/include/mach/imx/generic.h
+++ b/include/mach/imx/generic.h
@@ -83,6 +83,11 @@ void imx93_cpu_lowlevel_init(void);
extern unsigned int __imx_cpu_type;
+static __always_inline void imx_set_cpu_type(unsigned int cpu_type)
+{
+ __imx_cpu_type = cpu_type;
+}
+
#ifdef CONFIG_ARCH_IMX1
# ifdef imx_cpu_type
# undef imx_cpu_type