summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorLuo Ji <ji.luo@nxp.com>2018-06-08 10:31:11 +0800
committerJi Luo <ji.luo@nxp.com>2018-08-20 21:31:28 +0800
commitdbcf1e3cc079d2f1b3df6c4c9ec3a34d0c05eb4c (patch)
tree65685970179ebf242d0a49e14fbd4108d85beda9 /common
parent4cfd7437ac44f7bf64650e1f95628624d7eb79b2 (diff)
[iot] Support dual bootloader in SPL
Move the A/B slot check to SPL, the A/B slot switch workflow is just like what we have in libavb_ab. Test: A/B select works fine on imx8m. Change-Id: Ie3d827a9be0298b491bf2bc8d48833597fd70e90 Signed-off-by: Luo Ji <ji.luo@nxp.com>
Diffstat (limited to 'common')
-rw-r--r--common/spl/spl_mmc.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 4b9be0dc4d..150886c1a8 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -4,6 +4,8 @@
*
* Aneesh V <aneesh@ti.com>
*
+ * Copyright 2018 NXP
+ *
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
@@ -18,7 +20,7 @@
DECLARE_GLOBAL_DATA_PTR;
-static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc,
+int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc,
ulong sector, struct image_header *header)
{
u32 image_size_sectors;
@@ -44,7 +46,7 @@ static int mmc_load_legacy(struct spl_image_info *spl_image, struct mmc *mmc,
return 0;
}
-static ulong h_spl_load_read(struct spl_load_info *load, ulong sector,
+ulong h_spl_load_read(struct spl_load_info *load, ulong sector,
ulong count, void *buf)
{
struct mmc *mmc = load->dev;
@@ -52,9 +54,15 @@ static ulong h_spl_load_read(struct spl_load_info *load, ulong sector,
return blk_dread(mmc_get_blk_desc(mmc), sector, count, buf);
}
+#ifdef CONFIG_DUAL_BOOTLOADER
+/* Pre-declaration of mmc_load_image_raw_sector_dual_uboot().
+ */
+extern int mmc_load_image_raw_sector_dual_uboot(struct spl_image_info *spl_image,
+ struct mmc *mmc);
+#else
static __maybe_unused
int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
- struct mmc *mmc, unsigned long sector)
+ struct mmc *mmc, unsigned long sector)
{
struct image_header *header = (struct image_header *)(CONFIG_SYS_TEXT_BASE -
sizeof(struct image_header));
@@ -98,6 +106,8 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
return 0;
}
+#endif /* CONFIG_DUAL_BOOTLOADER */
+
static int spl_mmc_get_device_index(u32 boot_device)
{
switch (boot_device) {
@@ -329,10 +339,15 @@ int spl_mmc_load_image(struct spl_image_info *spl_image,
* 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
if (CONFIG_IS_ENABLED(MMC_TINY))
err = mmc_switch_part(mmc, part);
@@ -361,8 +376,13 @@ int spl_mmc_load_image(struct spl_image_info *spl_image,
return err;
#endif
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
+#ifdef CONFIG_DUAL_BOOTLOADER
+ err = mmc_load_image_raw_sector_dual_uboot(spl_image,
+ mmc);
+#else
err = mmc_load_image_raw_sector(spl_image, mmc,
spl_mmc_get_uboot_raw_sector(mmc));
+#endif
if (!err)
return err;
#endif