mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Hans Christian Lonstad <hcl@datarespons.com>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/3] nvmem: ocotp: prepare adding tester3 support
Date: Fri, 19 Jan 2024 23:45:21 +0100	[thread overview]
Message-ID: <20240119224522.1399213-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240119224522.1399213-1-a.fatoum@pengutronix.de>

The tester fuses are written to the OCOTP by NXP during production.
So far, we only evaluated tester4 to determine which peripherals
are missing from the SoC. On the i.MX8MP, VPU and CPUs existence is
instead encoded into the tester3 fuse word. In preparation for adding
support for tester4, rename the existing masks to be tester4-specific.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/nvmem/ocotp.c            | 14 +++++++-------
 drivers/soc/imx/imx8m-featctrl.c | 32 +++++++++++++++++++-------------
 include/soc/imx8m/featctrl.h     | 12 +++++++-----
 3 files changed, 33 insertions(+), 25 deletions(-)

diff --git a/drivers/nvmem/ocotp.c b/drivers/nvmem/ocotp.c
index 66a88ae48033..ccdc8a417ed1 100644
--- a/drivers/nvmem/ocotp.c
+++ b/drivers/nvmem/ocotp.c
@@ -959,9 +959,9 @@ static struct imx_ocotp_data vf610_ocotp_data = {
 };
 
 static struct imx8m_featctrl_data imx8mp_featctrl_data = {
-	.gpu_bitmask = 0xc0,
-	.mipi_dsi_bitmask = 0x60000,
-	.isp_bitmask = 0x3,
+	.tester4.gpu_bitmask = 0xc0,
+	.tester4.mipi_dsi_bitmask = 0x60000,
+	.tester4.isp_bitmask = 0x3,
 };
 
 static struct imx_ocotp_data imx8mp_ocotp_data = {
@@ -990,8 +990,8 @@ static struct imx_ocotp_data imx8mq_ocotp_data = {
 };
 
 static struct imx8m_featctrl_data imx8mm_featctrl_data = {
-	.vpu_bitmask = 0x1c0000,
-	.check_cpus = true,
+	.tester4.vpu_bitmask = 0x1c0000,
+	.tester4.cpu_bitmask = 0x3,
 };
 
 static struct imx_ocotp_data imx8mm_ocotp_data = {
@@ -1008,8 +1008,8 @@ static struct imx_ocotp_data imx8mm_ocotp_data = {
 };
 
 static struct imx8m_featctrl_data imx8mn_featctrl_data = {
-	.gpu_bitmask = 0x1000000,
-	.check_cpus = true,
+	.tester4.gpu_bitmask = 0x1000000,
+	.tester4.cpu_bitmask = 0x3,
 };
 
 static struct imx_ocotp_data imx8mn_ocotp_data = {
diff --git a/drivers/soc/imx/imx8m-featctrl.c b/drivers/soc/imx/imx8m-featctrl.c
index 9a2b66555dce..23a3f990160d 100644
--- a/drivers/soc/imx/imx8m-featctrl.c
+++ b/drivers/soc/imx/imx8m-featctrl.c
@@ -33,6 +33,19 @@ static inline bool is_fused(u32 val, u32 bitmask)
 	return bitmask && (val & bitmask) == bitmask;
 }
 
+#define field_get(_mask, _reg) (((_reg) & (_mask)) >> (ffs(_mask) - 1))
+
+static void check_cpus(u32 mask, u32 reg, unsigned long *features)
+{
+	switch (field_get(mask, reg)) {
+	case 0b11:
+		clear_bit(IMX8M_FEAT_CPU_DUAL, features);
+		fallthrough;
+	case 0b10:
+		clear_bit(IMX8M_FEAT_CPU_QUAD, features);
+	}
+}
+
 int imx8m_feat_ctrl_init(struct device *dev, u32 tester4,
 			 const struct imx8m_featctrl_data *data)
 {
@@ -49,24 +62,17 @@ int imx8m_feat_ctrl_init(struct device *dev, u32 tester4,
 
 	bitmap_fill(features, IMX8M_FEAT_END);
 
-	if (is_fused(tester4, data->vpu_bitmask))
+	if (is_fused(tester4, data->tester4.vpu_bitmask))
 		clear_bit(IMX8M_FEAT_VPU, features);
-	if (is_fused(tester4, data->gpu_bitmask))
+	if (is_fused(tester4, data->tester4.gpu_bitmask))
 		clear_bit(IMX8M_FEAT_GPU, features);
-	if (is_fused(tester4, data->mipi_dsi_bitmask))
+	if (is_fused(tester4, data->tester4.mipi_dsi_bitmask))
 		clear_bit(IMX8M_FEAT_MIPI_DSI, features);
-	if (is_fused(tester4, data->isp_bitmask))
+	if (is_fused(tester4, data->tester4.isp_bitmask))
 		clear_bit(IMX8M_FEAT_ISP, features);
 
-	if (data->check_cpus) {
-		switch (tester4 & 3) {
-		case 0b11:
-			clear_bit(IMX8M_FEAT_CPU_DUAL, features);
-			fallthrough;
-		case 0b10:
-			clear_bit(IMX8M_FEAT_CPU_QUAD, features);
-		}
-	}
+	if (data->tester4.cpu_bitmask)
+		check_cpus(data->tester4.cpu_bitmask, tester4, features);
 
 	priv->feat.dev = dev;
 	priv->feat.check = imx8m_feat_check;
diff --git a/include/soc/imx8m/featctrl.h b/include/soc/imx8m/featctrl.h
index 91d14bc68c0a..cfbc3fad80f4 100644
--- a/include/soc/imx8m/featctrl.h
+++ b/include/soc/imx8m/featctrl.h
@@ -7,11 +7,13 @@
 #include <linux/types.h>
 
 struct imx8m_featctrl_data {
-	u32 vpu_bitmask;
-	u32 gpu_bitmask;
-	u32 mipi_dsi_bitmask;
-	u32 isp_bitmask;
-	bool check_cpus;
+	struct {
+		u32 vpu_bitmask;
+		u32 gpu_bitmask;
+		u32 mipi_dsi_bitmask;
+		u32 isp_bitmask;
+		u32 cpu_bitmask;
+	} tester4;
 };
 
 struct device;
-- 
2.39.2




  parent reply	other threads:[~2024-01-19 22:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19 22:45 [PATCH 0/3] soc: imx: featctrl: finalize support for i.MX8MP Ahmad Fatoum
2024-01-19 22:45 ` [PATCH 1/3] soc: imx: imx8m-featctrl: make header self-contained Ahmad Fatoum
2024-01-19 22:45 ` Ahmad Fatoum [this message]
2024-01-22  9:35   ` [PATCH 2/3] nvmem: ocotp: prepare adding tester3 support Sascha Hauer
2024-01-19 22:45 ` [PATCH 3/3] soc: imx: featctrl: finalize support for i.MX8MP Ahmad Fatoum
2024-01-22  9:31 ` [PATCH 0/3] " 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=20240119224522.1399213-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=hcl@datarespons.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