mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Steffen Trumtrar <s.trumtrar@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Subject: [PATCH 3/7] ARM: socfpga: xload: support more qspi partitions
Date: Tue,  9 Aug 2016 14:37:28 +0200	[thread overview]
Message-ID: <1470746252-3146-3-git-send-email-s.trumtrar@pengutronix.de> (raw)
In-Reply-To: <1470746252-3146-1-git-send-email-s.trumtrar@pengutronix.de>

From: Ulrich Ölmann <u.oelmann@pengutronix.de>

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
 arch/arm/mach-socfpga/xload.c | 56 +++++++++++++++++++++++++++++++------------
 1 file changed, 41 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-socfpga/xload.c b/arch/arm/mach-socfpga/xload.c
index 7f8f0320ca0e..993626966e17 100644
--- a/arch/arm/mach-socfpga/xload.c
+++ b/arch/arm/mach-socfpga/xload.c
@@ -20,13 +20,15 @@
 #include <mach/system-manager.h>
 #include <mach/socfpga-regs.h>
 
-
-static struct socfpga_barebox_part default_part = {
-	.nor_offset = SZ_256K,
-	.nor_size = SZ_1M,
-	.mmc_disk = "disk0.1",
+static struct socfpga_barebox_part default_parts[] = {
+	{
+		.nor_offset = SZ_256K,
+		.nor_size = SZ_1M,
+		.mmc_disk = "disk0.1",
+	},
+	{ /* sentinel */ }
 };
-const struct socfpga_barebox_part *barebox_part = &default_part;
+const struct socfpga_barebox_part *barebox_parts = &default_parts;
 
 enum socfpga_clks {
 	timer, mmc, qspi_clk, uart, clk_max
@@ -109,28 +111,52 @@ static void socfpga_timer_init(void)
 static __noreturn int socfpga_xload(void)
 {
 	enum bootsource bootsource = bootsource_get();
-	void *buf;
+	struct socfpga_barebox_part *part;
+	void *buf = NULL;
 
 	switch (bootsource) {
 	case BOOTSOURCE_MMC:
 		socfpga_mmc_init();
-		buf = bootstrap_read_disk(barebox_part->mmc_disk, "fat");
+
+		for (part = barebox_parts; part->mmc_disk; part++) {
+			buf = bootstrap_read_disk(barebox_parts->mmc_disk, "fat");
+			if (!buf) {
+				pr_info("failed to load barebox from MMC %s\n",
+					part->mmc_disk);
+				continue;
+			}
+		}
+		if (!buf) {
+			pr_err("failed to load barebox.bin from MMC\n");
+			hang();
+		}
 		break;
 	case BOOTSOURCE_SPI:
 		socfpga_qspi_init();
-		buf = bootstrap_read_devfs("mtd0", false, barebox_part->nor_offset,
-					barebox_part->nor_size, SZ_1M);
+
+		for (part = barebox_parts; part->nor_size; part++) {
+			buf = bootstrap_read_devfs("mtd0", false,
+					part->nor_offset, part->nor_size, SZ_1M);
+			if (!buf) {
+				pr_info("failed to load barebox from QSPI NOR flash at offset %#x\n",
+					part->nor_offset);
+				continue;
+			}
+
+			break;
+		}
+
+		if (!buf) {
+			pr_err("failed to load barebox from QSPI NOR flash\n");
+			hang();
+		}
+
 		break;
 	default:
 		pr_err("unknown bootsource %d\n", bootsource);
 		hang();
 	}
 
-	if (!buf) {
-		pr_err("failed to load barebox.bin\n");
-		hang();
-	}
-
 	pr_info("starting bootloader...\n");
 
 	bootstrap_boot(buf, 0);
-- 
2.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2016-08-09 12:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-09 12:37 [PATCH 1/7] filetype: add new filetype for SoCFPGA xload image Steffen Trumtrar
2016-08-09 12:37 ` [PATCH 2/7] ARM: socfpga: defconfig: add bootstrap_devfs Steffen Trumtrar
2016-08-09 17:48   ` Trent Piepho
2016-08-10  6:14     ` Steffen Trumtrar
2016-08-09 12:37 ` Steffen Trumtrar [this message]
2016-08-09 12:37 ` [PATCH 4/7] socfpga: remove dt entries that are upstream Steffen Trumtrar
2016-08-09 12:37 ` [PATCH 5/7] ARM: socfpga: socrates: set alias for ethernet0 Steffen Trumtrar
2016-08-09 12:37 ` [PATCH 6/7] ARM: socfpga: socrates: add qspi partitions Steffen Trumtrar
2016-08-09 12:37 ` [PATCH 7/7] ARM: socfpga: socrates: register bbu handlers Steffen Trumtrar
2016-08-18  6:23 ` [PATCH 1/7] filetype: add new filetype for SoCFPGA xload image Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470746252-3146-3-git-send-email-s.trumtrar@pengutronix.de \
    --to=s.trumtrar@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox