diff options
author | Ye Li <ye.li@nxp.com> | 2020-06-03 02:48:04 -0700 |
---|---|---|
committer | Ye Li <ye.li@nxp.com> | 2020-06-03 22:28:06 -0700 |
commit | ad89720915982afb3a3c8e853fffd17241771d0d (patch) | |
tree | 38f6903cdb99235a1dfabfb6ebc154bd31dbd03d /common | |
parent | f2207845076db51670e115fa392efac11ebee1ce (diff) |
MLK-24254-2 spl: mmc: Move the eMMC boot part index to weak function
Move the default eMMC boot partition index used for SPL load to a weak
function. So we can override it in iMX8 specified codes.
Because on iMX8 when the emmc regular boot is from boot part0/1, ROM
will switch to the other boot part for secondary boot. So we can't
directly use the boot part index in PARTITION_CONFIG register. But have
to check the secondary boot for using the other part.
Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/spl/spl_mmc.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 748f6e0970..586c4e2490 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -335,6 +335,27 @@ unsigned long __weak spl_mmc_get_uboot_raw_sector(struct mmc *mmc, return raw_sect; } +int __weak spl_mmc_emmc_boot_partition(struct mmc *mmc) +{ + int part = 0; + +#ifdef CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION + part = CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION; +#else + /* + * We need to check what the partition is configured to. + * 1 and 2 match up to boot0 / boot1 and 7 is user data + * which is the first physical partition (0). + */ + part = (mmc->part_config >> 3) & PART_ACCESS_MASK; + + if (part == 7) + part = 0; +#endif + + return part; +} + int spl_mmc_load(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, const char *filename, @@ -366,26 +387,7 @@ int spl_mmc_load(struct spl_image_info *spl_image, err = -EINVAL; switch (boot_mode) { case MMCSD_MODE_EMMCBOOT: -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION - part = CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION; -#else - /* - * We need to check what the partition is configured to. - * 1 and 2 match up to boot0 / boot1 and 7 is user data - * which is the first physical partition (0). - */ -#ifdef CONFIG_DUAL_BOOTLOADER - /* Bootloader is stored in eMMC user partition for - * dual bootloader. - */ - part = 0; -#else - part = (mmc->part_config >> 3) & PART_ACCESS_MASK; - - if (part == 7) - part = 0; -#endif -#endif + part = spl_mmc_emmc_boot_partition(mmc); if (CONFIG_IS_ENABLED(MMC_TINY)) err = mmc_switch_part(mmc, part); |