mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Philipp Zabel <philipp.zabel@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH] ARM i.MX6: Fix bootsource detection
Date: Thu,  6 Jun 2013 08:32:49 +0200	[thread overview]
Message-ID: <1370500369-3657-1-git-send-email-philipp.zabel@gmail.com> (raw)

This patch fixes bootsource detection on i.MX6 for serial and i2c boot.
The bootsource_instance is now determined for spi, i2c, and mmc/sd boot.

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
---
 arch/arm/mach-imx/boot.c |   26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index bd0cb84..4d81fd4 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -217,11 +217,13 @@ void imx53_boot_save_loc(void __iomem *src_base)
 void imx6_boot_save_loc(void __iomem *src_base)
 {
 	enum bootsource src = BOOTSOURCE_UNKNOWN;
-	uint32_t sbmr2 = readl(src_base + IMX6_SRC_SBMR2) >> 24;
-	uint32_t cfg1 = readl(src_base + IMX6_SRC_SBMR1) & 0xff;
+	int instance = BOOTSOURCE_INSTANCE_UNKNOWN;
+	uint32_t sbmr1 = readl(src_base + IMX6_SRC_SBMR1);
+	uint32_t sbmr2 = readl(src_base + IMX6_SRC_SBMR2);
 	uint32_t boot_cfg_4_2_0;
 	int boot_mode;
 
+	/* BMOD[1:0] */
 	boot_mode = (sbmr2 >> 24) & 0x3;
 
 	switch (boot_mode) {
@@ -241,32 +243,42 @@ void imx6_boot_save_loc(void __iomem *src_base)
 
 internal_boot:
 
-	switch (cfg1 >> 4) {
+	/* BOOT_CFG1[7:4] */
+	switch ((sbmr1 >> 4) & 0xf) {
 	case 2:
 		src = BOOTSOURCE_HD;
 		break;
 	case 3:
-		boot_cfg_4_2_0 = (cfg1 >> 16) & 0x7;
+		/* BOOT_CFG4[2:0] */
+		boot_cfg_4_2_0 = (sbmr1 >> 24) & 0x7;
 
-		if (boot_cfg_4_2_0 > 4)
+		if (boot_cfg_4_2_0 > 4) {
 			src = BOOTSOURCE_I2C;
-		else
+			instance = boot_cfg_4_2_0 - 5;
+		} else {
 			src = BOOTSOURCE_SPI;
+			instance = boot_cfg_4_2_0;
+		}
 		break;
 	case 4:
 	case 5:
 	case 6:
 	case 7:
 		src = BOOTSOURCE_MMC;
+
+		/* BOOT_CFG2[4:3] */
+		instance = (sbmr1 >> 11) & 0x3;
 		break;
 	default:
 		break;
 	}
 
-	if (cfg1 & (1 << 7))
+	/* BOOT_CFG1[7:0] */
+	if (sbmr1 & (1 << 7))
 		src = BOOTSOURCE_NAND;
 
 	bootsource_set(src);
+	bootsource_set_instance(instance);
 
 	return;
 }
-- 
1.7.10.4


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

             reply	other threads:[~2013-06-06  6:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-06  6:32 Philipp Zabel [this message]
2013-06-08 13:22 ` 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=1370500369-3657-1-git-send-email-philipp.zabel@gmail.com \
    --to=philipp.zabel@gmail.com \
    --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