mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>,
	Chris Healy <cphealy@gmail.com>
Subject: [PATCH 1/2] i.MX: Introduce imx_ocotp_read_uid()
Date: Fri, 13 Sep 2019 23:02:46 -0700	[thread overview]
Message-ID: <20190914060247.23673-1-andrew.smirnov@gmail.com> (raw)

UID information in OCOTP is located in the same place on at least
i.MX6, i.MX7 and i.MX8MQ. Create an SoC-agnostic helper to do all the
work and convert i.MX6 to use it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>
---
 arch/arm/mach-imx/imx6.c               |  8 +-------
 arch/arm/mach-imx/include/mach/ocotp.h | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
index 0fdd9f082f..41e0066add 100644
--- a/arch/arm/mach-imx/imx6.c
+++ b/arch/arm/mach-imx/imx6.c
@@ -192,13 +192,7 @@ int imx6_cpu_revision(void)
 
 u64 imx6_uid(void)
 {
-	void __iomem *ocotpbase = IOMEM(MX6_OCOTP_BASE_ADDR);
-	u64 uid;
-
-	uid = ((u64)readl(ocotpbase + MX6_OCOTP_CFG0) << 32);
-	uid |= (u64)readl(ocotpbase + MX6_OCOTP_CFG1);
-
-	return uid;
+	return imx_ocotp_read_uid(IOMEM(MX6_OCOTP_BASE_ADDR));
 }
 
 int imx6_init(void)
diff --git a/arch/arm/mach-imx/include/mach/ocotp.h b/arch/arm/mach-imx/include/mach/ocotp.h
index e758238cb9..7ba5da156b 100644
--- a/arch/arm/mach-imx/include/mach/ocotp.h
+++ b/arch/arm/mach-imx/include/mach/ocotp.h
@@ -26,10 +26,24 @@
 #define OCOTP_BIT(n)		FIELD_PREP(OCOTP_BIT_MASK, n)
 #define OCOTP_WIDTH(n)		FIELD_PREP(OCOTP_WIDTH_MASK, (n) - 1)
 
+#define OCOTP_OFFSET_CFG0	0x410
+#define OCOTP_OFFSET_CFG1	0x420
+
 
 int imx_ocotp_read_field(uint32_t field, unsigned *value);
 int imx_ocotp_write_field(uint32_t field, unsigned value);
 int imx_ocotp_permanent_write(int enable);
 bool imx_ocotp_sense_enable(bool enable);
 
+static inline u64 imx_ocotp_read_uid(void __iomem *ocotp)
+{
+	u64 uid;
+
+	uid  = readl(ocotp + OCOTP_OFFSET_CFG0);
+	uid <<= 32;
+	uid |= readl(ocotp + OCOTP_OFFSET_CFG1);
+
+	return uid;
+}
+
 #endif /* __MACH_IMX_OCOTP_H */
-- 
2.21.0


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

             reply	other threads:[~2019-09-14  6:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-14  6:02 Andrey Smirnov [this message]
2019-09-14  6:02 ` [PATCH 2/2] ARM: i.MX8MQ: Display UID information on boot Andrey Smirnov
2019-09-16  7:09 ` [PATCH 1/2] i.MX: Introduce imx_ocotp_read_uid() 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=20190914060247.23673-1-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=cphealy@gmail.com \
    /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