All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@nxp.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2 12/12] imx: mx7dsabresd: add board revision check
Date: Thu, 13 Apr 2017 14:10:00 +0800	[thread overview]
Message-ID: <1492063800-17290-12-git-send-email-peng.fan@nxp.com> (raw)
In-Reply-To: <1492063800-17290-1-git-send-email-peng.fan@nxp.com>

Add board revision check

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 board/freescale/mx7dsabresd/mx7dsabresd.c | 59 ++++++++++++++++++++++++++++++-
 1 file changed, 58 insertions(+), 1 deletion(-)

diff --git a/board/freescale/mx7dsabresd/mx7dsabresd.c b/board/freescale/mx7dsabresd/mx7dsabresd.c
index ecea5a5..07392fa 100644
--- a/board/freescale/mx7dsabresd/mx7dsabresd.c
+++ b/board/freescale/mx7dsabresd/mx7dsabresd.c
@@ -82,6 +82,48 @@ static iomux_v3_cfg_t const uart1_pads[] = {
 	MX7D_PAD_UART1_RX_DATA__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
 };
 
+#define BOARD_REV_C  0x300
+#define BOARD_REV_B  0x200
+#define BOARD_REV_A  0x100
+
+static int mx7sabre_rev(void)
+{
+	/*
+	 * Get Board ID information from OCOTP_GP1[15:8]
+	 * i.MX7D SDB RevA: 0x41
+	 * i.MX7D SDB RevB: 0x42
+	 */
+	struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
+	struct fuse_bank *bank = &ocotp->bank[14];
+	int reg = readl(&bank->fuse_regs[0]);
+	int ret;
+
+	if (reg != 0) {
+		switch (reg >> 8 & 0x0F) {
+		case 0x3:
+			ret = BOARD_REV_C;
+			break;
+		case 0x02:
+			ret = BOARD_REV_B;
+			break;
+		case 0x01:
+		default:
+			ret = BOARD_REV_A;
+			break;
+		}
+	} else {
+		/* If the gp1 fuse is not burn, we have to use TO rev for the board rev */
+		if (is_soc_rev(CHIP_REV_1_0))
+			ret = BOARD_REV_A;
+		else if (is_soc_rev(CHIP_REV_1_1))
+			ret = BOARD_REV_B;
+		else
+			ret = BOARD_REV_C;
+	}
+
+	return ret;
+}
+
 #ifdef CONFIG_NAND_MXS
 static iomux_v3_cfg_t const gpmi_pads[] = {
 	MX7D_PAD_SD3_DATA0__NAND_DATA00 | MUX_PAD_CTRL(NAND_PAD_CTRL),
@@ -377,14 +419,29 @@ int board_late_init(void)
 
 int checkboard(void)
 {
+	int rev = mx7sabre_rev();
 	char *mode;
+	char *revname;
 
 	if (IS_ENABLED(CONFIG_ARMV7_BOOT_SEC_DEFAULT))
 		mode = "secure";
 	else
 		mode = "non-secure";
 
-	printf("Board: i.MX7D SABRESD in %s mode\n", mode);
+	switch (rev) {
+	case BOARD_REV_C:
+		revname = "C";
+		break;
+	case BOARD_REV_B:
+		revname = "B";
+		break;
+	case BOARD_REV_A:
+	default:
+		revname = "A";
+		break;
+	}
+
+	printf("Board: i.MX7D SABRESD Rev%s in %s mode\n", revname, mode);
 
 	return 0;
 }
-- 
2.6.2

  parent reply	other threads:[~2017-04-13  6:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-13  6:09 [U-Boot] [PATCH V2 01/12] arm: dts: imx7: sync with Linux Peng Fan
2017-04-13  6:09 ` [U-Boot] [PATCH V2 02/12] arm: dts: imx7d-sdb add basic dts Peng Fan
2017-04-13  6:09 ` [U-Boot] [PATCH V2 03/12] arm: dts: imx7d-sdb: add spi gpio node Peng Fan
2017-04-13  6:09 ` [U-Boot] [PATCH V2 04/12] arm: dts: imx7d-sdb: add regulator node for usb and mmc Peng Fan
2017-04-13  6:09 ` [U-Boot] [PATCH V2 05/12] arm: dts: imx7d-sdb: add i2c support Peng Fan
2017-04-13  6:09 ` [U-Boot] [PATCH V2 06/12] arm: dts: imx7d-sdb: add usdhc support Peng Fan
2017-04-13  6:09 ` [U-Boot] [PATCH V2 07/12] spi: kconfig: add soft spi Kconfig entry Peng Fan
2017-05-03  6:06   ` Jagan Teki
2017-05-08  2:47     ` Peng Fan
2017-04-13  6:09 ` [U-Boot] [PATCH V2 08/12] gpio: 74x164: make oe-pins optional Peng Fan
2017-04-16 19:32   ` Simon Glass
2017-04-13  6:09 ` [U-Boot] [PATCH V2 09/12] imx: mx7dsabresd: enable more DM drivers Peng Fan
2017-05-18  8:46   ` Stefano Babic
2017-04-13  6:09 ` [U-Boot] [PATCH V2 10/12] imx: mx7dsabresd: reset ENET_RST_B Peng Fan
2017-04-13  6:09 ` [U-Boot] [PATCH V2 11/12] imx: mx7dsabresd: switch to DM USB Peng Fan
2017-04-13  6:10 ` Peng Fan [this message]
2017-04-17 15:00   ` [U-Boot] [PATCH V2 12/12] imx: mx7dsabresd: add board revision check Fabio Estevam
2017-04-18  0:54     ` Peng Fan
2017-05-11 11:33       ` Stefano Babic
2017-05-11 12:52         ` Peng Fan
2017-05-18  8:19       ` Stefano Babic
2017-05-18  8:51         ` Peng Fan
2017-05-18  9:00           ` Stefano Babic
2017-05-11 11:35 ` [U-Boot] [PATCH V2 01/12] arm: dts: imx7: sync with Linux Stefano Babic

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=1492063800-17290-12-git-send-email-peng.fan@nxp.com \
    --to=peng.fan@nxp.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.