]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: gateworks: venice: dynamically determine U-Boot raw sector
authorTim Harvey <tharvey@gateworks.com>
Wed, 3 May 2023 00:05:53 +0000 (17:05 -0700)
committerStefano Babic <sbabic@denx.de>
Tue, 11 Jul 2023 12:40:03 +0000 (14:40 +0200)
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR needs to adjust for
IMX8MN and IMX8MP when booting from an eMMC boot partition due
to IMX BOOTROM v2 using an SPL offset of 0 for boot partitions
and 32K for the user partition.

In order to allow the same firmware to run on both user and boot
hardware partitions adjust raw_sect dynamically at runtime.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
board/gateworks/venice/spl.c

index 4eb7bdfcee674f46eb3258370a0118d71be22e3e..50056da3ee0fd5076b72e6ae37510240bfdcef7a 100644 (file)
@@ -327,6 +327,21 @@ int spl_board_boot_device(enum boot_device boot_dev_spl)
        }
 }
 
+unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc, unsigned long raw_sect)
+{
+       if (!IS_SD(mmc)) {
+               switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
+               case 1:
+               case 2:
+                       if (IS_ENABLED(CONFIG_IMX8MN) || IS_ENABLED(CONFIG_IMX8MP))
+                               raw_sect -= 32 * 2;
+                       break;
+               }
+       }
+
+       return raw_sect;
+}
+
 const char *spl_board_loader_name(u32 boot_device)
 {
        switch (boot_device) {