From patchwork Tue Jun 9 10:34:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Li X-Patchwork-Id: 241994 List-Id: U-Boot discussion From: ye.li at nxp.com (Ye Li) Date: Tue, 9 Jun 2020 03:34:43 -0700 Subject: [PATCH 2/3] spl: mmc: Move the eMMC boot part index to weak function In-Reply-To: <1591698884-72174-1-git-send-email-ye.li@nxp.com> References: <1591698884-72174-1-git-send-email-ye.li@nxp.com> Message-ID: <1591698884-72174-2-git-send-email-ye.li@nxp.com> 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 correct boot partition. Signed-off-by: Ye Li Reviewed-by: Peng Fan --- common/spl/spl_mmc.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index add2785..f2880cc 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -324,6 +324,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, @@ -355,19 +376,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). - */ - part = (mmc->part_config >> 3) & PART_ACCESS_MASK; - - if (part == 7) - part = 0; -#endif + part = spl_mmc_emmc_boot_partition(mmc); if (CONFIG_IS_ENABLED(MMC_TINY)) err = mmc_switch_part(mmc, part);