mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/4] ARM i.MX53: set bootsource location
Date: Fri, 12 Oct 2012 18:52:53 +0200	[thread overview]
Message-ID: <1350060774-24779-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1350060774-24779-1-git-send-email-s.hauer@pengutronix.de>

To be able to set the environment location based on the
bootsource.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-imx/boot.c                 |   35 ++++++++++++++++++++++++++++++
 arch/arm/mach-imx/imx53.c                |    2 ++
 arch/arm/mach-imx/include/mach/generic.h |    2 ++
 3 files changed, 39 insertions(+)

diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index 409c237..cdddbe5 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -28,6 +28,7 @@ static const char *bootsource_str[] = {
 	[bootsource_spi] = "spi",
 	[bootsource_serial] = "serial",
 	[bootsource_onenand] = "onenand",
+	[bootsource_hd] = "harddisk",
 };
 
 static enum imx_bootsource bootsource;
@@ -183,3 +184,37 @@ int imx51_boot_save_loc(void __iomem *src_base)
 
 	return 0;
 }
+
+#define IMX53_SRC_SBMR	0x4
+int imx53_boot_save_loc(void __iomem *src_base)
+{
+	enum imx_bootsource src = bootsource_unknown;
+	uint32_t cfg1 = readl(src_base + IMX53_SRC_SBMR) & 0xff;
+
+	switch (cfg1 >> 4) {
+	case 2:
+		src = bootsource_hd;
+		break;
+	case 3:
+		if (cfg1 & (1 << 3))
+			src = bootsource_spi;
+		else
+			src = bootsource_i2c;
+		break;
+	case 4:
+	case 5:
+	case 6:
+	case 7:
+		src = bootsource_mmc;
+		break;
+	default:
+		break;
+	}
+
+	if (cfg1 & (1 << 7))
+		src = bootsource_nand;
+
+	imx_set_bootsource(src);
+
+	return 0;
+}
diff --git a/arch/arm/mach-imx/imx53.c b/arch/arm/mach-imx/imx53.c
index cac7b74..e424e7d 100644
--- a/arch/arm/mach-imx/imx53.c
+++ b/arch/arm/mach-imx/imx53.c
@@ -20,6 +20,7 @@
 #include <mach/imx53-regs.h>
 #include <mach/revision.h>
 #include <mach/clock-imx51_53.h>
+#include <mach/generic.h>
 
 #define SI_REV 0x48
 
@@ -52,6 +53,7 @@ static int imx53_silicon_revision(void)
 static int imx53_init(void)
 {
 	imx53_silicon_revision();
+	imx53_boot_save_loc((void *)MX53_SRC_BASE_ADDR);
 
 	add_generic_device("imx_iim", 0, NULL, MX53_IIM_BASE_ADDR, SZ_4K,
 			IORESOURCE_MEM, NULL);
diff --git a/arch/arm/mach-imx/include/mach/generic.h b/arch/arm/mach-imx/include/mach/generic.h
index 86966e4..39bb7e3 100644
--- a/arch/arm/mach-imx/include/mach/generic.h
+++ b/arch/arm/mach-imx/include/mach/generic.h
@@ -10,6 +10,7 @@ enum imx_bootsource {
 	bootsource_spi,
 	bootsource_serial,
 	bootsource_onenand,
+	bootsource_hd,
 };
 
 enum imx_bootsource imx_bootsource(void);
@@ -18,6 +19,7 @@ void imx_set_bootsource(enum imx_bootsource src);
 int imx_25_35_boot_save_loc(unsigned int ctrl, unsigned int type);
 void imx_27_boot_save_loc(void __iomem *sysctrl_base);
 int imx51_boot_save_loc(void __iomem *src_base);
+int imx53_boot_save_loc(void __iomem *src_base);
 
 /* There's a off-by-one betweem the gpio bank number and the gpiochip */
 /* range e.g. GPIO_1_5 is gpio 5 under linux */
-- 
1.7.10.4


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

  parent reply	other threads:[~2012-10-12 16:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-12 16:52 [PATCH] More Karo tx53 support Sascha Hauer
2012-10-12 16:52 ` [PATCH 1/4] ARM i.MX53: enable imx53_init_lowlevel for pbl Sascha Hauer
2012-10-12 16:52 ` [PATCH 2/4] ARM i.MX tx53: Add rev xx30 board support Sascha Hauer
2012-10-12 16:52 ` Sascha Hauer [this message]
2012-10-12 16:52 ` [PATCH 4/4] ARM i.MX Karo tx53: Add env depending on bootsource 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=1350060774-24779-4-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@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