diff mbox

[U-Boot,2/2] spl: MMC U-Boot image load from raw partition

Message ID 1415484896-28928-3-git-send-email-contact@paulk.fr
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Paul Kocialkowski Nov. 8, 2014, 10:14 p.m. UTC
Raw images of U-Boot can be stored inside MMC partitions, so it makes sense to
read the partition table, looking for a partition number instead of using
a fixed sector address.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 README               |    4 ++++
 common/spl/spl_mmc.c |   26 +++++++++++++++++++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)

Comments

Tom Rini Nov. 10, 2014, 6:46 p.m. UTC | #1
On Sat, Nov 08, 2014 at 11:14:56PM +0100, Paul Kocialkowski wrote:
> Raw images of U-Boot can be stored inside MMC partitions, so it makes sense to
> read the partition table, looking for a partition number instead of using
> a fixed sector address.
> 
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>

Reviewed-by: Tom Rini <trini@ti.com>
Tom Rini Dec. 8, 2014, 9:41 p.m. UTC | #2
On Sat, Nov 08, 2014 at 11:14:56PM +0100, Paul Kocialkowski wrote:

> Raw images of U-Boot can be stored inside MMC partitions, so it makes sense to
> read the partition table, looking for a partition number instead of using
> a fixed sector address.
> 
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> Reviewed-by: Tom Rini <trini@ti.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/README b/README
index 0b5fad9..5444b2e 100644
--- a/README
+++ b/README
@@ -3550,6 +3550,10 @@  FIT uImage format:
 		Address and partition on the MMC to load U-Boot from
 		when the MMC is being used in raw mode.
 
+		CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
+		Partition on the MMC to load U-Boot from when the MMC is being
+		used in raw mode
+
 		CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR
 		Sector to load kernel uImage from when MMC is being
 		used in raw mode (for Falcon mode)
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index f9c3851..31ddcdc 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -15,7 +15,7 @@ 
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int mmc_load_image_raw(struct mmc *mmc, unsigned long sector)
+static int mmc_load_image_raw_sector(struct mmc *mmc, unsigned long sector)
 {
 	unsigned long err;
 	u32 image_size_sectors;
@@ -51,6 +51,20 @@  end:
 	return (err == 0);
 }
 
+static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
+{
+	disk_partition_t info;
+
+	if (get_partition_info(&mmc->block_dev, partition, &info)) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+		printf("spl: partition error\n");
+#endif
+		return -1;
+	}
+
+	return mmc_load_image_raw_sector(mmc, info.start);
+}
+
 #ifdef CONFIG_SPL_OS_BOOT
 static int mmc_load_image_raw_os(struct mmc *mmc)
 {
@@ -64,7 +78,8 @@  static int mmc_load_image_raw_os(struct mmc *mmc)
 		return -1;
 	}
 
-	return mmc_load_image_raw(mmc, CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
+	return mmc_load_image_raw_sector(mmc,
+						CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
 }
 #endif
 
@@ -98,8 +113,13 @@  void spl_mmc_load_image(void)
 #ifdef CONFIG_SPL_OS_BOOT
 		if (spl_start_uboot() || mmc_load_image_raw_os(mmc))
 #endif
-		err = mmc_load_image_raw(mmc,
+#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
+		err = mmc_load_image_raw_partition(mmc,
+			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
+#else
+		err = mmc_load_image_raw_sector(mmc,
 			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
+#endif
 #if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
 	} else if (boot_mode == MMCSD_MODE_FS) {
 		debug("boot mode - FS\n");