Commit b2b8aa81b13d301259d7af5211051b11fbb83c20

Authored by Ye Li
1 parent 2d8d25d12c

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>

Showing 1 changed file with 22 additions and 20 deletions Side-by-side Diff

common/spl/spl_mmc.c
... ... @@ -335,6 +335,27 @@
335 335 return raw_sect;
336 336 }
337 337  
  338 +int __weak spl_mmc_emmc_boot_partition(struct mmc *mmc)
  339 +{
  340 + int part = 0;
  341 +
  342 +#ifdef CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION
  343 + part = CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION;
  344 +#else
  345 + /*
  346 + * We need to check what the partition is configured to.
  347 + * 1 and 2 match up to boot0 / boot1 and 7 is user data
  348 + * which is the first physical partition (0).
  349 + */
  350 + part = (mmc->part_config >> 3) & PART_ACCESS_MASK;
  351 +
  352 + if (part == 7)
  353 + part = 0;
  354 +#endif
  355 +
  356 + return part;
  357 +}
  358 +
338 359 int spl_mmc_load(struct spl_image_info *spl_image,
339 360 struct spl_boot_device *bootdev,
340 361 const char *filename,
... ... @@ -366,26 +387,7 @@
366 387 err = -EINVAL;
367 388 switch (boot_mode) {
368 389 case MMCSD_MODE_EMMCBOOT:
369   -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION
370   - part = CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION;
371   -#else
372   - /*
373   - * We need to check what the partition is configured to.
374   - * 1 and 2 match up to boot0 / boot1 and 7 is user data
375   - * which is the first physical partition (0).
376   - */
377   -#ifdef CONFIG_DUAL_BOOTLOADER
378   - /* Bootloader is stored in eMMC user partition for
379   - * dual bootloader.
380   - */
381   - part = 0;
382   -#else
383   - part = (mmc->part_config >> 3) & PART_ACCESS_MASK;
384   -
385   - if (part == 7)
386   - part = 0;
387   -#endif
388   -#endif
  390 + part = spl_mmc_emmc_boot_partition(mmc);
389 391  
390 392 if (CONFIG_IS_ENABLED(MMC_TINY))
391 393 err = mmc_switch_part(mmc, part);