]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
imx9: scmi: Support iMX95/94/952 secondary boot
authorYe Li <ye.li@nxp.com>
Tue, 28 Apr 2026 08:32:50 +0000 (16:32 +0800)
committerFabio Estevam <festevam@gmail.com>
Fri, 15 May 2026 20:31:39 +0000 (17:31 -0300)
When ROM boots from secondary container set, SPL should select
correct offset to load u-boot-atf container.
The implementation uses ROM passover information:
1) For non-eMMC boot partition device, use image offset in ROM
   passover data to get u-boot-atf container offset.
2) For eMMC boot partition device, use boot stage (secondary)
   in ROM passover data to select correct eMMC boot partition
   for u-boot-atf container.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
arch/arm/include/asm/arch-imx9/sys_proto.h
arch/arm/mach-imx/image-container.c
arch/arm/mach-imx/imx9/scmi/soc.c

index 73df8715f22bef64d9765b3b4a98307e567575ca..b5e7d7d6855dd8902eeb33ee70c61768db2950bb 100644 (file)
@@ -23,7 +23,9 @@ int low_drive_freq_update(void *blob);
 enum imx9_soc_voltage_mode soc_target_voltage_mode(void);
 int get_reset_reason(bool sys, bool lm);
 
-u8 imx95_detect_secondary_image_boot(void);
+int scmi_get_boot_device_offset(unsigned long *img_off);
+int scmi_get_boot_stage(u8 *stage);
+u8 scmi_get_imgset_sel(void);
 
 #define is_voltage_mode(mode) (soc_target_voltage_mode() == (mode))
 
index 63cf85963165be6e7e69cf65a4a5206ebcf93387..bdb43d138f286c9e5fa1bf81875dd50873af4d6d 100644 (file)
@@ -225,15 +225,9 @@ static bool check_secondary_cnt_set(unsigned long *set_off)
                        }
                }
        }
-#elif IS_ENABLED(CONFIG_IMX95)
-       u8 img_set_sel = imx95_detect_secondary_image_boot();
-
-       *set_off = img_set_sel ? 0x400000 : 0;
+#endif
 
-       return !!img_set_sel;
-#else
        return false;
-#endif
 }
 
 static unsigned long get_boot_device_offset(void *dev, int dev_type)
@@ -246,6 +240,14 @@ static unsigned long get_boot_device_offset(void *dev, int dev_type)
                return offset;
        }
 
+#if IS_ENABLED(CONFIG_ARCH_IMX9) && IS_ENABLED(CONFIG_SCMI_FIRMWARE)
+       int ret;
+       ret = scmi_get_boot_device_offset(&offset);
+       if (!ret)
+               return offset;
+       /* fall back to boot from primary set if get rom passover failed */
+#endif
+
        sec_boot = check_secondary_cnt_set(&sec_set_off);
        if (sec_boot)
                printf("Secondary set selected\n");
@@ -372,10 +374,17 @@ int spl_mmc_emmc_boot_partition(struct mmc *mmc)
 
        part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
        if (part == EMMC_BOOT_PART_BOOT1 || part == EMMC_BOOT_PART_BOOT2) {
-               unsigned long sec_set_off = 0;
                bool sec_boot = false;
-
+#if IS_ENABLED(CONFIG_ARCH_IMX9) && IS_ENABLED(CONFIG_SCMI_FIRMWARE)
+               u8 stage;
+               int ret;
+               ret = scmi_get_boot_stage(&stage);
+               if (!ret)
+                       sec_boot = (stage == 0x9);
+#else
+               unsigned long sec_set_off = 0;
                sec_boot = check_secondary_cnt_set(&sec_set_off);
+#endif
                if (sec_boot)
                        part = (part == EMMC_BOOT_PART_BOOT1) ? EMMC_HWPART_BOOT2 : EMMC_HWPART_BOOT1;
        } else if (part == EMMC_BOOT_PART_USER) {
index 47e8fc247dfb1d3d697309db41dbffc20360d042..60fdd577f5587203c59cd39ee6ed909818bf2097 100644 (file)
@@ -745,8 +745,31 @@ void build_info(void)
        puts("\n");
 }
 
-#if IS_ENABLED(CONFIG_IMX95)
-u8 imx95_detect_secondary_image_boot(void)
+int scmi_get_boot_device_offset(unsigned long *img_off)
+{
+       int ret;
+       rom_passover_t rom_data = {0};
+
+       ret = scmi_get_rom_data(&rom_data);
+       if (!ret)
+               *img_off = rom_data.img_ofs;
+
+       return 0;
+}
+
+int scmi_get_boot_stage(u8 *stage)
+{
+       int ret;
+       rom_passover_t rom_data = {0};
+
+       ret = scmi_get_rom_data(&rom_data);
+       if (!ret)
+               *stage = rom_data.boot_stage;
+
+       return ret;
+}
+
+u8 scmi_get_imgset_sel(void)
 {
        rom_passover_t rdata = { 0 };
        int ret = scmi_get_rom_data(&rdata);
@@ -759,9 +782,8 @@ u8 imx95_detect_secondary_image_boot(void)
 
 int boot_mode_getprisec(void)
 {
-       return !!imx95_detect_secondary_image_boot();
+       return !!scmi_get_imgset_sel();
 }
-#endif
 
 int arch_misc_init(void)
 {