From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Thu, 13 Nov 2025 10:35:09 +0100 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vJTjR-000UrK-1S for lore@lore.pengutronix.de; Thu, 13 Nov 2025 10:35:09 +0100 Received: from bombadil.infradead.org ([2607:7c80:54:3::133]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vJTjQ-0007Mp-S0 for lore@pengutronix.de; Thu, 13 Nov 2025 10:35:09 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5rGUYp/LfF+CjKB6lnpKTmzio7XFcCJuGK8EKV4d710=; b=YNF2aaUOjH6OwLZ+BtfGpeEY1D aIUD3NJWmwu8WnLbhT6ETjr/D44/8RJu7/K4+KU2hYR+GCXQg/4uG8XY/+o8ps/aT2j3Frs4cgNzZ DnWG36D42ZrwxGGbJyFuIuAce7t5LB4noRMIFEy9VrQWVreQwlF61jNUvGmXnjOMKRD5LqsKbgPlO +OUcbHVW7+SoDV4FnX6Rsq0WMNvJGI6GK505pRf3lpCPRYnOsRldyU9Xl2Le69/yShWmt6eLWx6ms Pwk6sD1gkb0FvpfVtIZRzhY9fGSj6ZQ2vPLVYGnendttatq3cpgT7HmdGMk84HPoQQyVeUHug8Tw7 JwTYxuQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vJTiw-0000000ACTR-2GGc; Thu, 13 Nov 2025 09:34:38 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vJTir-0000000ACRX-3CpA for barebox@lists.infradead.org; Thu, 13 Nov 2025 09:34:35 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vJTio-00070G-B0; Thu, 13 Nov 2025 10:34:30 +0100 Received: from dude02.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::28]) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vJTio-000EXu-00; Thu, 13 Nov 2025 10:34:30 +0100 Received: from localhost ([::1] helo=dude02.red.stw.pengutronix.de) by dude02.red.stw.pengutronix.de with esmtp (Exim 4.98.2) (envelope-from ) id 1vJTio-00000008Q1y-1Hvr; Thu, 13 Nov 2025 10:34:29 +0100 From: Sascha Hauer Date: Thu, 13 Nov 2025 10:34:30 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20251113-soc-uid-v1-6-29a256e07144@pengutronix.de> References: <20251113-soc-uid-v1-0-29a256e07144@pengutronix.de> In-Reply-To: <20251113-soc-uid-v1-0-29a256e07144@pengutronix.de> To: BAREBOX X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763026469; l=1996; i=s.hauer@pengutronix.de; s=20230412; h=from:subject:message-id; bh=5NTDWuCOvms33QU8DZsV6Z2jNden2Y/HlsnNL/JlKDs=; b=D8RZhEFpx+5/Mb84U47G+Mo/i12AiyIliEXubCX51rIb+BApuSL7pkm41EyKSKxVVSGRUUgZr eSDja4fGs2HCf0DIsQYlk2iUXDJW0YVUq2nH/ZeQWEyQIGfm8Q1BPOF X-Developer-Key: i=s.hauer@pengutronix.de; a=ed25519; pk=4kuc9ocmECiBJKWxYgqyhtZOHj5AWi7+d0n/UjhkwTg= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251113_013433_853958_C14E386B X-CRM114-Status: GOOD ( 13.11 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:3::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-4.0 required=4.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Subject: [PATCH 6/9] nvmem: ocotp: Fix SoC ID reading for i.MX8MP X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.whiteo.stw.pengutronix.de) On i.MX8MP the SoC ID is stored at 0x420/0x430, not on 0x410/0x420 as on other i.MX8M SoCs. Also on i.MX8MP the SoC ID is 128bit and not 64bit with the upper bits stored at 0xe00/0xe10. Signed-off-by: Sascha Hauer --- drivers/nvmem/ocotp.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/nvmem/ocotp.c b/drivers/nvmem/ocotp.c index 7bca27540417ad9ba0ce5c5f8ec43ad1c63638b9..affca938849d0d1a8dc347e3a0e1f3a380f1aab7 100644 --- a/drivers/nvmem/ocotp.c +++ b/drivers/nvmem/ocotp.c @@ -853,17 +853,38 @@ static int imx_ocotp_init_dt(struct ocotp_priv *priv) return imx8m_feat_ctrl_init(priv->dev.parent, tester3, tester4, priv->data->feat); } +#define IMX8MP_OCOTP_UID(n) \ + (OCOTP_WORD(0x420 + 0x10 * (n)) | OCOTP_BIT(0) | OCOTP_WIDTH(32)) +#define IMX8MP_OCOTP_UID_2(n) \ + (OCOTP_WORD(0xe00 + 0x10 * (n)) | OCOTP_BIT(0) | OCOTP_WIDTH(32)) + static void imx_ocotp_set_unique_machine_id(void) { - uint32_t unique_id_parts[UNIQUE_ID_NUM]; - int i; + bool is_imx8mp = of_machine_is_compatible("fsl,imx8mp"); + uint32_t uid[4]; + int len; - for (i = 0; i < UNIQUE_ID_NUM; i++) - if (imx_ocotp_read_field(OCOTP_UNIQUE_ID(i), - &unique_id_parts[i])) + if (is_imx8mp) { + if (imx_ocotp_read_field(IMX8MP_OCOTP_UID(0), &uid[0])) + return; + if (imx_ocotp_read_field(IMX8MP_OCOTP_UID(1), &uid[1])) + return; + + if (imx_ocotp_read_field(IMX8MP_OCOTP_UID_2(0), &uid[2])) + return; + if (imx_ocotp_read_field(IMX8MP_OCOTP_UID_2(1), &uid[3])) return; + len = sizeof(uid); + } else { + if (imx_ocotp_read_field(OCOTP_UNIQUE_ID(0), &uid[0])) + return; + if (imx_ocotp_read_field(OCOTP_UNIQUE_ID(1), &uid[1])) + return; + + len = sizeof(uid) / 2; + } - machine_id_set_hashable(unique_id_parts, sizeof(unique_id_parts)); + machine_id_set_hashable(uid, len); } static int imx_ocotp_probe(struct device *dev) -- 2.47.3