All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature
@ 2015-11-08 15:11 Nikita Kiryanov
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 01/13] spl: nand: remove code duplication Nikita Kiryanov
                   ` (12 more replies)
  0 siblings, 13 replies; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

This series has two parts: patches 1-7 perform refactors aimed at reducing the
ifdef complexity of SPL mmc code (and some nand as well). This refactor also
addresses a few design issues I noticed while working on the refactor.

Image size comparison for arm modules can be seen here:
http://patchwork.ozlabs.org/patch/534387/
Since the changes in V2 are minimal, the V1 results should still be valid for
the V2 as well.

The rest of the series introduces a new SPL feature that allows board code to
define a list of boot devices that SPL will try before failing (instead of the
only one device it attempts now). This feature is useful for implementing
fallbacks, as well as reacting to bootROM sequences. For example:

On CM-FX6, if boot from the alternate boot device (MMC) fails, the bootROM
proceeds to try boot from SPI flash. If the SPI flash boot is succesful, SPL
will still try to load U-Boot from MMC, instead of from the actual boot device
SPI flash), and probably fail and hang. The alternate boot feature makes it
possible for SPL to follow the MMC boot attempt with boot from the SPI flash.
The CM-FX6 based miniature PC Utilite depends on this capability for its SPI
flash boot to work, since SPI flash boot is only attempted if MMC boot fails.

Finally, patch 13 makes SPL look at the specific BOOT_DEVICE_MMCx, and search
for the correct mmc device, instead of always going for mmc0.

This series was compile tested for arm and powerpc (patches 1-12).
Patch 13 compile tested for sunxi.
Tested on CM-FX6.

Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Tom Rini <trini@konsulko.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Otavio Salvador <otavio.salvador@ossystems.com.br>

Changes in V4:
- Rebased over current mainline. Rerun compile test for arm and powerpc
- Fixed typo in a commit message
- Moved announce_boot_device() code to after #ifndef BOOT_DEVICE_NONE
- Replaced one puts with printf

Changes in V3:
- Added documentation for spl_board_load_image().
- Reworked announce_boot_device() to make the code less repititive by
  utilizing a table of boot_device --> name.

Changes in V2:
- Per request I went over the changes to see if they should cause documentation
  updates or board updates, but found none to be necessary.
- Slight modification in patch 2 (and consequentially patch 8): removal of
  hang() in default switch case, and enclosing of default case in #ifdef
  LIBCONFIG to avoid compiler complaints if LIBCONFIG support not compiled in.
- Patch 13 is a new patch which makes SPL look at the value of BOOT_DEVICE_MMCx
  instead of always working with mmc0. A hack in sunxi boards that attempted to
  circumvent this issue is thus removed.
- Rebased over current mainline.


Nikita Kiryanov (13):
  spl: nand: remove code duplication
  spl: mmc: add break statements in spl_mmc_load_image()
  spl: mmc: refactor device location code to its own function
  spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check
  spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
    check
  spl: mmc: move fs boot into its own function
  spl: mmc: get rid of emmc boot code duplication
  spl: change return values of spl_*_load_image()
  common: spl: move image load to its own function
  spl: add support for alternative boot device
  spl: announce boot devices
  arm: mx6: cm-fx6: define fallback boot devices for spl
  spl: mmc: add support for BOOT_DEVICE_MMC2

 arch/arm/cpu/armv7/sunxi/board.c |  14 +-
 arch/arm/include/asm/spl.h       |  10 +-
 board/compulab/cm_fx6/spl.c      |  19 +--
 common/spl/spl.c                 | 194 +++++++++++++++++++-------
 common/spl/spl_ext.c             |   6 +
 common/spl/spl_fat.c             |   6 +
 common/spl/spl_mmc.c             | 290 ++++++++++++++++++++++++---------------
 common/spl/spl_nand.c            |  47 ++++---
 common/spl/spl_net.c             |   9 +-
 common/spl/spl_nor.c             |   6 +-
 common/spl/spl_onenand.c         |   4 +-
 common/spl/spl_sata.c            |  11 +-
 common/spl/spl_usb.c             |  17 ++-
 common/spl/spl_ymodem.c          |   5 +-
 drivers/mtd/spi/spi_spl_load.c   |  17 ++-
 include/configs/cm_fx6.h         |   1 -
 include/spl.h                    |  18 +--
 17 files changed, 446 insertions(+), 228 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 01/13] spl: nand: remove code duplication
  2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
@ 2015-11-08 15:11 ` Nikita Kiryanov
  2015-11-16 11:50   ` Heiko Schocher
  2015-11-18 22:33   ` [U-Boot] [U-Boot,V4,01/13] " Tom Rini
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 02/13] spl: mmc: add break statements in spl_mmc_load_image() Nikita Kiryanov
                   ` (11 subsequent siblings)
  12 siblings, 2 replies; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

Remove code duplication in spl_nand_load_image().

No functional changes.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Scott Wood <scottwood@freescale.com>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Acked-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Changes in V4:
	- No changes.

Changes in V3:
	- No changes.

Changes in V2:
	- No changes.

 common/spl/spl_nand.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index b8c369d..6e4e641 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -22,6 +22,19 @@ void spl_nand_load_image(void)
 	nand_deselect();
 }
 #else
+static int spl_nand_load_element(int offset, struct image_header *header)
+{
+	int err;
+
+	err = nand_spl_load_image(offset, sizeof(*header), (void *)header);
+	if (err)
+		return err;
+
+	spl_parse_image_header(header);
+	return nand_spl_load_image(offset, spl_image.size,
+				   (void *)spl_image.load_addr);
+}
+
 void spl_nand_load_image(void)
 {
 	struct image_header *header;
@@ -73,25 +86,13 @@ void spl_nand_load_image(void)
 	}
 #endif
 #ifdef CONFIG_NAND_ENV_DST
-	nand_spl_load_image(CONFIG_ENV_OFFSET,
-		sizeof(*header), (void *)header);
-	spl_parse_image_header(header);
-	nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
-		(void *)spl_image.load_addr);
+	spl_nand_load_element(CONFIG_ENV_OFFSET, header);
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
-		sizeof(*header), (void *)header);
-	spl_parse_image_header(header);
-	nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
-		(void *)spl_image.load_addr);
+	spl_nand_load_element(CONFIG_ENV_OFFSET_REDUND, header);
 #endif
 #endif
 	/* Load u-boot */
-	nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
-		sizeof(*header), (void *)header);
-	spl_parse_image_header(header);
-	nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
-		spl_image.size, (void *)(unsigned long)spl_image.load_addr);
+	spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header);
 	nand_deselect();
 }
 #endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 02/13] spl: mmc: add break statements in spl_mmc_load_image()
  2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 01/13] spl: nand: remove code duplication Nikita Kiryanov
@ 2015-11-08 15:11 ` Nikita Kiryanov
  2015-11-18 22:33   ` [U-Boot] [U-Boot, V4, " Tom Rini
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 03/13] spl: mmc: refactor device location code to its own function Nikita Kiryanov
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

The original intention of the mmc load_image() function was to try multiple
boot modes before failing. This is evident by the lack of break statements
in the switch, and the following line in the default case:
puts("spl: mmc: no boot mode left to try\n");

This implementation is problematic because:
- The availability of alternative boot modes is very arbitrary since it
depends on the specific order of the switch cases. If your boot mode happens to
be the first case, then you'll have a bunch of other boot modes as alternatives.
If it happens to be the last case, then you have none.
- Opting in/out is tied to config options, so the only way for you to prevent an
alternative boot mode from being attempted is to give up on the feature completely.
- This implementation makes the code more complicated and difficult to
understand.

Address these issues by inserting a break statements between the cases to make the
function try only one boot mode.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Paul Kocialkowski <contact@paulk.fr>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
Changes in V4:
	- No changes.

Changes in V3:
	- No changes.

Changes in V2:
	- Removed hang() in default cases, moved default case into ifdef
	  LIBCOMMON.

 common/spl/spl_mmc.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index ce58c58..6011f77 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -164,6 +164,7 @@ void spl_mmc_load_image(void)
 		if (!err)
 			return;
 #endif
+		break;
 	case MMCSD_MODE_FS:
 		debug("spl: mmc boot mode: fs\n");
 
@@ -203,6 +204,7 @@ void spl_mmc_load_image(void)
 #endif
 #endif
 #endif
+		break;
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
 	case MMCSD_MODE_EMMCBOOT:
 		/*
@@ -240,15 +242,14 @@ void spl_mmc_load_image(void)
 		if (!err)
 			return;
 #endif
+		break;
 #endif
 	case MMCSD_MODE_UNDEFINED:
-	default:
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
-		if (err)
-			puts("spl: mmc: no boot mode left to try\n");
-		else
-			puts("spl: mmc: wrong boot mode\n");
+	default:
+		puts("spl: mmc: wrong boot mode\n");
 #endif
-		hang();
 	}
+
+	hang();
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 03/13] spl: mmc: refactor device location code to its own function
  2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 01/13] spl: nand: remove code duplication Nikita Kiryanov
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 02/13] spl: mmc: add break statements in spl_mmc_load_image() Nikita Kiryanov
@ 2015-11-08 15:11 ` Nikita Kiryanov
  2015-11-08 21:19   ` Tom Rini
  2015-11-18 22:33   ` [U-Boot] [U-Boot, V4, " Tom Rini
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 04/13] spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check Nikita Kiryanov
                   ` (9 subsequent siblings)
  12 siblings, 2 replies; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

Simplify spl_mmc_load_image() code by moving the part that finds the mmc device
into its own function spl_mmc_find_device(), available in two flavors: DM and
non-DM.

This refactor fixes a bug in which an error in the device location sequence
does not necessarily aborts the rest of the code. With this refactor, we fail
the moment there is an error.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Paul Kocialkowski <contact@paulk.fr>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Changes in V4:
	- s/puts/printf/

Changes in V3:
	- No changes.

Changes in V2:
	- No changes.

 common/spl/spl_mmc.c | 77 +++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 55 insertions(+), 22 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 6011f77..9d3c09e 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -11,6 +11,7 @@
 #include <spl.h>
 #include <linux/compiler.h>
 #include <asm/u-boot.h>
+#include <errno.h>
 #include <mmc.h>
 #include <image.h>
 
@@ -59,6 +60,58 @@ end:
 	return 0;
 }
 
+#ifdef CONFIG_DM_MMC
+static int spl_mmc_find_device(struct mmc **mmc)
+{
+	struct udevice *dev;
+	int err;
+
+	err = mmc_initialize(NULL);
+	if (err) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+		printf("spl: could not initialize mmc. error: %d\n", err);
+#endif
+		return err;
+	}
+
+	err = uclass_get_device(UCLASS_MMC, 0, &dev);
+	if (err) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+		printf("spl: could not find mmc device. error: %d\n", err);
+#endif
+		return err;
+	}
+
+	*mmc = NULL;
+	*mmc = mmc_get_mmc_dev(dev);
+	return *mmc != NULL ? 0 : -ENODEV;
+}
+#else
+static int spl_mmc_find_device(struct mmc **mmc)
+{
+	int err;
+
+	err = mmc_initialize(gd->bd);
+	if (err) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+		printf("spl: could not initialize mmc. error: %d\n", err);
+#endif
+		return err;
+	}
+
+	/* We register only one device. So, the dev id is always 0 */
+	*mmc = find_mmc_device(0);
+	if (!*mmc) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+		puts("spl: mmc device not found\n");
+#endif
+		return -ENODEV;
+	}
+
+	return 0;
+}
+#endif
+
 #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
 static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
 {
@@ -110,30 +163,10 @@ void spl_mmc_load_image(void)
 	int err = 0;
 	__maybe_unused int part;
 
-#ifdef CONFIG_DM_MMC
-	struct udevice *dev;
-
-	mmc_initialize(NULL);
-	err = uclass_get_device(UCLASS_MMC, 0, &dev);
-	mmc = NULL;
-	if (!err)
-		mmc = mmc_get_mmc_dev(dev);
-#else
-	mmc_initialize(gd->bd);
-
-	/* We register only one device. So, the dev id is always 0 */
-	mmc = find_mmc_device(0);
-	if (!mmc) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
-		puts("spl: mmc device not found\n");
-#endif
+	if (spl_mmc_find_device(&mmc))
 		hang();
-	}
-#endif
-
-	if (!err)
-		err = mmc_init(mmc);
 
+	err = mmc_init(mmc);
 	if (err) {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("spl: mmc init failed with error: %d\n", err);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 04/13] spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check
  2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
                   ` (2 preceding siblings ...)
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 03/13] spl: mmc: refactor device location code to its own function Nikita Kiryanov
@ 2015-11-08 15:11 ` Nikita Kiryanov
  2015-11-18 22:33   ` [U-Boot] [U-Boot, V4, " Tom Rini
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 05/13] spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION check Nikita Kiryanov
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

Implement default versions of falcon mode functions to make the
CONFIG_SPL_OS_BOOT check in spl_mmc_load_image() unnecessary, thus reducing
its #ifdef complexity.

No functional changes.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Paul Kocialkowski <contact@paulk.fr>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Guillaume GARDET <guillaume.gardet@free.fr>
Cc: Suriyan Ramasami <suriyan.r@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
Changes in V4:
	- No changes.

Changes in V3:
	- No changes.

Changes in V2:
	- No changes.

 common/spl/spl_ext.c |  6 ++++++
 common/spl/spl_fat.c |  6 ++++++
 common/spl/spl_mmc.c | 17 +++++++++--------
 3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index 9d37fd3..a42fbd0 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -6,6 +6,7 @@
 #include <spl.h>
 #include <asm/u-boot.h>
 #include <ext4fs.h>
+#include <errno.h>
 #include <image.h>
 
 #ifdef CONFIG_SPL_EXT_SUPPORT
@@ -135,5 +136,10 @@ defaults:
 	return spl_load_image_ext(block_dev, partition,
 			CONFIG_SPL_FS_LOAD_KERNEL_NAME);
 }
+#else
+int spl_load_image_ext_os(block_dev_desc_t *block_dev, int partition)
+{
+	return -ENOSYS;
+}
 #endif
 #endif
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index 350f7d9..0daadbe 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -13,6 +13,7 @@
 #include <spl.h>
 #include <asm/u-boot.h>
 #include <fat.h>
+#include <errno.h>
 #include <image.h>
 
 static int fat_registered;
@@ -119,5 +120,10 @@ defaults:
 	return spl_load_image_fat(block_dev, partition,
 			CONFIG_SPL_FS_LOAD_KERNEL_NAME);
 }
+#else
+int spl_load_image_fat_os(block_dev_desc_t *block_dev, int partition)
+{
+	return -ENOSYS;
+}
 #endif
 #endif
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 9d3c09e..837fa0d 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -154,6 +154,15 @@ static int mmc_load_image_raw_os(struct mmc *mmc)
 	return mmc_load_image_raw_sector(mmc,
 		CONFIG_SYS_MMCSD_RAW_MODE_KERNEL_SECTOR);
 }
+#else
+int spl_start_uboot(void)
+{
+	return 1;
+}
+static int mmc_load_image_raw_os(struct mmc *mmc)
+{
+	return -ENOSYS;
+}
 #endif
 
 void spl_mmc_load_image(void)
@@ -179,13 +188,11 @@ void spl_mmc_load_image(void)
 	case MMCSD_MODE_RAW:
 		debug("spl: mmc boot mode: raw\n");
 
-#ifdef CONFIG_SPL_OS_BOOT
 		if (!spl_start_uboot()) {
 			err = mmc_load_image_raw_os(mmc);
 			if (!err)
 				return;
 		}
-#endif
 #if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
 		err = mmc_load_image_raw_partition(mmc,
 			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
@@ -203,14 +210,12 @@ void spl_mmc_load_image(void)
 
 #ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
 #ifdef CONFIG_SPL_FAT_SUPPORT
-#ifdef CONFIG_SPL_OS_BOOT
 		if (!spl_start_uboot()) {
 			err = spl_load_image_fat_os(&mmc->block_dev,
 				CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
 			if (!err)
 				return;
 		}
-#endif
 #ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
 		err = spl_load_image_fat(&mmc->block_dev,
 					 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
@@ -220,14 +225,12 @@ void spl_mmc_load_image(void)
 #endif
 #endif
 #ifdef CONFIG_SPL_EXT_SUPPORT
-#ifdef CONFIG_SPL_OS_BOOT
 		if (!spl_start_uboot()) {
 			err = spl_load_image_ext_os(&mmc->block_dev,
 				CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
 			if (!err)
 				return;
 		}
-#endif
 #ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
 		err = spl_load_image_ext(&mmc->block_dev,
 					 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
@@ -257,13 +260,11 @@ void spl_mmc_load_image(void)
 			hang();
 		}
 
-#ifdef CONFIG_SPL_OS_BOOT
 		if (!spl_start_uboot()) {
 			err = mmc_load_image_raw_os(mmc);
 			if (!err)
 				return;
 		}
-#endif
 #if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
 		err = mmc_load_image_raw_partition(mmc,
 			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 05/13] spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION check
  2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
                   ` (3 preceding siblings ...)
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 04/13] spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check Nikita Kiryanov
@ 2015-11-08 15:11 ` Nikita Kiryanov
  2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 06/13] spl: mmc: move fs boot into its own function Nikita Kiryanov
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

Implement defaults for the raw partition image loading so that the #ifdef
CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION in spl_mmc_load_image() will no
longer be necessary.

This change makes it possible for mmc_load_image_raw_partition() and
mmc_load_image_raw_sector() to coexist.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Paul Kocialkowski <contact@paulk.fr>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
Changes in V4:
	- No changes.

Changes in V3:
	- No changes.

Changes in V2:
	- No changes.

 common/spl/spl_mmc.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 837fa0d..d646dc8 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -133,6 +133,12 @@ static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
 	return mmc_load_image_raw_sector(mmc, info.start);
 #endif
 }
+#else
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION -1
+static int mmc_load_image_raw_partition(struct mmc *mmc, int partition)
+{
+	return -ENOSYS;
+}
 #endif
 
 #ifdef CONFIG_SPL_OS_BOOT
@@ -193,12 +199,12 @@ void spl_mmc_load_image(void)
 			if (!err)
 				return;
 		}
-#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
+
 		err = mmc_load_image_raw_partition(mmc,
 			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
 		if (!err)
 			return;
-#elif defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
+#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
 		err = mmc_load_image_raw_sector(mmc,
 			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
 		if (!err)
@@ -265,12 +271,11 @@ void spl_mmc_load_image(void)
 			if (!err)
 				return;
 		}
-#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION)
 		err = mmc_load_image_raw_partition(mmc,
 			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
 		if (!err)
 			return;
-#elif defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
+#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
 		err = mmc_load_image_raw_sector(mmc,
 			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
 		if (!err)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 06/13] spl: mmc: move fs boot into its own function
  2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
                   ` (4 preceding siblings ...)
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 05/13] spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION check Nikita Kiryanov
@ 2015-11-08 15:11 ` Nikita Kiryanov
  2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 07/13] spl: mmc: get rid of emmc boot code duplication Nikita Kiryanov
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

Move the code that handles fs boot out of spl_mmc_load_image() and into its
own function to reduce the #ifdef complexity of spl_mmc_load_image().

No functional changes.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Paul Kocialkowski <contact@paulk.fr>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
Changes in V4:
	- Fixed typo in commit message.

Changes in V3:
	- No changes.

Changes in V2:
	- No changes.

 common/spl/spl_mmc.c | 81 +++++++++++++++++++++++++++++++++-------------------
 1 file changed, 51 insertions(+), 30 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index d646dc8..5dc576b 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -171,6 +171,55 @@ static int mmc_load_image_raw_os(struct mmc *mmc)
 }
 #endif
 
+#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
+int spl_mmc_do_fs_boot(struct mmc *mmc)
+{
+	int err = -ENOSYS;
+
+#ifdef CONFIG_SPL_FAT_SUPPORT
+	if (!spl_start_uboot()) {
+		err = spl_load_image_fat_os(&mmc->block_dev,
+			CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
+		if (!err)
+			return err;
+	}
+#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
+	err = spl_load_image_fat(&mmc->block_dev,
+				 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
+				 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
+	if (!err)
+		return err;
+#endif
+#endif
+#ifdef CONFIG_SPL_EXT_SUPPORT
+	if (!spl_start_uboot()) {
+		err = spl_load_image_ext_os(&mmc->block_dev,
+			CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
+		if (!err)
+			return err;
+	}
+#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
+	err = spl_load_image_ext(&mmc->block_dev,
+				 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
+				 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
+	if (!err)
+		return err;
+#endif
+#endif
+
+#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
+	err = -ENOENT;
+#endif
+
+	return err;
+}
+#else
+int spl_mmc_do_fs_boot(struct mmc *mmc)
+{
+	return -ENOSYS;
+}
+#endif
+
 void spl_mmc_load_image(void)
 {
 	struct mmc *mmc;
@@ -214,38 +263,10 @@ void spl_mmc_load_image(void)
 	case MMCSD_MODE_FS:
 		debug("spl: mmc boot mode: fs\n");
 
-#ifdef CONFIG_SYS_MMCSD_FS_BOOT_PARTITION
-#ifdef CONFIG_SPL_FAT_SUPPORT
-		if (!spl_start_uboot()) {
-			err = spl_load_image_fat_os(&mmc->block_dev,
-				CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
-			if (!err)
-				return;
-		}
-#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
-		err = spl_load_image_fat(&mmc->block_dev,
-					 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
-					 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
-		if (!err)
-			return;
-#endif
-#endif
-#ifdef CONFIG_SPL_EXT_SUPPORT
-		if (!spl_start_uboot()) {
-			err = spl_load_image_ext_os(&mmc->block_dev,
-				CONFIG_SYS_MMCSD_FS_BOOT_PARTITION);
-			if (!err)
-				return;
-		}
-#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME
-		err = spl_load_image_ext(&mmc->block_dev,
-					 CONFIG_SYS_MMCSD_FS_BOOT_PARTITION,
-					 CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
+		err = spl_mmc_do_fs_boot(mmc);
 		if (!err)
 			return;
-#endif
-#endif
-#endif
+
 		break;
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
 	case MMCSD_MODE_EMMCBOOT:
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 07/13] spl: mmc: get rid of emmc boot code duplication
  2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
                   ` (5 preceding siblings ...)
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 06/13] spl: mmc: move fs boot into its own function Nikita Kiryanov
@ 2015-11-08 15:11 ` Nikita Kiryanov
  2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 08/13] spl: change return values of spl_*_load_image() Nikita Kiryanov
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

Get rid of emmc boot code duplication in spl_mmc_load_image() using a switch
case fallthrough into MMCSD_MODE_RAW. Since the #ifdef CONFIG_SUPPORT_EMMC_BOOT
check is not really necessary, remove it in the process.

No functional changes.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Paul Kocialkowski <contact@paulk.fr>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
Changes in V4:
	- No changes.

Changes in V3:
	- No changes.

Changes in V2:
	- No changes.

 common/spl/spl_mmc.c | 54 ++++++++++++++++++----------------------------------
 1 file changed, 18 insertions(+), 36 deletions(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 5dc576b..7d100fa 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -240,6 +240,24 @@ void spl_mmc_load_image(void)
 
 	boot_mode = spl_boot_mode();
 	switch (boot_mode) {
+	case MMCSD_MODE_EMMCBOOT:
+			/*
+			 * 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;
+
+			if (mmc_switch_part(0, part)) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+				puts("spl: mmc partition switch failed\n");
+#endif
+				hang();
+			}
+			/* Fall through */
 	case MMCSD_MODE_RAW:
 		debug("spl: mmc boot mode: raw\n");
 
@@ -268,42 +286,6 @@ void spl_mmc_load_image(void)
 			return;
 
 		break;
-#ifdef CONFIG_SUPPORT_EMMC_BOOT
-	case MMCSD_MODE_EMMCBOOT:
-		/*
-		 * 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;
-
-		if (mmc_switch_part(0, part)) {
-#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
-			puts("spl: mmc partition switch failed\n");
-#endif
-			hang();
-		}
-
-		if (!spl_start_uboot()) {
-			err = mmc_load_image_raw_os(mmc);
-			if (!err)
-				return;
-		}
-		err = mmc_load_image_raw_partition(mmc,
-			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
-		if (!err)
-			return;
-#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
-		err = mmc_load_image_raw_sector(mmc,
-			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
-		if (!err)
-			return;
-#endif
-		break;
-#endif
 	case MMCSD_MODE_UNDEFINED:
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 	default:
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 08/13] spl: change return values of spl_*_load_image()
  2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
                   ` (6 preceding siblings ...)
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 07/13] spl: mmc: get rid of emmc boot code duplication Nikita Kiryanov
@ 2015-11-08 15:11 ` Nikita Kiryanov
  2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 09/13] common: spl: move image load to its own function Nikita Kiryanov
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

Make spl_*_load_image() functions return a value instead of
hanging if a problem is encountered. This enables main spl code
to make the decision whether to hang or not, thus preparing
it to support alternative boot devices.

Some boot devices (namely nand and spi) do not hang on error.
Instead, they return normally and SPL proceeds to boot the
contents of the load address. This is considered a bug and
is rectified by hanging on error for these devices as well.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Ian Campbell <ijc@hellion.org.uk>
Cc: Hans De Goede <hdegoede@redhat.com>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Jagan Teki <jteki@openedev.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
Changes in V4:
	- No changes.

Changes in V3:
	- Added documentation for spl_board_load_image().

Changes in V2:
	- Minor collateral adjustments from changes in patch 2 (only one return
	  statement at the end of spl_mmc_load_image).

 arch/arm/cpu/armv7/sunxi/board.c |  4 +++-
 arch/arm/include/asm/spl.h       | 10 ++++++++--
 common/spl/spl.c                 | 43 +++++++++++++++++++++++++++-------------
 common/spl/spl_mmc.c             | 26 ++++++++++++++----------
 common/spl/spl_nand.c            | 18 +++++++++++------
 common/spl/spl_net.c             |  9 ++++++---
 common/spl/spl_nor.c             |  6 ++++--
 common/spl/spl_onenand.c         |  4 +++-
 common/spl/spl_sata.c            | 11 +++++++---
 common/spl/spl_usb.c             | 17 ++++++++++------
 common/spl/spl_ymodem.c          |  5 +++--
 drivers/mtd/spi/spi_spl_load.c   | 17 +++++++++++-----
 include/spl.h                    | 18 ++++++++---------
 13 files changed, 123 insertions(+), 65 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
index 4785ac6..9b5c46b 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -95,10 +95,12 @@ static int gpio_init(void)
 	return 0;
 }
 
-void spl_board_load_image(void)
+int spl_board_load_image(void)
 {
 	debug("Returning to FEL sp=%x, lr=%x\n", fel_stash.sp, fel_stash.lr);
 	return_to_fel(fel_stash.sp, fel_stash.lr);
+
+	return 0;
 }
 
 void s_init(void)
diff --git a/arch/arm/include/asm/spl.h b/arch/arm/include/asm/spl.h
index 6db405d..5c5d33f 100644
--- a/arch/arm/include/asm/spl.h
+++ b/arch/arm/include/asm/spl.h
@@ -31,8 +31,14 @@ enum {
 };
 #endif
 
-/* Board-specific load method */
-void spl_board_load_image(void);
+/**
+ * Board specific load method for boards that have a special way of loading
+ * U-Boot, which does not fit with the existing SPL code.
+ *
+ * @return 0 on success, negative errno value on failure.
+ */
+
+int spl_board_load_image(void);
 
 /* Linker symbols. */
 extern char __bss_start[], __bss_end[];
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 4b319d6..ff1bad2 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -132,7 +132,7 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 }
 
 #ifdef CONFIG_SPL_RAM_DEVICE
-static void spl_ram_load_image(void)
+static int spl_ram_load_image(void)
 {
 	const struct image_header *header;
 
@@ -145,6 +145,8 @@ static void spl_ram_load_image(void)
 		(CONFIG_SYS_TEXT_BASE -	sizeof(struct image_header));
 
 	spl_parse_image_header(header);
+
+	return 0;
 }
 #endif
 
@@ -208,68 +210,81 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	switch (boot_device) {
 #ifdef CONFIG_SPL_RAM_DEVICE
 	case BOOT_DEVICE_RAM:
-		spl_ram_load_image();
+		if (spl_ram_load_image())
+			hang();
 		break;
 #endif
 #ifdef CONFIG_SPL_MMC_SUPPORT
 	case BOOT_DEVICE_MMC1:
 	case BOOT_DEVICE_MMC2:
 	case BOOT_DEVICE_MMC2_2:
-		spl_mmc_load_image();
+		if (spl_mmc_load_image())
+			hang();
 		break;
 #endif
 #ifdef CONFIG_SPL_NAND_SUPPORT
 	case BOOT_DEVICE_NAND:
-		spl_nand_load_image();
+		if (spl_nand_load_image())
+			hang();
 		break;
 #endif
 #ifdef CONFIG_SPL_ONENAND_SUPPORT
 	case BOOT_DEVICE_ONENAND:
-		spl_onenand_load_image();
+		if (spl_onenand_load_image())
+			hang();
 		break;
 #endif
 #ifdef CONFIG_SPL_NOR_SUPPORT
 	case BOOT_DEVICE_NOR:
-		spl_nor_load_image();
+		if (spl_nor_load_image())
+			hang();
 		break;
 #endif
 #ifdef CONFIG_SPL_YMODEM_SUPPORT
 	case BOOT_DEVICE_UART:
-		spl_ymodem_load_image();
+		if (spl_ymodem_load_image())
+			hang();
 		break;
 #endif
 #ifdef CONFIG_SPL_SPI_SUPPORT
 	case BOOT_DEVICE_SPI:
-		spl_spi_load_image();
+		if (spl_spi_load_image())
+			hang();
 		break;
 #endif
 #ifdef CONFIG_SPL_ETH_SUPPORT
 	case BOOT_DEVICE_CPGMAC:
 #ifdef CONFIG_SPL_ETH_DEVICE
-		spl_net_load_image(CONFIG_SPL_ETH_DEVICE);
+		if (spl_net_load_image(CONFIG_SPL_ETH_DEVICE))
+			hang();
 #else
-		spl_net_load_image(NULL);
+		if (spl_net_load_image(NULL))
+			hang();
 #endif
 		break;
 #endif
 #ifdef CONFIG_SPL_USBETH_SUPPORT
 	case BOOT_DEVICE_USBETH:
-		spl_net_load_image("usb_ether");
+		if (spl_net_load_image("usb_ether"))
+			hang();
 		break;
 #endif
 #ifdef CONFIG_SPL_USB_SUPPORT
 	case BOOT_DEVICE_USB:
-		spl_usb_load_image();
+		if (spl_usb_load_image())
+			hang();
 		break;
 #endif
 #ifdef CONFIG_SPL_SATA_SUPPORT
 	case BOOT_DEVICE_SATA:
-		spl_sata_load_image();
+		if (spl_sata_load_image())
+			hang();
 		break;
 #endif
 #ifdef CONFIG_SPL_BOARD_LOAD_IMAGE
 	case BOOT_DEVICE_BOARD:
-		spl_board_load_image();
+		if (spl_board_load_image())
+			hang();
 		break;
 #endif
 	default:
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index 7d100fa..b68190a 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <spl.h>
 #include <linux/compiler.h>
+#include <errno.h>
 #include <asm/u-boot.h>
 #include <errno.h>
 #include <mmc.h>
@@ -220,25 +221,27 @@ int spl_mmc_do_fs_boot(struct mmc *mmc)
 }
 #endif
 
-void spl_mmc_load_image(void)
+int spl_mmc_load_image(void)
 {
 	struct mmc *mmc;
 	u32 boot_mode;
 	int err = 0;
 	__maybe_unused int part;
 
-	if (spl_mmc_find_device(&mmc))
-		hang();
+	err = spl_mmc_find_device(&mmc);
+	if (err)
+		return err;
 
 	err = mmc_init(mmc);
 	if (err) {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("spl: mmc init failed with error: %d\n", err);
 #endif
-		hang();
+		return err;
 	}
 
 	boot_mode = spl_boot_mode();
+	err = -EINVAL;
 	switch (boot_mode) {
 	case MMCSD_MODE_EMMCBOOT:
 			/*
@@ -251,11 +254,12 @@ void spl_mmc_load_image(void)
 			if (part == 7)
 				part = 0;
 
-			if (mmc_switch_part(0, part)) {
+			err = mmc_switch_part(0, part);
+			if (err) {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 				puts("spl: mmc partition switch failed\n");
 #endif
-				hang();
+				return err;
 			}
 			/* Fall through */
 	case MMCSD_MODE_RAW:
@@ -264,18 +268,18 @@ void spl_mmc_load_image(void)
 		if (!spl_start_uboot()) {
 			err = mmc_load_image_raw_os(mmc);
 			if (!err)
-				return;
+				return err;
 		}
 
 		err = mmc_load_image_raw_partition(mmc,
 			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
 		if (!err)
-			return;
+			return err;
 #if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR)
 		err = mmc_load_image_raw_sector(mmc,
 			CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
 		if (!err)
-			return;
+			return err;
 #endif
 		break;
 	case MMCSD_MODE_FS:
@@ -283,7 +287,7 @@ void spl_mmc_load_image(void)
 
 		err = spl_mmc_do_fs_boot(mmc);
 		if (!err)
-			return;
+			return err;
 
 		break;
 	case MMCSD_MODE_UNDEFINED:
@@ -293,5 +297,5 @@ void spl_mmc_load_image(void)
 #endif
 	}
 
-	hang();
+	return err;
 }
diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index 6e4e641..ad69db7 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -11,7 +11,7 @@
 #include <nand.h>
 
 #if defined(CONFIG_SPL_NAND_RAW_ONLY)
-void spl_nand_load_image(void)
+int spl_nand_load_image(void)
 {
 	nand_init();
 
@@ -20,6 +20,8 @@ void spl_nand_load_image(void)
 			    (void *)CONFIG_SYS_NAND_U_BOOT_DST);
 	spl_set_header_raw_uboot();
 	nand_deselect();
+
+	return 0;
 }
 #else
 static int spl_nand_load_element(int offset, struct image_header *header)
@@ -35,8 +37,9 @@ static int spl_nand_load_element(int offset, struct image_header *header)
 				   (void *)spl_image.load_addr);
 }
 
-void spl_nand_load_image(void)
+int spl_nand_load_image(void)
 {
+	int err;
 	struct image_header *header;
 	int *src __attribute__((unused));
 	int *dst __attribute__((unused));
@@ -73,10 +76,12 @@ void spl_nand_load_image(void)
 		spl_parse_image_header(header);
 		if (header->ih_os == IH_OS_LINUX) {
 			/* happy - was a linux */
-			nand_spl_load_image(CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
-				spl_image.size, (void *)spl_image.load_addr);
+			err = nand_spl_load_image(
+				CONFIG_SYS_NAND_SPL_KERNEL_OFFS,
+				spl_image.size,
+				(void *)spl_image.load_addr);
 			nand_deselect();
-			return;
+			return err;
 		} else {
 			puts("The Expected Linux image was not "
 				"found. Please check your NAND "
@@ -92,7 +97,8 @@ void spl_nand_load_image(void)
 #endif
 #endif
 	/* Load u-boot */
-	spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header);
+	err = spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header);
 	nand_deselect();
+	return err;
 }
 #endif
diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c
index 217a435..63b20d8 100644
--- a/common/spl/spl_net.c
+++ b/common/spl/spl_net.c
@@ -8,12 +8,13 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 #include <common.h>
+#include <errno.h>
 #include <spl.h>
 #include <net.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-void spl_net_load_image(const char *device)
+int spl_net_load_image(const char *device)
 {
 	int rv;
 
@@ -24,14 +25,16 @@ void spl_net_load_image(const char *device)
 	rv = eth_initialize();
 	if (rv == 0) {
 		printf("No Ethernet devices found\n");
-		hang();
+		return -ENODEV;
 	}
 	if (device)
 		setenv("ethact", device);
 	rv = net_loop(BOOTP);
 	if (rv < 0) {
 		printf("Problem booting with BOOTP\n");
-		hang();
+		return rv;
 	}
 	spl_parse_image_header((struct image_header *)load_addr);
+
+	return 0;
 }
diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c
index c2fee01..e08afe2 100644
--- a/common/spl/spl_nor.c
+++ b/common/spl/spl_nor.c
@@ -7,7 +7,7 @@
 #include <common.h>
 #include <spl.h>
 
-void spl_nor_load_image(void)
+int spl_nor_load_image(void)
 {
 	/*
 	 * Loading of the payload to SDRAM is done with skipping of
@@ -43,7 +43,7 @@ void spl_nor_load_image(void)
 			       (void *)(CONFIG_SYS_FDT_BASE),
 			       (16 << 10));
 
-			return;
+			return 0;
 		} else {
 			puts("The Expected Linux image was not found.\n"
 			     "Please check your NOR configuration.\n"
@@ -62,4 +62,6 @@ void spl_nor_load_image(void)
 	memcpy((void *)spl_image.load_addr,
 	       (void *)(CONFIG_SYS_UBOOT_BASE + sizeof(struct image_header)),
 	       spl_image.size);
+
+	return 0;
 }
diff --git a/common/spl/spl_onenand.c b/common/spl/spl_onenand.c
index d8d8097..af7d82e 100644
--- a/common/spl/spl_onenand.c
+++ b/common/spl/spl_onenand.c
@@ -14,7 +14,7 @@
 #include <asm/io.h>
 #include <onenand_uboot.h>
 
-void spl_onenand_load_image(void)
+int spl_onenand_load_image(void)
 {
 	struct image_header *header;
 
@@ -28,4 +28,6 @@ void spl_onenand_load_image(void)
 	spl_parse_image_header(header);
 	onenand_spl_load_image(CONFIG_SYS_ONENAND_U_BOOT_OFFS,
 		spl_image.size, (void *)spl_image.load_addr);
+
+	return 0;
 }
diff --git a/common/spl/spl_sata.c b/common/spl/spl_sata.c
index 2a5eb29..3ba4c24 100644
--- a/common/spl/spl_sata.c
+++ b/common/spl/spl_sata.c
@@ -14,12 +14,13 @@
 #include <asm/u-boot.h>
 #include <sata.h>
 #include <scsi.h>
+#include <errno.h>
 #include <fat.h>
 #include <image.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-void spl_sata_load_image(void)
+int spl_sata_load_image(void)
 {
 	int err;
 	block_dev_desc_t *stor_dev;
@@ -29,11 +30,13 @@ void spl_sata_load_image(void)
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("spl: sata init failed: err - %d\n", err);
 #endif
-		hang();
+		return err;
 	} else {
 		/* try to recognize storage devices immediately */
 		scsi_scan(0);
 		stor_dev = scsi_get_dev(0);
+		if (!stor_dev)
+			return -ENODEV;
 	}
 
 #ifdef CONFIG_SPL_OS_BOOT
@@ -45,6 +48,8 @@ void spl_sata_load_image(void)
 				CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
 	if (err) {
 		puts("Error loading sata device\n");
-		hang();
+		return err;
 	}
+
+	return 0;
 }
diff --git a/common/spl/spl_usb.c b/common/spl/spl_usb.c
index c81672b..588b85c 100644
--- a/common/spl/spl_usb.c
+++ b/common/spl/spl_usb.c
@@ -12,6 +12,7 @@
 #include <common.h>
 #include <spl.h>
 #include <asm/u-boot.h>
+#include <errno.h>
 #include <usb.h>
 #include <fat.h>
 
@@ -21,7 +22,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static int usb_stor_curr_dev = -1; /* current device */
 #endif
 
-void spl_usb_load_image(void)
+int spl_usb_load_image(void)
 {
 	int err;
 	block_dev_desc_t *stor_dev;
@@ -32,13 +33,15 @@ void spl_usb_load_image(void)
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("%s: usb init failed: err - %d\n", __func__, err);
 #endif
-		hang();
+		return err;
 	}
 
 #ifdef CONFIG_USB_STORAGE
 	/* try to recognize storage devices immediately */
 	usb_stor_curr_dev = usb_stor_scan(1);
 	stor_dev = usb_stor_get_dev(usb_stor_curr_dev);
+	if (!stor_dev)
+		return -ENODEV;
 #endif
 
 	debug("boot mode - FAT\n");
@@ -51,8 +54,10 @@ void spl_usb_load_image(void)
 				CONFIG_SYS_USB_FAT_BOOT_PARTITION,
 				CONFIG_SPL_FS_LOAD_PAYLOAD_NAME);
 
-		if (err) {
-			puts("Error loading USB device\n");
-			hang();
-		}
+	if (err) {
+		puts("Error loading from USB device\n");
+		return err;
+	}
+
+	return 0;
 }
diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c
index 0f1e9970..380d8dd 100644
--- a/common/spl/spl_ymodem.c
+++ b/common/spl/spl_ymodem.c
@@ -23,7 +23,7 @@ static int getcymodem(void) {
 	return -1;
 }
 
-void spl_ymodem_load_image(void)
+int spl_ymodem_load_image(void)
 {
 	int size = 0;
 	int err;
@@ -49,11 +49,12 @@ void spl_ymodem_load_image(void)
 		}
 	} else {
 		printf("spl: ymodem err - %s\n", xyzModem_error(err));
-		hang();
+		return ret;
 	}
 
 	xyzModem_stream_close(&err);
 	xyzModem_stream_terminate(false, &getcymodem);
 
 	printf("Loaded %d bytes\n", size);
+	return 0;
 }
diff --git a/drivers/mtd/spi/spi_spl_load.c b/drivers/mtd/spi/spi_spl_load.c
index 2e0c871..ca56fe9 100644
--- a/drivers/mtd/spi/spi_spl_load.c
+++ b/drivers/mtd/spi/spi_spl_load.c
@@ -12,6 +12,7 @@
 #include <common.h>
 #include <spi.h>
 #include <spi_flash.h>
+#include <errno.h>
 #include <spl.h>
 
 #ifdef CONFIG_SPL_OS_BOOT
@@ -48,8 +49,9 @@ static int spi_load_image_os(struct spi_flash *flash,
  * configured and available since this code loads the main U-Boot image
  * from SPI into SDRAM and starts it from there.
  */
-void spl_spi_load_image(void)
+int spl_spi_load_image(void)
 {
+	int err = 0;
 	struct spi_flash *flash;
 	struct image_header *header;
 
@@ -63,7 +65,7 @@ void spl_spi_load_image(void)
 				CONFIG_SF_DEFAULT_MODE);
 	if (!flash) {
 		puts("SPI probe failed.\n");
-		hang();
+		return -ENODEV;
 	}
 
 	/* use CONFIG_SYS_TEXT_BASE as temporary storage area */
@@ -74,10 +76,15 @@ void spl_spi_load_image(void)
 #endif
 	{
 		/* Load u-boot, mkimage header is 64 bytes. */
-		spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40,
-			       (void *)header);
+		err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40,
+				     (void *)header);
+		if (err)
+			return err;
+
 		spl_parse_image_header(header);
-		spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,
+		err = spi_flash_read(flash, CONFIG_SYS_SPI_U_BOOT_OFFS,
 			       spl_image.size, (void *)spl_image.load_addr);
 	}
+
+	return err;
 }
diff --git a/include/spl.h b/include/spl.h
index 8e53426..46fc454 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -45,31 +45,31 @@ int spl_start_uboot(void);
 void spl_display_print(void);
 
 /* NAND SPL functions */
-void spl_nand_load_image(void);
+int spl_nand_load_image(void);
 
 /* OneNAND SPL functions */
-void spl_onenand_load_image(void);
+int spl_onenand_load_image(void);
 
 /* NOR SPL functions */
-void spl_nor_load_image(void);
+int spl_nor_load_image(void);
 
 /* MMC SPL functions */
-void spl_mmc_load_image(void);
+int spl_mmc_load_image(void);
 
 /* YMODEM SPL functions */
-void spl_ymodem_load_image(void);
+int spl_ymodem_load_image(void);
 
 /* SPI SPL functions */
-void spl_spi_load_image(void);
+int spl_spi_load_image(void);
 
 /* Ethernet SPL functions */
-void spl_net_load_image(const char *device);
+int spl_net_load_image(const char *device);
 
 /* USB SPL functions */
-void spl_usb_load_image(void);
+int spl_usb_load_image(void);
 
 /* SATA SPL functions */
-void spl_sata_load_image(void);
+int spl_sata_load_image(void);
 
 /* SPL FAT image functions */
 int spl_load_image_fat(block_dev_desc_t *block_dev, int partition, const char *filename);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 09/13] common: spl: move image load to its own function
  2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
                   ` (7 preceding siblings ...)
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 08/13] spl: change return values of spl_*_load_image() Nikita Kiryanov
@ 2015-11-08 15:11 ` Nikita Kiryanov
  2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 10/13] spl: add support for alternative boot device Nikita Kiryanov
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

Refactor spl image load code out of board_init_r and into its own
function. This is a preparation for supporting alternative boot
devices.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
Changes in V4:
	- No changes.

Changes in V3:
	- No changes.

Changes in V2:
	- No changes.

 common/spl/spl.c | 117 ++++++++++++++++++++++++-------------------------------
 1 file changed, 50 insertions(+), 67 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index ff1bad2..56fccca 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -178,122 +178,105 @@ int spl_init(void)
 	return 0;
 }
 
-void board_init_r(gd_t *dummy1, ulong dummy2)
+static int spl_load_image(u32 boot_device)
 {
-	u32 boot_device;
-
-	debug(">>spl:board_init_r()\n");
-
-#if defined(CONFIG_SYS_SPL_MALLOC_START)
-	mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
-			CONFIG_SYS_SPL_MALLOC_SIZE);
-	gd->flags |= GD_FLG_FULL_MALLOC_INIT;
-#endif
-	if (!(gd->flags & GD_FLG_SPL_INIT)) {
-		if (spl_init())
-			hang();
-	}
-#ifndef CONFIG_PPC
-	/*
-	 * timer_init() does not exist on PPC systems. The timer is initialized
-	 * and enabled (decrementer) in interrupt_init() here.
-	 */
-	timer_init();
-#endif
-
-#ifdef CONFIG_SPL_BOARD_INIT
-	spl_board_init();
-#endif
-
-	boot_device = spl_boot_device();
-	debug("boot device - %d\n", boot_device);
 	switch (boot_device) {
 #ifdef CONFIG_SPL_RAM_DEVICE
 	case BOOT_DEVICE_RAM:
-		if (spl_ram_load_image())
-			hang();
-		break;
+		return spl_ram_load_image();
 #endif
 #ifdef CONFIG_SPL_MMC_SUPPORT
 	case BOOT_DEVICE_MMC1:
 	case BOOT_DEVICE_MMC2:
 	case BOOT_DEVICE_MMC2_2:
-		if (spl_mmc_load_image())
-			hang();
-		break;
+		return spl_mmc_load_image();
 #endif
 #ifdef CONFIG_SPL_NAND_SUPPORT
 	case BOOT_DEVICE_NAND:
-		if (spl_nand_load_image())
-			hang();
-		break;
+		return spl_nand_load_image();
 #endif
 #ifdef CONFIG_SPL_ONENAND_SUPPORT
 	case BOOT_DEVICE_ONENAND:
-		if (spl_onenand_load_image())
-			hang();
-		break;
+		return spl_onenand_load_image();
 #endif
 #ifdef CONFIG_SPL_NOR_SUPPORT
 	case BOOT_DEVICE_NOR:
-		if (spl_nor_load_image())
-			hang();
-		break;
+		return spl_nor_load_image();
 #endif
 #ifdef CONFIG_SPL_YMODEM_SUPPORT
 	case BOOT_DEVICE_UART:
-		if (spl_ymodem_load_image())
-			hang();
-		break;
+		return spl_ymodem_load_image();
 #endif
 #ifdef CONFIG_SPL_SPI_SUPPORT
 	case BOOT_DEVICE_SPI:
-		if (spl_spi_load_image())
-			hang();
-		break;
+		return spl_spi_load_image();
 #endif
 #ifdef CONFIG_SPL_ETH_SUPPORT
 	case BOOT_DEVICE_CPGMAC:
 #ifdef CONFIG_SPL_ETH_DEVICE
-		if (spl_net_load_image(CONFIG_SPL_ETH_DEVICE))
-			hang();
+		return spl_net_load_image(CONFIG_SPL_ETH_DEVICE);
 #else
-		if (spl_net_load_image(NULL))
-			hang();
+		return spl_net_load_image(NULL);
 #endif
-		break;
 #endif
 #ifdef CONFIG_SPL_USBETH_SUPPORT
 	case BOOT_DEVICE_USBETH:
-		if (spl_net_load_image("usb_ether"))
-			hang();
-		break;
+		return spl_net_load_image("usb_ether");
 #endif
 #ifdef CONFIG_SPL_USB_SUPPORT
 	case BOOT_DEVICE_USB:
-		if (spl_usb_load_image())
-			hang();
-		break;
+		return spl_usb_load_image();
 #endif
 #ifdef CONFIG_SPL_SATA_SUPPORT
 	case BOOT_DEVICE_SATA:
-		if (spl_sata_load_image())
-			hang();
-		break;
+		return spl_sata_load_image();
 #endif
 #ifdef CONFIG_SPL_BOARD_LOAD_IMAGE
 	case BOOT_DEVICE_BOARD:
-		if (spl_board_load_image())
-			hang();
-		break;
+		return spl_board_load_image();
 #endif
 	default:
 #if defined(CONFIG_SPL_SERIAL_SUPPORT) && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
 		puts("SPL: Unsupported Boot Device!\n");
 #endif
-		hang();
+		return -ENODEV;
 	}
 
+	return -EINVAL;
+}
+
+void board_init_r(gd_t *dummy1, ulong dummy2)
+{
+	u32 boot_device;
+
+	debug(">>spl:board_init_r()\n");
+
+#if defined(CONFIG_SYS_SPL_MALLOC_START)
+	mem_malloc_init(CONFIG_SYS_SPL_MALLOC_START,
+			CONFIG_SYS_SPL_MALLOC_SIZE);
+	gd->flags |= GD_FLG_FULL_MALLOC_INIT;
+#endif
+	if (!(gd->flags & GD_FLG_SPL_INIT)) {
+		if (spl_init())
+			hang();
+	}
+#ifndef CONFIG_PPC
+	/*
+	 * timer_init() does not exist on PPC systems. The timer is initialized
+	 * and enabled (decrementer) in interrupt_init() here.
+	 */
+	timer_init();
+#endif
+
+#ifdef CONFIG_SPL_BOARD_INIT
+	spl_board_init();
+#endif
+
+	boot_device = spl_boot_device();
+	debug("boot device - %d\n", boot_device);
+	if (spl_load_image(boot_device))
+		hang();
+
 	switch (spl_image.os) {
 	case IH_OS_U_BOOT:
 		debug("Jumping to U-Boot\n");
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 10/13] spl: add support for alternative boot device
  2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
                   ` (8 preceding siblings ...)
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 09/13] common: spl: move image load to its own function Nikita Kiryanov
@ 2015-11-08 15:11 ` Nikita Kiryanov
  2015-11-09 20:24   ` Simon Glass
                     ` (2 more replies)
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 11/13] spl: announce boot devices Nikita Kiryanov
                   ` (2 subsequent siblings)
  12 siblings, 3 replies; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

Introduce spl_boot_list array, which defines a list of boot devices
that SPL will try before hanging. By default this list will consist
of only spl_boot_device(), but board_boot_order() can be overridden
by board code to populate the array with custom values.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
Changes in V4:
	- No changes.

Changes in V3:
	- No changes.

Changes in V2:
	- No changes.

 common/spl/spl.c | 33 +++++++++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 56fccca..7913c52 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -178,6 +178,23 @@ int spl_init(void)
 	return 0;
 }
 
+#ifndef BOOT_DEVICE_NONE
+#define BOOT_DEVICE_NONE 0xdeadbeef
+#endif
+
+static u32 spl_boot_list[] = {
+	BOOT_DEVICE_NONE,
+	BOOT_DEVICE_NONE,
+	BOOT_DEVICE_NONE,
+	BOOT_DEVICE_NONE,
+	BOOT_DEVICE_NONE,
+};
+
+__weak void board_boot_order(u32 *spl_boot_list)
+{
+	spl_boot_list[0] = spl_boot_device();
+}
+
 static int spl_load_image(u32 boot_device)
 {
 	switch (boot_device) {
@@ -247,7 +264,7 @@ static int spl_load_image(u32 boot_device)
 
 void board_init_r(gd_t *dummy1, ulong dummy2)
 {
-	u32 boot_device;
+	int i;
 
 	debug(">>spl:board_init_r()\n");
 
@@ -272,10 +289,18 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	spl_board_init();
 #endif
 
-	boot_device = spl_boot_device();
-	debug("boot device - %d\n", boot_device);
-	if (spl_load_image(boot_device))
+	board_boot_order(spl_boot_list);
+	for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
+			spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
+		if (!spl_load_image(spl_boot_list[i]))
+			break;
+	}
+
+	if (i == ARRAY_SIZE(spl_boot_list) ||
+	    spl_boot_list[i] == BOOT_DEVICE_NONE) {
+		puts("SPL: failed to boot from all boot devices\n");
 		hang();
+	}
 
 	switch (spl_image.os) {
 	case IH_OS_U_BOOT:
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 11/13] spl: announce boot devices
  2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
                   ` (9 preceding siblings ...)
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 10/13] spl: add support for alternative boot device Nikita Kiryanov
@ 2015-11-08 15:11 ` Nikita Kiryanov
  2015-11-09 20:24   ` Simon Glass
  2015-11-18 22:34   ` [U-Boot] [U-Boot,V4,11/13] " Tom Rini
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 12/13] arm: mx6: cm-fx6: define fallback boot devices for spl Nikita Kiryanov
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 13/13] spl: mmc: add support for BOOT_DEVICE_MMC2 Nikita Kiryanov
  12 siblings, 2 replies; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

Now that we support alternative boot devices, it can sometimes be
unclear which boot devices was actually used. Provide a function to
announce which boot devices are attempted during boot.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
Changes in V2:
	- Moved new code to be located after #ifndef BOOT_DEVICE_NONE

Changes in V3:
	- Reworked announce_boot_device() to make the code less repititive by
	  utilizing a table of boot_device --> name.

Changes in V2:
	- No changes.

 common/spl/spl.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 7913c52..b522c8b 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -195,6 +195,84 @@ __weak void board_boot_order(u32 *spl_boot_list)
 	spl_boot_list[0] = spl_boot_device();
 }
 
+#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE
+__weak void spl_board_announce_boot_device(void) { }
+#endif
+
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+struct boot_device_name {
+	u32 boot_dev;
+	const char *name;
+};
+
+struct boot_device_name boot_name_table[] = {
+#ifdef CONFIG_SPL_RAM_DEVICE
+	{ BOOT_DEVICE_RAM, "RAM" },
+#endif
+#ifdef CONFIG_SPL_MMC_SUPPORT
+	{ BOOT_DEVICE_MMC1, "MMC" },
+	{ BOOT_DEVICE_MMC2, "MMC" },
+	{ BOOT_DEVICE_MMC2_2, "MMC" },
+#endif
+#ifdef CONFIG_SPL_NAND_SUPPORT
+	{ BOOT_DEVICE_NAND, "NAND" },
+#endif
+#ifdef CONFIG_SPL_ONENAND_SUPPORT
+	{ BOOT_DEVICE_ONENAND, "OneNAND" },
+#endif
+#ifdef CONFIG_SPL_NOR_SUPPORT
+	{ BOOT_DEVICE_NOR, "NOR" },
+#endif
+#ifdef CONFIG_SPL_YMODEM_SUPPORT
+	{ BOOT_DEVICE_UART, "UART" },
+#endif
+#ifdef CONFIG_SPL_SPI_SUPPORT
+	{ BOOT_DEVICE_SPI, "SPI" },
+#endif
+#ifdef CONFIG_SPL_ETH_SUPPORT
+#ifdef CONFIG_SPL_ETH_DEVICE
+	{ BOOT_DEVICE_CPGMAC, "eth device" },
+#else
+	{ BOOT_DEVICE_CPGMAC, "net" },
+#endif
+#endif
+#ifdef CONFIG_SPL_USBETH_SUPPORT
+	{ BOOT_DEVICE_USBETH, "USB eth" },
+#endif
+#ifdef CONFIG_SPL_USB_SUPPORT
+	{ BOOT_DEVICE_USB, "USB" },
+#endif
+#ifdef CONFIG_SPL_SATA_SUPPORT
+	{ BOOT_DEVICE_SATA, "SATA" },
+#endif
+	/* Keep this entry last */
+	{ BOOT_DEVICE_NONE, "unknown boot device" },
+};
+
+static void announce_boot_device(u32 boot_device)
+{
+	int i;
+
+	puts("Trying to boot from ");
+
+#ifdef CONFIG_SPL_BOARD_LOAD_IMAGE
+	if (boot_device == BOOT_DEVICE_BOARD) {
+		spl_board_announce_boot_device();
+		puts("\n");
+		return;
+	}
+#endif
+	for (i = 0; i < ARRAY_SIZE(boot_name_table) - 1; i++) {
+		if (boot_name_table[i].boot_dev == boot_device)
+			break;
+	}
+
+	printf("%s\n", boot_name_table[i].name);
+}
+#else
+static inline void announce_boot_device(u32 boot_device) { }
+#endif
+
 static int spl_load_image(u32 boot_device)
 {
 	switch (boot_device) {
@@ -292,6 +370,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	board_boot_order(spl_boot_list);
 	for (i = 0; i < ARRAY_SIZE(spl_boot_list) &&
 			spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
+		announce_boot_device(spl_boot_list[i]);
 		if (!spl_load_image(spl_boot_list[i]))
 			break;
 	}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 12/13] arm: mx6: cm-fx6: define fallback boot devices for spl
  2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
                   ` (10 preceding siblings ...)
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 11/13] spl: announce boot devices Nikita Kiryanov
@ 2015-11-08 15:11 ` Nikita Kiryanov
  2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 13/13] spl: mmc: add support for BOOT_DEVICE_MMC2 Nikita Kiryanov
  12 siblings, 1 reply; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

Use spl alternate boot device feature to define fallback to
the main boot device as it is defined by hardware.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Stefano Babic <sbabic@denx.de>
---
Changes in V4:
	- No changes.

Changes in V3:
	- No changes.

Changes in V2:
	- No changes.

 board/compulab/cm_fx6/spl.c | 19 ++++++++++---------
 include/configs/cm_fx6.h    |  1 -
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/board/compulab/cm_fx6/spl.c b/board/compulab/cm_fx6/spl.c
index d94ced9..d8328fd 100644
--- a/board/compulab/cm_fx6/spl.c
+++ b/board/compulab/cm_fx6/spl.c
@@ -337,16 +337,17 @@ void board_init_f(ulong dummy)
 	board_init_r(NULL, 0);
 }
 
-void spl_board_init(void)
+void board_boot_order(u32 *spl_boot_list)
 {
-	u32 boot_device = spl_boot_device();
-
-	if (boot_device == BOOT_DEVICE_SPI)
-		puts("Booting from SPI flash\n");
-	else if (boot_device == BOOT_DEVICE_MMC1)
-		puts("Booting from MMC\n");
-	else
-		puts("Unknown boot device\n");
+	spl_boot_list[0] = spl_boot_device();
+	switch (spl_boot_list[0]) {
+	case BOOT_DEVICE_SPI:
+		spl_boot_list[1] = BOOT_DEVICE_MMC1;
+		break;
+	case BOOT_DEVICE_MMC1:
+		spl_boot_list[1] = BOOT_DEVICE_SPI;
+		break;
+	}
 }
 
 #ifdef CONFIG_SPL_MMC_SUPPORT
diff --git a/include/configs/cm_fx6.h b/include/configs/cm_fx6.h
index 0513204..180ea28 100644
--- a/include/configs/cm_fx6.h
+++ b/include/configs/cm_fx6.h
@@ -230,7 +230,6 @@
 
 /* SPL */
 #include "imx6_spl.h"
-#define CONFIG_SPL_BOARD_INIT
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR	0x80 /* offset 64 kb */
 #define CONFIG_SYS_MONITOR_LEN	(CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS / 2 * 1024)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 13/13] spl: mmc: add support for BOOT_DEVICE_MMC2
  2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
                   ` (11 preceding siblings ...)
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 12/13] arm: mx6: cm-fx6: define fallback boot devices for spl Nikita Kiryanov
@ 2015-11-08 15:11 ` Nikita Kiryanov
  2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini
  12 siblings, 1 reply; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-08 15:11 UTC (permalink / raw)
  To: u-boot

Currently the mmc device that SPL looks at is always mmc0, regardless
of the BOOT_DEVICE_MMCx value. This forces some boards to
implement hacks in order to boot from other mmc devices.

Make SPL take into account the correct mmc device.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
Changes in V4:
	- No changes.

Changes in V3:
	- No changes.

Changes in V2:
	- New patch.

 arch/arm/cpu/armv7/sunxi/board.c | 10 +---------
 common/spl/spl.c                 |  2 +-
 common/spl/spl_mmc.c             | 41 ++++++++++++++++++++++++++++++++--------
 include/spl.h                    |  2 +-
 4 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c
index 9b5c46b..794b829 100644
--- a/arch/arm/cpu/armv7/sunxi/board.c
+++ b/arch/arm/cpu/armv7/sunxi/board.c
@@ -173,16 +173,8 @@ u32 spl_boot_device(void)
 #ifdef CONFIG_MMC
 	if (CONFIG_MMC_SUNXI_SLOT_EXTRA == 2) {
 		mmc1 = find_mmc_device(1);
-		if (sunxi_mmc_has_egon_boot_signature(mmc1)) {
-			/*
-			 * spl_mmc.c: spl_mmc_load_image() is hard-coded to
-			 * use find_mmc_device(0), no matter what we
-			 * return. Swap mmc0 and mmc2 to make this work.
-			 */
-			mmc0->block_dev.dev = 1;
-			mmc1->block_dev.dev = 0;
+		if (sunxi_mmc_has_egon_boot_signature(mmc1))
 			return BOOT_DEVICE_MMC2;
-		}
 	}
 #endif
 
diff --git a/common/spl/spl.c b/common/spl/spl.c
index b522c8b..7a393dc 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -284,7 +284,7 @@ static int spl_load_image(u32 boot_device)
 	case BOOT_DEVICE_MMC1:
 	case BOOT_DEVICE_MMC2:
 	case BOOT_DEVICE_MMC2_2:
-		return spl_mmc_load_image();
+		return spl_mmc_load_image(boot_device);
 #endif
 #ifdef CONFIG_SPL_NAND_SUPPORT
 	case BOOT_DEVICE_NAND:
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index b68190a..b3c2c64 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -61,11 +61,32 @@ end:
 	return 0;
 }
 
+int spl_mmc_get_device_index(u32 boot_device)
+{
+	switch (boot_device) {
+	case BOOT_DEVICE_MMC1:
+		return 0;
+	case BOOT_DEVICE_MMC2:
+	case BOOT_DEVICE_MMC2_2:
+		return 1;
+	}
+
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+	printf("spl: unsupported mmc boot device.\n");
+#endif
+
+	return -ENODEV;
+}
+
 #ifdef CONFIG_DM_MMC
-static int spl_mmc_find_device(struct mmc **mmc)
+static int spl_mmc_find_device(struct mmc **mmc, u32 boot_device)
 {
 	struct udevice *dev;
-	int err;
+	int err, mmc_dev;
+
+	mmc_dev = spl_mmc_get_device_index(boot_device);
+	if (mmc_dev < 0)
+		return mmc_dev;
 
 	err = mmc_initialize(NULL);
 	if (err) {
@@ -75,7 +96,7 @@ static int spl_mmc_find_device(struct mmc **mmc)
 		return err;
 	}
 
-	err = uclass_get_device(UCLASS_MMC, 0, &dev);
+	err = uclass_get_device(UCLASS_MMC, mmc_dev, &dev);
 	if (err) {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		printf("spl: could not find mmc device. error: %d\n", err);
@@ -88,9 +109,13 @@ static int spl_mmc_find_device(struct mmc **mmc)
 	return *mmc != NULL ? 0 : -ENODEV;
 }
 #else
-static int spl_mmc_find_device(struct mmc **mmc)
+static int spl_mmc_find_device(struct mmc **mmc, u32 boot_device)
 {
-	int err;
+	int err, mmc_dev;
+
+	mmc_dev = spl_mmc_get_device_index(boot_device);
+	if (mmc_dev < 0)
+		return mmc_dev;
 
 	err = mmc_initialize(gd->bd);
 	if (err) {
@@ -101,7 +126,7 @@ static int spl_mmc_find_device(struct mmc **mmc)
 	}
 
 	/* We register only one device. So, the dev id is always 0 */
-	*mmc = find_mmc_device(0);
+	*mmc = find_mmc_device(mmc_dev);
 	if (!*mmc) {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
 		puts("spl: mmc device not found\n");
@@ -221,14 +246,14 @@ int spl_mmc_do_fs_boot(struct mmc *mmc)
 }
 #endif
 
-int spl_mmc_load_image(void)
+int spl_mmc_load_image(u32 boot_device)
 {
 	struct mmc *mmc;
 	u32 boot_mode;
 	int err = 0;
 	__maybe_unused int part;
 
-	err = spl_mmc_find_device(&mmc);
+	err = spl_mmc_find_device(&mmc, boot_device);
 	if (err)
 		return err;
 
diff --git a/include/spl.h b/include/spl.h
index 46fc454..92cdc04 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -54,7 +54,7 @@ int spl_onenand_load_image(void);
 int spl_nor_load_image(void);
 
 /* MMC SPL functions */
-int spl_mmc_load_image(void);
+int spl_mmc_load_image(u32 boot_device);
 
 /* YMODEM SPL functions */
 int spl_ymodem_load_image(void);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 03/13] spl: mmc: refactor device location code to its own function
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 03/13] spl: mmc: refactor device location code to its own function Nikita Kiryanov
@ 2015-11-08 21:19   ` Tom Rini
  2015-11-18 22:33   ` [U-Boot] [U-Boot, V4, " Tom Rini
  1 sibling, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-08 21:19 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:44PM +0200, Nikita Kiryanov wrote:

> Simplify spl_mmc_load_image() code by moving the part that finds the mmc device
> into its own function spl_mmc_find_device(), available in two flavors: DM and
> non-DM.
> 
> This refactor fixes a bug in which an error in the device location sequence
> does not necessarily aborts the rest of the code. With this refactor, we fail
> the moment there is an error.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Paul Kocialkowski <contact@paulk.fr>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151108/98b19400/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 10/13] spl: add support for alternative boot device
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 10/13] spl: add support for alternative boot device Nikita Kiryanov
@ 2015-11-09 20:24   ` Simon Glass
  2015-11-18 22:33   ` [U-Boot] [U-Boot, V4, " Tom Rini
  2015-11-18 22:34   ` Tom Rini
  2 siblings, 0 replies; 37+ messages in thread
From: Simon Glass @ 2015-11-09 20:24 UTC (permalink / raw)
  To: u-boot

On 8 November 2015 at 07:11, Nikita Kiryanov <nikita@compulab.co.il> wrote:
> Introduce spl_boot_list array, which defines a list of boot devices
> that SPL will try before hanging. By default this list will consist
> of only spl_boot_device(), but board_boot_order() can be overridden
> by board code to populate the array with custom values.
>
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> ---
> Changes in V4:
>         - No changes.
>
> Changes in V3:
>         - No changes.
>
> Changes in V2:
>         - No changes.
>
>  common/spl/spl.c | 33 +++++++++++++++++++++++++++++----
>  1 file changed, 29 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 11/13] spl: announce boot devices
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 11/13] spl: announce boot devices Nikita Kiryanov
@ 2015-11-09 20:24   ` Simon Glass
  2015-11-18 22:34   ` [U-Boot] [U-Boot,V4,11/13] " Tom Rini
  1 sibling, 0 replies; 37+ messages in thread
From: Simon Glass @ 2015-11-09 20:24 UTC (permalink / raw)
  To: u-boot

On 8 November 2015 at 07:11, Nikita Kiryanov <nikita@compulab.co.il> wrote:
> Now that we support alternative boot devices, it can sometimes be
> unclear which boot devices was actually used. Provide a function to
> announce which boot devices are attempted during boot.
>
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> ---
> Changes in V2:
>         - Moved new code to be located after #ifndef BOOT_DEVICE_NONE
>
> Changes in V3:
>         - Reworked announce_boot_device() to make the code less repititive by
>           utilizing a table of boot_device --> name.
>
> Changes in V2:
>         - No changes.
>
>  common/spl/spl.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 79 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [PATCH V4 01/13] spl: nand: remove code duplication
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 01/13] spl: nand: remove code duplication Nikita Kiryanov
@ 2015-11-16 11:50   ` Heiko Schocher
  2015-11-18 22:33   ` [U-Boot] [U-Boot,V4,01/13] " Tom Rini
  1 sibling, 0 replies; 37+ messages in thread
From: Heiko Schocher @ 2015-11-16 11:50 UTC (permalink / raw)
  To: u-boot

Hello Nikita,

Am 08.11.2015 um 16:11 schrieb Nikita Kiryanov:
> Remove code duplication in spl_nand_load_image().
>
> No functional changes.
>
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Scott Wood <scottwood@freescale.com>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Acked-by: Scott Wood <scottwood@freescale.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
> Changes in V4:
> 	- No changes.
>
> Changes in V3:
> 	- No changes.
>
> Changes in V2:
> 	- No changes.
>
>   common/spl/spl_nand.c | 31 ++++++++++++++++---------------
>   1 file changed, 16 insertions(+), 15 deletions(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
> index b8c369d..6e4e641 100644
> --- a/common/spl/spl_nand.c
> +++ b/common/spl/spl_nand.c
> @@ -22,6 +22,19 @@ void spl_nand_load_image(void)
>   	nand_deselect();
>   }
>   #else
> +static int spl_nand_load_element(int offset, struct image_header *header)
> +{
> +	int err;
> +
> +	err = nand_spl_load_image(offset, sizeof(*header), (void *)header);
> +	if (err)
> +		return err;
> +
> +	spl_parse_image_header(header);
> +	return nand_spl_load_image(offset, spl_image.size,
> +				   (void *)spl_image.load_addr);
> +}
> +
>   void spl_nand_load_image(void)
>   {
>   	struct image_header *header;
> @@ -73,25 +86,13 @@ void spl_nand_load_image(void)
>   	}
>   #endif
>   #ifdef CONFIG_NAND_ENV_DST
> -	nand_spl_load_image(CONFIG_ENV_OFFSET,
> -		sizeof(*header), (void *)header);
> -	spl_parse_image_header(header);
> -	nand_spl_load_image(CONFIG_ENV_OFFSET, spl_image.size,
> -		(void *)spl_image.load_addr);
> +	spl_nand_load_element(CONFIG_ENV_OFFSET, header);
>   #ifdef CONFIG_ENV_OFFSET_REDUND
> -	nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND,
> -		sizeof(*header), (void *)header);
> -	spl_parse_image_header(header);
> -	nand_spl_load_image(CONFIG_ENV_OFFSET_REDUND, spl_image.size,
> -		(void *)spl_image.load_addr);
> +	spl_nand_load_element(CONFIG_ENV_OFFSET_REDUND, header);
>   #endif
>   #endif
>   	/* Load u-boot */
> -	nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
> -		sizeof(*header), (void *)header);
> -	spl_parse_image_header(header);
> -	nand_spl_load_image(CONFIG_SYS_NAND_U_BOOT_OFFS,
> -		spl_image.size, (void *)(unsigned long)spl_image.load_addr);
> +	spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header);
>   	nand_deselect();
>   }
>   #endif
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 10/13] spl: add support for alternative boot device
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 10/13] spl: add support for alternative boot device Nikita Kiryanov
  2015-11-09 20:24   ` Simon Glass
@ 2015-11-18 22:33   ` Tom Rini
  2015-11-19 11:19     ` Nikita Kiryanov
  2015-11-18 22:34   ` Tom Rini
  2 siblings, 1 reply; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:33 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:51PM +0200, Nikita Kiryanov wrote:

> Introduce spl_boot_list array, which defines a list of boot devices
> that SPL will try before hanging. By default this list will consist
> of only spl_boot_device(), but board_boot_order() can be overridden
> by board code to populate the array with custom values.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

So, a problem with this patch is that we push the x600 board, which is
an 8KiB SPL target, over the line.  I feel like maybe we need a
follow-up patch that makes announcing depend not on libcommon (which
x600 needs) but something else to know that there's a reason to
announce.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/890f30f5/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot,V4,01/13] spl: nand: remove code duplication
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 01/13] spl: nand: remove code duplication Nikita Kiryanov
  2015-11-16 11:50   ` Heiko Schocher
@ 2015-11-18 22:33   ` Tom Rini
  1 sibling, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:33 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:42PM +0200, Nikita Kiryanov wrote:

> Remove code duplication in spl_nand_load_image().
> 
> No functional changes.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Scott Wood <scottwood@freescale.com>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Acked-by: Scott Wood <scottwood@freescale.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/c2577b0f/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 02/13] spl: mmc: add break statements in spl_mmc_load_image()
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 02/13] spl: mmc: add break statements in spl_mmc_load_image() Nikita Kiryanov
@ 2015-11-18 22:33   ` Tom Rini
  0 siblings, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:33 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:43PM +0200, Nikita Kiryanov wrote:

> The original intention of the mmc load_image() function was to try multiple
> boot modes before failing. This is evident by the lack of break statements
> in the switch, and the following line in the default case:
> puts("spl: mmc: no boot mode left to try\n");
> 
> This implementation is problematic because:
> - The availability of alternative boot modes is very arbitrary since it
> depends on the specific order of the switch cases. If your boot mode happens to
> be the first case, then you'll have a bunch of other boot modes as alternatives.
> If it happens to be the last case, then you have none.
> - Opting in/out is tied to config options, so the only way for you to prevent an
> alternative boot mode from being attempted is to give up on the feature completely.
> - This implementation makes the code more complicated and difficult to
> understand.
> 
> Address these issues by inserting a break statements between the cases to make the
> function try only one boot mode.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Paul Kocialkowski <contact@paulk.fr>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/52185286/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 03/13] spl: mmc: refactor device location code to its own function
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 03/13] spl: mmc: refactor device location code to its own function Nikita Kiryanov
  2015-11-08 21:19   ` Tom Rini
@ 2015-11-18 22:33   ` Tom Rini
  1 sibling, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:33 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:44PM +0200, Nikita Kiryanov wrote:

> Simplify spl_mmc_load_image() code by moving the part that finds the mmc device
> into its own function spl_mmc_find_device(), available in two flavors: DM and
> non-DM.
> 
> This refactor fixes a bug in which an error in the device location sequence
> does not necessarily aborts the rest of the code. With this refactor, we fail
> the moment there is an error.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Paul Kocialkowski <contact@paulk.fr>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/f0a46b20/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 04/13] spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 04/13] spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check Nikita Kiryanov
@ 2015-11-18 22:33   ` Tom Rini
  0 siblings, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:33 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:45PM +0200, Nikita Kiryanov wrote:

> Implement default versions of falcon mode functions to make the
> CONFIG_SPL_OS_BOOT check in spl_mmc_load_image() unnecessary, thus reducing
> its #ifdef complexity.
> 
> No functional changes.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Paul Kocialkowski <contact@paulk.fr>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Guillaume GARDET <guillaume.gardet@free.fr>
> Cc: Suriyan Ramasami <suriyan.r@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/2338e4b2/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 05/13] spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION check
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 05/13] spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION check Nikita Kiryanov
@ 2015-11-18 22:34   ` Tom Rini
  0 siblings, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:34 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:46PM +0200, Nikita Kiryanov wrote:

> Implement defaults for the raw partition image loading so that the #ifdef
> CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION in spl_mmc_load_image() will no
> longer be necessary.
> 
> This change makes it possible for mmc_load_image_raw_partition() and
> mmc_load_image_raw_sector() to coexist.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Paul Kocialkowski <contact@paulk.fr>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/9f62fcb9/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 06/13] spl: mmc: move fs boot into its own function
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 06/13] spl: mmc: move fs boot into its own function Nikita Kiryanov
@ 2015-11-18 22:34   ` Tom Rini
  0 siblings, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:34 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:47PM +0200, Nikita Kiryanov wrote:

> Move the code that handles fs boot out of spl_mmc_load_image() and into its
> own function to reduce the #ifdef complexity of spl_mmc_load_image().
> 
> No functional changes.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Paul Kocialkowski <contact@paulk.fr>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/06a11c5d/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 07/13] spl: mmc: get rid of emmc boot code duplication
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 07/13] spl: mmc: get rid of emmc boot code duplication Nikita Kiryanov
@ 2015-11-18 22:34   ` Tom Rini
  0 siblings, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:34 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:48PM +0200, Nikita Kiryanov wrote:

> Get rid of emmc boot code duplication in spl_mmc_load_image() using a switch
> case fallthrough into MMCSD_MODE_RAW. Since the #ifdef CONFIG_SUPPORT_EMMC_BOOT
> check is not really necessary, remove it in the process.
> 
> No functional changes.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Paul Kocialkowski <contact@paulk.fr>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/84d1f036/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 08/13] spl: change return values of spl_*_load_image()
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 08/13] spl: change return values of spl_*_load_image() Nikita Kiryanov
@ 2015-11-18 22:34   ` Tom Rini
  0 siblings, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:34 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:49PM +0200, Nikita Kiryanov wrote:

> Make spl_*_load_image() functions return a value instead of
> hanging if a problem is encountered. This enables main spl code
> to make the decision whether to hang or not, thus preparing
> it to support alternative boot devices.
> 
> Some boot devices (namely nand and spi) do not hang on error.
> Instead, they return normally and SPL proceeds to boot the
> contents of the load address. This is considered a bug and
> is rectified by hanging on error for these devices as well.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Ian Campbell <ijc@hellion.org.uk>
> Cc: Hans De Goede <hdegoede@redhat.com>
> Cc: Albert Aribaud <albert.u.boot@aribaud.net>
> Cc: Jagan Teki <jteki@openedev.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/22108db7/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 09/13] common: spl: move image load to its own function
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 09/13] common: spl: move image load to its own function Nikita Kiryanov
@ 2015-11-18 22:34   ` Tom Rini
  0 siblings, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:34 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:50PM +0200, Nikita Kiryanov wrote:

> Refactor spl image load code out of board_init_r and into its own
> function. This is a preparation for supporting alternative boot
> devices.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/01f9dccd/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 10/13] spl: add support for alternative boot device
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 10/13] spl: add support for alternative boot device Nikita Kiryanov
  2015-11-09 20:24   ` Simon Glass
  2015-11-18 22:33   ` [U-Boot] [U-Boot, V4, " Tom Rini
@ 2015-11-18 22:34   ` Tom Rini
  2 siblings, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:34 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:51PM +0200, Nikita Kiryanov wrote:

> Introduce spl_boot_list array, which defines a list of boot devices
> that SPL will try before hanging. By default this list will consist
> of only spl_boot_device(), but board_boot_order() can be overridden
> by board code to populate the array with custom values.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/5334ebbc/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot,V4,11/13] spl: announce boot devices
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 11/13] spl: announce boot devices Nikita Kiryanov
  2015-11-09 20:24   ` Simon Glass
@ 2015-11-18 22:34   ` Tom Rini
  1 sibling, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:34 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:52PM +0200, Nikita Kiryanov wrote:

> Now that we support alternative boot devices, it can sometimes be
> unclear which boot devices was actually used. Provide a function to
> announce which boot devices are attempted during boot.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/1575ebfe/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 12/13] arm: mx6: cm-fx6: define fallback boot devices for spl
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 12/13] arm: mx6: cm-fx6: define fallback boot devices for spl Nikita Kiryanov
@ 2015-11-18 22:34   ` Tom Rini
  0 siblings, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:34 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:53PM +0200, Nikita Kiryanov wrote:

> Use spl alternate boot device feature to define fallback to
> the main boot device as it is defined by hardware.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Cc: Igor Grinberg <grinberg@compulab.co.il>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Tom Rini <trini@konsulko.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
> Reviewed-by: Stefano Babic <sbabic@denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/404aa6f6/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 13/13] spl: mmc: add support for BOOT_DEVICE_MMC2
  2015-11-08 15:11 ` [U-Boot] [PATCH V4 13/13] spl: mmc: add support for BOOT_DEVICE_MMC2 Nikita Kiryanov
@ 2015-11-18 22:34   ` Tom Rini
  0 siblings, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-18 22:34 UTC (permalink / raw)
  To: u-boot

On Sun, Nov 08, 2015 at 05:11:54PM +0200, Nikita Kiryanov wrote:

> Currently the mmc device that SPL looks at is always mmc0, regardless
> of the BOOT_DEVICE_MMCx value. This forces some boards to
> implement hacks in order to boot from other mmc devices.
> 
> Make SPL take into account the correct mmc device.
> 
> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151118/39b70697/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 10/13] spl: add support for alternative boot device
  2015-11-18 22:33   ` [U-Boot] [U-Boot, V4, " Tom Rini
@ 2015-11-19 11:19     ` Nikita Kiryanov
  2015-11-19 11:46       ` Stefan Roese
  2015-11-19 22:10       ` Tom Rini
  0 siblings, 2 replies; 37+ messages in thread
From: Nikita Kiryanov @ 2015-11-19 11:19 UTC (permalink / raw)
  To: u-boot

Hi Tom,

On Wed, Nov 18, 2015 at 05:33:20PM -0500, Tom Rini wrote:
> On Sun, Nov 08, 2015 at 05:11:51PM +0200, Nikita Kiryanov wrote:
> 
> > Introduce spl_boot_list array, which defines a list of boot devices
> > that SPL will try before hanging. By default this list will consist
> > of only spl_boot_device(), but board_boot_order() can be overridden
> > by board code to populate the array with custom values.
> > 
> > Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> > Cc: Igor Grinberg <grinberg@compulab.co.il>
> > Cc: Tom Rini <trini@konsulko.com>
> > Cc: Simon Glass <sjg@chromium.org>
> > Reviewed-by: Tom Rini <trini@konsulko.com>
> > Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> So, a problem with this patch is that we push the x600 board, which is
> an 8KiB SPL target, over the line.  I feel like maybe we need a
> follow-up patch that makes announcing depend not on libcommon (which
> x600 needs) but something else to know that there's a reason to
> announce.

Based on the content of your reply I'm guessing you're referring to the
next patch, not this one.

I suppose that announcing can be made into an optional feature. However,
I also think that since printing is an optional feature that can greatly
increase binary size, it shouldn't be coupled with other, often
non-optional libcommon features the way it currently is via
CONFIG_SPL_LIBCOMMON_SUPPORT. The best fix in my opinion would be to
implement a way to exclude printing support from SPL even if libcommon
is included (CONFIG_SPL_SILENT that replaces printfs with empty stubs?).

This will also make it possible to remove all those #ifdef
CONFIG_SPL_LIBCOMMON_SUPPORT checks that appear all over the SPL code.

> 
> -- 
> Tom

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 10/13] spl: add support for alternative boot device
  2015-11-19 11:19     ` Nikita Kiryanov
@ 2015-11-19 11:46       ` Stefan Roese
  2015-11-19 22:11         ` Tom Rini
  2015-11-19 22:10       ` Tom Rini
  1 sibling, 1 reply; 37+ messages in thread
From: Stefan Roese @ 2015-11-19 11:46 UTC (permalink / raw)
  To: u-boot

On 19.11.2015 12:19, Nikita Kiryanov wrote:
> Hi Tom,
>
> On Wed, Nov 18, 2015 at 05:33:20PM -0500, Tom Rini wrote:
>> On Sun, Nov 08, 2015 at 05:11:51PM +0200, Nikita Kiryanov wrote:
>>
>>> Introduce spl_boot_list array, which defines a list of boot devices
>>> that SPL will try before hanging. By default this list will consist
>>> of only spl_boot_device(), but board_boot_order() can be overridden
>>> by board code to populate the array with custom values.
>>>
>>> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
>>> Cc: Igor Grinberg <grinberg@compulab.co.il>
>>> Cc: Tom Rini <trini@konsulko.com>
>>> Cc: Simon Glass <sjg@chromium.org>
>>> Reviewed-by: Tom Rini <trini@konsulko.com>
>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>
>> So, a problem with this patch is that we push the x600 board, which is
>> an 8KiB SPL target, over the line.  I feel like maybe we need a
>> follow-up patch that makes announcing depend not on libcommon (which
>> x600 needs) but something else to know that there's a reason to
>> announce.
>
> Based on the content of your reply I'm guessing you're referring to the
> next patch, not this one.
>
> I suppose that announcing can be made into an optional feature. However,
> I also think that since printing is an optional feature that can greatly
> increase binary size, it shouldn't be coupled with other, often
> non-optional libcommon features the way it currently is via
> CONFIG_SPL_LIBCOMMON_SUPPORT. The best fix in my opinion would be to
> implement a way to exclude printing support from SPL even if libcommon
> is included (CONFIG_SPL_SILENT that replaces printfs with empty stubs?).
>
> This will also make it possible to remove all those #ifdef
> CONFIG_SPL_LIBCOMMON_SUPPORT checks that appear all over the SPL code.

I think that my recently posted tiny-printf patches:

https://patchwork.ozlabs.org/patch/545034/
https://patchwork.ozlabs.org/patch/545033/
https://patchwork.ozlabs.org/patch/545036/
https://patchwork.ozlabs.org/patch/545035/

can solve this size issue on x600 (and perhaps other) board.

Comments welcome...

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 10/13] spl: add support for alternative boot device
  2015-11-19 11:19     ` Nikita Kiryanov
  2015-11-19 11:46       ` Stefan Roese
@ 2015-11-19 22:10       ` Tom Rini
  1 sibling, 0 replies; 37+ messages in thread
From: Tom Rini @ 2015-11-19 22:10 UTC (permalink / raw)
  To: u-boot

On Thu, Nov 19, 2015 at 01:19:39PM +0200, Nikita Kiryanov wrote:
> Hi Tom,
> 
> On Wed, Nov 18, 2015 at 05:33:20PM -0500, Tom Rini wrote:
> > On Sun, Nov 08, 2015 at 05:11:51PM +0200, Nikita Kiryanov wrote:
> > 
> > > Introduce spl_boot_list array, which defines a list of boot devices
> > > that SPL will try before hanging. By default this list will consist
> > > of only spl_boot_device(), but board_boot_order() can be overridden
> > > by board code to populate the array with custom values.
> > > 
> > > Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> > > Cc: Igor Grinberg <grinberg@compulab.co.il>
> > > Cc: Tom Rini <trini@konsulko.com>
> > > Cc: Simon Glass <sjg@chromium.org>
> > > Reviewed-by: Tom Rini <trini@konsulko.com>
> > > Reviewed-by: Simon Glass <sjg@chromium.org>
> > 
> > So, a problem with this patch is that we push the x600 board, which is
> > an 8KiB SPL target, over the line.  I feel like maybe we need a
> > follow-up patch that makes announcing depend not on libcommon (which
> > x600 needs) but something else to know that there's a reason to
> > announce.
> 
> Based on the content of your reply I'm guessing you're referring to the
> next patch, not this one.

Oh yes, oops.

> I suppose that announcing can be made into an optional feature. However,
> I also think that since printing is an optional feature that can greatly
> increase binary size, it shouldn't be coupled with other, often
> non-optional libcommon features the way it currently is via
> CONFIG_SPL_LIBCOMMON_SUPPORT. The best fix in my opinion would be to
> implement a way to exclude printing support from SPL even if libcommon
> is included (CONFIG_SPL_SILENT that replaces printfs with empty stubs?).
> 
> This will also make it possible to remove all those #ifdef
> CONFIG_SPL_LIBCOMMON_SUPPORT checks that appear all over the SPL code.

So the reason I'm thinking that we want this announce thing separate is
that (due to the way you re-worked it I think, based on Simons' request)
this added a huge amount of space.  We went from OK to overflowing by
more than 1KiB.  So I'm not immediately sure that we can regain that
space with a more (space) efficient printing infrastructure.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151119/8c906c6b/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 10/13] spl: add support for alternative boot device
  2015-11-19 11:46       ` Stefan Roese
@ 2015-11-19 22:11         ` Tom Rini
  2015-11-20  6:35           ` Stefan Roese
  0 siblings, 1 reply; 37+ messages in thread
From: Tom Rini @ 2015-11-19 22:11 UTC (permalink / raw)
  To: u-boot

On Thu, Nov 19, 2015 at 12:46:58PM +0100, Stefan Roese wrote:
> On 19.11.2015 12:19, Nikita Kiryanov wrote:
> >Hi Tom,
> >
> >On Wed, Nov 18, 2015 at 05:33:20PM -0500, Tom Rini wrote:
> >>On Sun, Nov 08, 2015 at 05:11:51PM +0200, Nikita Kiryanov wrote:
> >>
> >>>Introduce spl_boot_list array, which defines a list of boot devices
> >>>that SPL will try before hanging. By default this list will consist
> >>>of only spl_boot_device(), but board_boot_order() can be overridden
> >>>by board code to populate the array with custom values.
> >>>
> >>>Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
> >>>Cc: Igor Grinberg <grinberg@compulab.co.il>
> >>>Cc: Tom Rini <trini@konsulko.com>
> >>>Cc: Simon Glass <sjg@chromium.org>
> >>>Reviewed-by: Tom Rini <trini@konsulko.com>
> >>>Reviewed-by: Simon Glass <sjg@chromium.org>
> >>
> >>So, a problem with this patch is that we push the x600 board, which is
> >>an 8KiB SPL target, over the line.  I feel like maybe we need a
> >>follow-up patch that makes announcing depend not on libcommon (which
> >>x600 needs) but something else to know that there's a reason to
> >>announce.
> >
> >Based on the content of your reply I'm guessing you're referring to the
> >next patch, not this one.
> >
> >I suppose that announcing can be made into an optional feature. However,
> >I also think that since printing is an optional feature that can greatly
> >increase binary size, it shouldn't be coupled with other, often
> >non-optional libcommon features the way it currently is via
> >CONFIG_SPL_LIBCOMMON_SUPPORT. The best fix in my opinion would be to
> >implement a way to exclude printing support from SPL even if libcommon
> >is included (CONFIG_SPL_SILENT that replaces printfs with empty stubs?).
> >
> >This will also make it possible to remove all those #ifdef
> >CONFIG_SPL_LIBCOMMON_SUPPORT checks that appear all over the SPL code.
> 
> I think that my recently posted tiny-printf patches:
> 
> https://patchwork.ozlabs.org/patch/545034/
> https://patchwork.ozlabs.org/patch/545033/
> https://patchwork.ozlabs.org/patch/545036/
> https://patchwork.ozlabs.org/patch/545035/
> 
> can solve this size issue on x600 (and perhaps other) board.

If you can see if x600 builds again in mainline that would be good :)

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151119/8ffdd81f/attachment.sig>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [U-Boot] [U-Boot, V4, 10/13] spl: add support for alternative boot device
  2015-11-19 22:11         ` Tom Rini
@ 2015-11-20  6:35           ` Stefan Roese
  0 siblings, 0 replies; 37+ messages in thread
From: Stefan Roese @ 2015-11-20  6:35 UTC (permalink / raw)
  To: u-boot

Hi Tom,

On 19.11.2015 23:11, Tom Rini wrote:
> On Thu, Nov 19, 2015 at 12:46:58PM +0100, Stefan Roese wrote:
>> On 19.11.2015 12:19, Nikita Kiryanov wrote:
>>> Hi Tom,
>>>
>>> On Wed, Nov 18, 2015 at 05:33:20PM -0500, Tom Rini wrote:
>>>> On Sun, Nov 08, 2015 at 05:11:51PM +0200, Nikita Kiryanov wrote:
>>>>
>>>>> Introduce spl_boot_list array, which defines a list of boot devices
>>>>> that SPL will try before hanging. By default this list will consist
>>>>> of only spl_boot_device(), but board_boot_order() can be overridden
>>>>> by board code to populate the array with custom values.
>>>>>
>>>>> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
>>>>> Cc: Igor Grinberg <grinberg@compulab.co.il>
>>>>> Cc: Tom Rini <trini@konsulko.com>
>>>>> Cc: Simon Glass <sjg@chromium.org>
>>>>> Reviewed-by: Tom Rini <trini@konsulko.com>
>>>>> Reviewed-by: Simon Glass <sjg@chromium.org>
>>>>
>>>> So, a problem with this patch is that we push the x600 board, which is
>>>> an 8KiB SPL target, over the line.  I feel like maybe we need a
>>>> follow-up patch that makes announcing depend not on libcommon (which
>>>> x600 needs) but something else to know that there's a reason to
>>>> announce.
>>>
>>> Based on the content of your reply I'm guessing you're referring to the
>>> next patch, not this one.
>>>
>>> I suppose that announcing can be made into an optional feature. However,
>>> I also think that since printing is an optional feature that can greatly
>>> increase binary size, it shouldn't be coupled with other, often
>>> non-optional libcommon features the way it currently is via
>>> CONFIG_SPL_LIBCOMMON_SUPPORT. The best fix in my opinion would be to
>>> implement a way to exclude printing support from SPL even if libcommon
>>> is included (CONFIG_SPL_SILENT that replaces printfs with empty stubs?).
>>>
>>> This will also make it possible to remove all those #ifdef
>>> CONFIG_SPL_LIBCOMMON_SUPPORT checks that appear all over the SPL code.
>>
>> I think that my recently posted tiny-printf patches:
>>
>> https://patchwork.ozlabs.org/patch/545034/
>> https://patchwork.ozlabs.org/patch/545033/
>> https://patchwork.ozlabs.org/patch/545036/
>> https://patchwork.ozlabs.org/patch/545035/
>>
>> can solve this size issue on x600 (and perhaps other) board.
>
> If you can see if x600 builds again in mainline that would be good :)

Yes, I can confirm, that build with the tiny-printf fixes the
build issue on x600. So once you add this tiny-printf patchset,
I'll send a patch to move x600 over to use this smaller version.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2015-11-20  6:35 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-08 15:11 [U-Boot] [PATCH V4 00/13] SPL mmc refactor and alternate boot device feature Nikita Kiryanov
2015-11-08 15:11 ` [U-Boot] [PATCH V4 01/13] spl: nand: remove code duplication Nikita Kiryanov
2015-11-16 11:50   ` Heiko Schocher
2015-11-18 22:33   ` [U-Boot] [U-Boot,V4,01/13] " Tom Rini
2015-11-08 15:11 ` [U-Boot] [PATCH V4 02/13] spl: mmc: add break statements in spl_mmc_load_image() Nikita Kiryanov
2015-11-18 22:33   ` [U-Boot] [U-Boot, V4, " Tom Rini
2015-11-08 15:11 ` [U-Boot] [PATCH V4 03/13] spl: mmc: refactor device location code to its own function Nikita Kiryanov
2015-11-08 21:19   ` Tom Rini
2015-11-18 22:33   ` [U-Boot] [U-Boot, V4, " Tom Rini
2015-11-08 15:11 ` [U-Boot] [PATCH V4 04/13] spl: mmc: remove #ifdef CONFIG_SPL_OS_BOOT check Nikita Kiryanov
2015-11-18 22:33   ` [U-Boot] [U-Boot, V4, " Tom Rini
2015-11-08 15:11 ` [U-Boot] [PATCH V4 05/13] spl: mmc: get rid of #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION check Nikita Kiryanov
2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini
2015-11-08 15:11 ` [U-Boot] [PATCH V4 06/13] spl: mmc: move fs boot into its own function Nikita Kiryanov
2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini
2015-11-08 15:11 ` [U-Boot] [PATCH V4 07/13] spl: mmc: get rid of emmc boot code duplication Nikita Kiryanov
2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini
2015-11-08 15:11 ` [U-Boot] [PATCH V4 08/13] spl: change return values of spl_*_load_image() Nikita Kiryanov
2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini
2015-11-08 15:11 ` [U-Boot] [PATCH V4 09/13] common: spl: move image load to its own function Nikita Kiryanov
2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini
2015-11-08 15:11 ` [U-Boot] [PATCH V4 10/13] spl: add support for alternative boot device Nikita Kiryanov
2015-11-09 20:24   ` Simon Glass
2015-11-18 22:33   ` [U-Boot] [U-Boot, V4, " Tom Rini
2015-11-19 11:19     ` Nikita Kiryanov
2015-11-19 11:46       ` Stefan Roese
2015-11-19 22:11         ` Tom Rini
2015-11-20  6:35           ` Stefan Roese
2015-11-19 22:10       ` Tom Rini
2015-11-18 22:34   ` Tom Rini
2015-11-08 15:11 ` [U-Boot] [PATCH V4 11/13] spl: announce boot devices Nikita Kiryanov
2015-11-09 20:24   ` Simon Glass
2015-11-18 22:34   ` [U-Boot] [U-Boot,V4,11/13] " Tom Rini
2015-11-08 15:11 ` [U-Boot] [PATCH V4 12/13] arm: mx6: cm-fx6: define fallback boot devices for spl Nikita Kiryanov
2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini
2015-11-08 15:11 ` [U-Boot] [PATCH V4 13/13] spl: mmc: add support for BOOT_DEVICE_MMC2 Nikita Kiryanov
2015-11-18 22:34   ` [U-Boot] [U-Boot, V4, " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.