All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@seco.com>
To: u-boot@lists.denx.de
Subject: [PATCH v2] ARM: mx6: Add function to set serial#
Date: Thu,  4 Feb 2021 16:44:22 -0500	[thread overview]
Message-ID: <20210204214422.1701664-1-sean.anderson@seco.com> (raw)

The serial number OTP is similar to the imx7 version, except that the
register names are different. This also sets serial# directly, instead of
providing board_get_serial.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

Changes in v2:
- Populate serial# directly and call this from arch_misc_init

 arch/arm/mach-imx/mx6/soc.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/arch/arm/mach-imx/mx6/soc.c b/arch/arm/mach-imx/mx6/soc.c
index bf6dddfdc9..aacfc854a2 100644
--- a/arch/arm/mach-imx/mx6/soc.c
+++ b/arch/arm/mach-imx/mx6/soc.c
@@ -7,6 +7,7 @@
  */
 
 #include <common.h>
+#include <env.h>
 #include <init.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
@@ -696,11 +697,47 @@ void imx_setup_hdmi(void)
 #endif
 
 #ifdef CONFIG_ARCH_MISC_INIT
+/*
+ * UNIQUE_ID describes a unique ID based on silicon wafer
+ * and die X/Y position
+ *
+ * UNIQUE_ID offset 0x410
+ * 31:0 fuse 0
+ * FSL-wide unique, encoded LOT ID STD II/SJC CHALLENGE/ Unique ID
+ *
+ * UNIQUE_ID offset 0x420
+ * 31:24 fuse 1
+ * The X-coordinate of the die location on the wafer/SJC CHALLENGE/ Unique ID
+ * 23:16 fuse 1
+ * The Y-coordinate of the die location on the wafer/SJC CHALLENGE/ Unique ID
+ * 15:11 fuse 1
+ * The wafer number of the wafer on which the device was fabricated/SJC
+ * CHALLENGE/ Unique ID
+ * 10:0 fuse 1
+ * FSL-wide unique, encoded LOT ID STD II/SJC CHALLENGE/ Unique ID
+ */
+static void setup_serial_number(void)
+{
+	char serial_string[17];
+	struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
+	struct fuse_bank *bank = &ocotp->bank[0];
+	struct fuse_bank0_regs *fuse =
+		(struct fuse_bank0_regs *)bank->fuse_regs;
+
+	if (env_get("serial#"))
+		return;
+
+	snprintf(serial_string, sizeof(serial_string), "%08x%08x",
+		 fuse->uid_low, fuse->uid_high);
+	env_set("serial#", serial_string);
+}
+
 int arch_misc_init(void)
 {
 #ifdef CONFIG_FSL_CAAM
 	sec_init();
 #endif
+	setup_serial_number();
 	return 0;
 }
 #endif
-- 
2.25.1

             reply	other threads:[~2021-02-04 21:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-04 21:44 Sean Anderson [this message]
2021-02-04 21:58 ` [PATCH v2] ARM: mx6: Add function to set serial# Tom Rini
2021-02-04 22:03   ` Heinrich Schuchardt
2021-02-04 22:12     ` Sean Anderson
2021-02-04 22:31       ` Heinrich Schuchardt
2021-02-04 22:55         ` Tom Rini
2021-02-04 22:23     ` Tom Rini
2021-03-01 11:55 ` sbabic at denx.de

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=20210204214422.1701664-1-sean.anderson@seco.com \
    --to=sean.anderson@seco.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.