mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Julian Vetter <jvetter@kalrayinc.com>
To: barebox@lists.infradead.org
Cc: Yann Sionneau <ysionneau@kalrayinc.com>,
	Louis Morhet <lmorhet@kalrayinc.com>,
	Julian Vetter <jvetter@kalrayinc.com>
Subject: [PATCH v1] kvx: socinfo: Fix mppa ID read from fuses
Date: Wed, 23 Oct 2024 11:00:52 +0200	[thread overview]
Message-ID: <20241023090052.1596583-1-jvetter@kalrayinc.com> (raw)

From: Louis Morhet <lmorhet@kalrayinc.com>

On kv3-2 the traceability registers order has been fixed. So, the
reversing of 64 Bit register reads can be skipped on kv3-2.

Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
---
 drivers/soc/kvx/kvx_socinfo.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/soc/kvx/kvx_socinfo.c b/drivers/soc/kvx/kvx_socinfo.c
index 5f28f08bfb..4b193ebac9 100644
--- a/drivers/soc/kvx/kvx_socinfo.c
+++ b/drivers/soc/kvx/kvx_socinfo.c
@@ -22,7 +22,7 @@
 
 #define LOT_ID_STR_LEN	8
 
-#define EWS_LOT_ID_MASK		0x1ffffffffffULL
+#define EWS_LOT_ID_MASK		0x3ffffffffffULL
 #define EWS_WAFER_ID_SHIFT	42
 #define EWS_WAFER_ID_MASK	0x1fULL
 
@@ -70,8 +70,8 @@ static void kvx_soc_info_read_revision(void)
 static int base38_decode(char *s, u64 val, int nb_char)
 {
 	int i;
-	const char *alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_?";
-	const int base = strlen(alphabet);
+	const char alphabet[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
+	const int base = sizeof(alphabet);
 
 	if (s == NULL)
 		return -1;
@@ -102,7 +102,10 @@ static int kvx_read_mppa_id(struct device_node *socinfo)
 	}
 
 	ews_val = *cell_val64;
+#ifdef CONFIG_ARCH_COOLIDGE_V1
+	/* On kv3-1, 32b regs on traceability are written in reverse order */
 	ews_val = (ews_val >> 32) | (ews_val << 32);
+#endif
 	wafer_id = (ews_val >> EWS_WAFER_ID_SHIFT) & EWS_WAFER_ID_MASK;
 	base38_decode(lot_id, ews_val & EWS_LOT_ID_MASK, LOT_ID_STR_LEN);
 	free(cell_val64);
@@ -118,8 +121,7 @@ static int kvx_read_mppa_id(struct device_node *socinfo)
 	base38_decode(&com_ap, (ft_val >> FT_COM_AP_SHIFT) & FT_COM_AP_MASK, 1);
 	free(cell_val32);
 
-	kvx_mppa_id = basprintf("%sA-%d%c-%03d", lot_id, wafer_id, com_ap,
-			       device_id);
+	kvx_mppa_id = basprintf("%sA-%dE-%03d", lot_id, wafer_id, device_id);
 
 	globalvar_add_simple_string("kvx.mppa_id", &kvx_mppa_id);
 
-- 
2.34.1








             reply	other threads:[~2024-10-23  9:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-23  9:00 Julian Vetter [this message]
2024-10-23 12:46 ` 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=20241023090052.1596583-1-jvetter@kalrayinc.com \
    --to=jvetter@kalrayinc.com \
    --cc=barebox@lists.infradead.org \
    --cc=lmorhet@kalrayinc.com \
    --cc=ysionneau@kalrayinc.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