Commit 35cce237 authored by Hugo Grostabussiat's avatar Hugo Grostabussiat

imx8m spl: load the M4 code from the boot partition

For eMMC booting from one of their hardware boot partitions, load the M4
binary from the hwpartition the SPL booted from.

This enables booting U-boot entirely from the eMMC boot1 or boot2
hwpartitions, thus keeping the bootloader and all the SoC-specific boot
black magic out of the way of the user.
parent ef141389
......@@ -278,10 +278,13 @@ static struct mmc *prepare_mmc_boot_device(void)
struct mmc *mmc;
int err;
int boot_device;
int boot_mode;
__maybe_unused int part;
printf("Finding MMC device\n");
boot_device = spl_boot_device();
boot_mode = spl_boot_mode(boot_device);
err = spl_mmc_find_device(&mmc, boot_device);
if (err) {
......@@ -294,6 +297,26 @@ static struct mmc *prepare_mmc_boot_device(void)
printf("spl: mmc init failed with error: %d\n", err);
return NULL;
}
/* Switch to the same partition as where the SPL is stored */
if (boot_mode == MMCSD_MODE_EMMCBOOT) {
int part;
part = (mmc->part_config >> 3) & PART_ACCESS_MASK;
if (part == 7)
part = 0;
printf("spl: switching to mmc hwpartition %d\n", part);
if (CONFIG_IS_ENABLED(MMC_TINY)) {
err = mmc_switch_part(mmc, part);
} else {
err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), part);
}
if (err) {
printf("spl: mmc partition switch failed\n");
return NULL;
}
}
return mmc;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment