From: Marc Kleine-Budde <mkl@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 10/10] ARM: mxs: add bootsource detection
Date: Thu, 14 Mar 2013 18:38:49 +0100 [thread overview]
Message-ID: <1363282729-18545-11-git-send-email-mkl@pengutronix.de> (raw)
In-Reply-To: <1363282729-18545-1-git-send-email-mkl@pengutronix.de>
For now only the v1.2 i.MX28 silicon is supported. The actual information is
read from a magic address within the internal SRAM.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
arch/arm/mach-mxs/imx.c | 99 +++++++++++++++++++++++++++++++
arch/arm/mach-mxs/include/mach/revision.h | 24 ++++++++
2 files changed, 123 insertions(+)
create mode 100644 arch/arm/mach-mxs/include/mach/revision.h
diff --git a/arch/arm/mach-mxs/imx.c b/arch/arm/mach-mxs/imx.c
index ab32f10..2ddec23 100644
--- a/arch/arm/mach-mxs/imx.c
+++ b/arch/arm/mach-mxs/imx.c
@@ -14,11 +14,15 @@
*/
#include <common.h>
+#include <bootsource.h>
#include <command.h>
#include <complete.h>
#include <init.h>
#include <io.h>
+
+#include <mach/generic.h>
#include <mach/imx-regs.h>
+#include <mach/revision.h>
#define HW_RTC_PERSISTENT1 0x070
@@ -55,3 +59,98 @@ BAREBOX_CMD_START(dump_clocks)
.usage = "show clock frequencies",
BAREBOX_CMD_COMPLETE(empty_complete)
BAREBOX_CMD_END
+
+
+static int __silicon_revision = SILICON_REVISION_UNKNOWN;
+
+int silicon_revision_get(void)
+{
+ return __silicon_revision;
+}
+
+void silicon_revision_set(const char *soc, int revision)
+{
+ __silicon_revision = revision;
+
+ printf("detected %s revision %d.%d\n", soc,
+ (revision >> 4) & 0xf, revision & 0xf);
+}
+
+#define HW_DIGCTL_CHIPID (0x8001c310)
+#define HW_DIGCTL_CHIPID_MASK (0xffff << 16)
+#define HW_DIGCTL_CHIPID_MX23 (0x3780 << 16)
+#define HW_DIGCTL_CHIPID_MX28 (0x2800 << 16)
+
+static void mxs_silicon_revision(void)
+{
+ enum silicon_revision revision = SILICON_REVISION_UNKNOWN;
+ const char *product = "unknown";
+ uint32_t reg;
+ uint8_t rev;
+
+ reg = readl((void __iomem *)HW_DIGCTL_CHIPID);
+ rev = reg & 0xff;
+
+ switch (reg & HW_DIGCTL_CHIPID_MASK) {
+ case HW_DIGCTL_CHIPID_MX23:
+ product = "i.MX23";
+ switch (rev) {
+ case 0x0: revision = SILICON_REVISION_1_0; break;
+ case 0x1: revision = SILICON_REVISION_1_1; break;
+ case 0x2: revision = SILICON_REVISION_1_2; break;
+ case 0x3: revision = SILICON_REVISION_1_3; break;
+ case 0x4: revision = SILICON_REVISION_1_4; break;
+ }
+ case HW_DIGCTL_CHIPID_MX28:
+ product = "i.MX28";
+ switch (rev) {
+ case 0x1: revision = SILICON_REVISION_1_2; break;
+ }
+ }
+
+ silicon_revision_set(product, revision);
+}
+
+#define MX28_REV_1_0_MODE (0x0001a7f0)
+#define MX28_REV_1_2_MODE (0x00019bf0)
+
+static void mxs_boot_save_loc(void)
+{
+ enum bootsource src = BOOTSOURCE_UNKNOWN;
+ int instance = 0;
+ uint32_t mode = 0xff;
+
+ if (cpu_is_mx23()) {
+ /* not implemented yet */
+ } else if (cpu_is_mx28()) {
+ enum silicon_revision rev = silicon_revision_get();
+
+ if (rev == SILICON_REVISION_1_2)
+ mode = *(uint32_t *)MX28_REV_1_2_MODE;
+ else
+ mode = *(uint32_t *)MX28_REV_1_0_MODE;
+ }
+
+ switch (mode & 0xf) {
+ case 0x0: src = BOOTSOURCE_USB; break; /* "USB" */
+ case 0x1: src = BOOTSOURCE_I2C; break; /* "I2C, master" */
+ case 0x3: instance = 1; /* fallthrough */ /* "SSP SPI #2, master, NOR" */
+ case 0x2: src = BOOTSOURCE_NOR; break; /* "SSP SPI #1, master, NOR" */
+ case 0x4: src = BOOTSOURCE_NAND; break; /* "NAND" */
+ case 0x8: src = BOOTSOURCE_EEPROM; break; /* "SSP SPI #3, master, EEPROM" */
+ case 0xa: instance = 1; /* fallthrough */ /* "SSP SD/MMC #1" */
+ case 0x9: src = BOOTSOURCE_MMC; break; /* "SSP SD/MMC #0" */
+ }
+
+ bootsource_set(src);
+ bootsource_set_instance(instance);
+}
+
+static int mxs_init(void)
+{
+ mxs_silicon_revision();
+ mxs_boot_save_loc();
+
+ return 0;
+}
+postcore_initcall(mxs_init);
diff --git a/arch/arm/mach-mxs/include/mach/revision.h b/arch/arm/mach-mxs/include/mach/revision.h
new file mode 100644
index 0000000..91f174d
--- /dev/null
+++ b/arch/arm/mach-mxs/include/mach/revision.h
@@ -0,0 +1,24 @@
+#ifndef __MACH_REVISION_H__
+#define __MACH_REVISION_H__
+
+/* silicon revisions */
+enum silicon_revision {
+ SILICON_REVISION_1_0 = 0x10,
+ SILICON_REVISION_1_1 = 0x11,
+ SILICON_REVISION_1_2 = 0x12,
+ SILICON_REVISION_1_3 = 0x13,
+ SILICON_REVISION_1_4 = 0x14,
+ SILICON_REVISION_2_0 = 0x20,
+ SILICON_REVISION_2_1 = 0x21,
+ SILICON_REVISION_2_2 = 0x22,
+ SILICON_REVISION_2_3 = 0x23,
+ SILICON_REVISION_3_0 = 0x30,
+ SILICON_REVISION_3_1 = 0x31,
+ SILICON_REVISION_3_2 = 0x32,
+ SILICON_REVISION_UNKNOWN =0xff
+};
+
+int silicon_revision_get(void);
+void silicon_revision_set(const char *soc, int revision);
+
+#endif /* __MACH_REVISION_H__ */
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2013-03-14 17:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-14 17:38 [PATCH 00/10] make bootsource an arch independent framework Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 01/10] ARM i.MX bootsource: convert enums from enum imx_bootsource to uppercase Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 02/10] ARM i.MX bootsource: convert all imx*_boot_save_loc functions to void Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 03/10] ARM i.MX bootsource: imx_25_35_boot_save_loc: remove leftover do-nothing code Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 04/10] ARM i.MX bootsource: rename imx_27_boot_save_loc -> imx27_boot_save_loc Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 05/10] ARM i.MX bootsource: add separate function for mx25 and mx35 Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 06/10] bootsource: create arch independent bootsource framework Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 07/10] bootsource: use initcall to export bootsource location to environment Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 08/10] bootsource: add support for bootsource instance information Marc Kleine-Budde
2013-03-14 17:38 ` [PATCH 09/10] bootsource: add definition for usb and eeprom Marc Kleine-Budde
2013-03-14 17:38 ` Marc Kleine-Budde [this message]
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=1363282729-18545-11-git-send-email-mkl@pengutronix.de \
--to=mkl@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