From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/3] ARM i.MX51: set barebox_loc according to boot source
Date: Mon, 15 Aug 2011 11:09:04 +0200 [thread overview]
Message-ID: <1313399344-21259-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1313399344-21259-1-git-send-email-s.hauer@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/imx51.c | 87 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 87 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-imx/imx51.c b/arch/arm/mach-imx/imx51.c
index 8b7c807..f2c886e 100644
--- a/arch/arm/mach-imx/imx51.c
+++ b/arch/arm/mach-imx/imx51.c
@@ -18,6 +18,7 @@
#include <init.h>
#include <common.h>
#include <sizes.h>
+#include <environment.h>
#include <asm/io.h>
#include <mach/imx51-regs.h>
@@ -89,3 +90,89 @@ static int imx51_init(void)
return 0;
}
coredevice_initcall(imx51_init);
+
+/*
+ * Saves the boot source media into the $barebox_loc enviroment variable
+ *
+ * This information is useful for barebox init scripts as we can then easily
+ * use a kernel image stored on the same media that we launch barebox with
+ * (for example).
+ *
+ * imx25 and imx35 can boot into barebox from several media such as
+ * nand, nor, mmc/sd cards, serial roms. "mmc" is used to represent several
+ * sources as its impossible to distinguish between them.
+ *
+ * Some sources such as serial roms can themselves have 3 different boot
+ * possibilities (i2c1, i2c2 etc). It is assumed that any board will
+ * only be using one of these at any one time.
+ *
+ * Note also that I suspect that the boot source pins are only sampled at
+ * power up.
+ */
+
+#define SRC_SBMR 0x4
+#define SBMR_BT_MEM_TYPE_SHIFT 7
+#define SBMR_BT_MEM_CTL_SHIFT 0
+#define SBMR_BMOD_SHIFT 14
+
+static int imx51_boot_save_loc(void)
+{
+ const char *bareboxloc = NULL;
+ uint32_t reg;
+ unsigned int ctrl, type;
+
+ /* [CTRL][TYPE] */
+ const char *const locations[4][4] = {
+ { /* CTRL = WEIM */
+ "nor",
+ NULL,
+ "onenand",
+ NULL,
+ }, { /* CTRL == NAND */
+ "nand",
+ "nand",
+ "nand",
+ "nand",
+ }, { /* CTRL == reserved */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ }, { /* CTRL == expansion */
+ "mmc",
+ NULL,
+ "i2c",
+ "spi",
+ }
+ };
+
+ reg = readl(MX51_SRC_BASE_ADDR + SRC_SBMR);
+
+ switch ((reg >> SBMR_BMOD_SHIFT) & 0x3) {
+ case 0:
+ case 2:
+ /* internal boot */
+ ctrl = (reg >> SBMR_BT_MEM_CTL_SHIFT) & 0x3;
+ type = (reg >> SBMR_BT_MEM_TYPE_SHIFT) & 0x3;
+
+ bareboxloc = locations[ctrl][type];
+ break;
+ case 1:
+ /* reserved */
+ bareboxloc = "unknown";
+ break;
+ case 3:
+ bareboxloc = "serial";
+ break;
+
+ }
+
+ if (bareboxloc) {
+ setenv("barebox_loc", bareboxloc);
+ export("barebox_loc");
+ }
+
+ return 0;
+}
+
+coredevice_initcall(imx51_boot_save_loc);
--
1.7.5.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-08-15 9:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-15 9:09 [PATCH] initialize barebox_loc on i.MX51 Sascha Hauer
2011-08-15 9:09 ` [PATCH 1/3] put env_push_context into postcore_initcall Sascha Hauer
2011-08-15 9:09 ` [PATCH 2/3] ARM i.MX25/35: initialize barebox_loc earlier Sascha Hauer
2011-08-15 9:09 ` Sascha Hauer [this message]
2011-08-17 9:25 ` [PATCH] initialize barebox_loc on i.MX51 Marc Reilly
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=1313399344-21259-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