Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2299009rdb; Mon, 9 Oct 2023 22:21:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMGWj9YOJpCnce/0dSlH2DSsgA/JF2VWQH5rX5r3e0vRg2ckJ0lpySJK5wFCnoEjxfI5PK X-Received: by 2002:a05:6a00:391b:b0:690:3793:17e5 with SMTP id fh27-20020a056a00391b00b00690379317e5mr21408501pfb.4.1696915269793; Mon, 09 Oct 2023 22:21:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696915269; cv=none; d=google.com; s=arc-20160816; b=OIXUa7lVQrJXSVfnjf4GiXiWDRJqEN6ODLBsXfJYiWCNiLOz+CZ/v9zMx+90L68FV1 EeEkhiv1HrvBgk94Skpdyyao6uifSc095G9YKm6ckA5rC0TU7Ao5KHi5mPUlyjCXuMH6 QJ558v4/UDzJNdCt8SLgMRpam2UzkAC0mbHm77LVnIV58YQMnxviKCIePUpdDiKllaEZ 9lkdI3CBgffItN/9poHENgFtwWbRzEIgL8PIL8e4eopNAEAAk9M7aNfj9/WEtOC1VTnF cCjQYXo6B00HdaGfVe6OUqhbF+wC/jjUzjXlanoy8hBfgTEHfY4q2eslWfw534POF0Pv nLrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=Hm2wM3RoEUuMi0bu6YguvSfj0Jb5XVXJEZA0ctE0qbY=; fh=bTlJ5i7TxeydIb6kU9LxnR+ACgJU7RvHvJCv61iU3U0=; b=vhN2id0SNGJYrjYhdIPLasWly5gcz7BK+GfJW7KhdoC9h7jEVUR7Vn91awwn1GE7YV y7bgYzpqctaxaNcEGZOTzdMk8YKSakoYM53W9JPF87XbA+9JzkFujK8XCPaz5ZwZobf1 cdT9Jo17wQrMNOiLeuOlxz/UNcOi4d3MwVpdkXqRqHu431v+w7zMOK8GBxJcRp+xxkcf 0SMW0aElHcmYmv7y1ra41tmVO38BqYZjYdtaI/LFLlswMCuQ15sqQFqKVfVhn3+8ey5t a2mtrg6Aoxr374EUOQwai3k0rUW8SCKVeL782wIgZxacqu/IRtwS4bH3BB223DOF4MW/ LxrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id y22-20020a056a00191600b00690c0051dcdsi9231143pfi.143.2023.10.09.22.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 22:21:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 2521D82072E7; Mon, 9 Oct 2023 22:21:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376502AbjJJFU4 (ORCPT + 99 others); Tue, 10 Oct 2023 01:20:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344471AbjJJFUy (ORCPT ); Tue, 10 Oct 2023 01:20:54 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E937AC for ; Mon, 9 Oct 2023 22:20:53 -0700 (PDT) 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 1qq5Ao-0001Xy-WC; Tue, 10 Oct 2023 07:20:51 +0200 Received: from [2a0a:edc0:2:b01:1d::c0] (helo=ptx.whiteo.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qq5An-000aIe-RI; Tue, 10 Oct 2023 07:20:49 +0200 Received: from mfe by ptx.whiteo.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1qq5An-00DfhY-Of; Tue, 10 Oct 2023 07:20:49 +0200 Date: Tue, 10 Oct 2023 07:20:49 +0200 From: Marco Felsch To: "Peng Fan (OSS)" Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, Peng Fan , linux-kernel@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, festevam@gmail.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] soc: imx8mp: support 128 bits UID Message-ID: <20231010052049.iwqn5cnk523jixq2@pengutronix.de> References: <20231008083808.1517132-1-peng.fan@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231008083808.1517132-1-peng.fan@oss.nxp.com> User-Agent: NeoMutt/20180716 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 22:21:07 -0700 (PDT) X-Spam-Level: ** Hi Peng, On 23-10-08, Peng Fan (OSS) wrote: > From: Peng Fan > > Current driver only supports 64bits UID for i.MX8MP, but > i.MX8MP UID is actually 128bits, the high 64bits is at 0xE00. > So update driver to support it. > > Signed-off-by: Peng Fan > --- > drivers/soc/imx/soc-imx8m.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c > index ec87d9d878f3..5dcc227d41c0 100644 > --- a/drivers/soc/imx/soc-imx8m.c > +++ b/drivers/soc/imx/soc-imx8m.c > @@ -24,6 +24,7 @@ > #define OCOTP_UID_HIGH 0x420 > > #define IMX8MP_OCOTP_UID_OFFSET 0x10 > +#define IMX8MP_OCOTP_UID_HIGH 0xE00 ^ 0xe00 > /* Same as ANADIG_DIGPROG_IMX7D */ > #define ANADIG_DIGPROG_IMX8MM 0x800 > @@ -34,6 +35,7 @@ struct imx8_soc_data { > }; > > static u64 soc_uid; > +static u64 soc_uid_h; > > #ifdef CONFIG_HAVE_ARM_SMCCC > static u32 imx8mq_soc_revision_from_atf(void) > @@ -122,8 +124,15 @@ static void __init imx8mm_soc_uid(void) > soc_uid <<= 32; > soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + offset); > > + if (offset) { > + soc_uid_h = readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_HIGH + 0x10); > + soc_uid_h <<= 32; > + soc_uid_h |= readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_HIGH); > + } Since the function is very small and with this addition the shared code is very limited. So I would rather tend to have a separate imx8mp_soc_uid() function. > + > clk_disable_unprepare(clk); > clk_put(clk); > + > iounmap(ocotp_base); > of_node_put(np); > } > @@ -222,7 +231,12 @@ static int __init imx8_soc_init(void) > goto free_soc; > } > > - soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid); > + if (soc_uid_h) { We already do have match data can't we do something like this: if (id->uid_128bit) soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX%016llX", soc_uid_h, soc_uid); else soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid); Regards, Marco > + soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX%016llX", > + soc_uid_h, soc_uid); > + } else { > + soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid); > + } > if (!soc_dev_attr->serial_number) { > ret = -ENOMEM; > goto free_rev; > -- > 2.37.1 > > >