Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2813189ybd; Thu, 27 Jun 2019 20:35:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqztXF5oHy7YM9mBPniEmx7zEKzn2FZcsyqcsZ8xbdtr29apqEfL22/Buzu1+B1OwCN+aboM X-Received: by 2002:a17:90a:a385:: with SMTP id x5mr10229348pjp.76.1561692949799; Thu, 27 Jun 2019 20:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561692949; cv=none; d=google.com; s=arc-20160816; b=0skBN7SVcDLdJObAdFI5BKU97rVG52W0QeNfWpnC6TGNxQh5sLRcTWBRbBIozt1Jiq NFl01A5nBRTq6/mn2r8ZDL9FT5DFYJjgoX4mNAJVBLFLjYZY8FuhVwYbEanDYRDWSfBM rdrV1knmSEUzVzm/lCqnBvn+ShT+rmpDpOTvXZ67JFAEEj4kR03hDizj0lqagun4muVG QOPXtz5XTUxTgin//8hdhilaxozo165r37EWzl+CFoOAGXVOVkJgD7QMhI6A6NZPlnue W0cqc3LAtqgDgwUcryD6U5UT1wTqX8wFLaZTlU8rvx+zZ3z8iAkJqVS92O3qnNFsqj9w wMcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=rVwtNSxdpyYp5y+L+r37wGq5B2fO00KJPh82uM7xRf4=; b=PJhQmmdTf5SmfS0RQ1iAMd9Pu4vRSGCG1V+e01wgzoEckvN+K0YJJmslrQRwNdOk37 nRoJP2miz6UE/6rfgIaiSUx8m7hOA9N47jNTAcIlagcrBhAvocE56zUx7L3jVTEkneJm y7aaLDSV2RA/6W1gsUi9C0pK/aGZeiL2BATP8duxDeugbg96NPy6g2JMHGoXZk6NaOGJ wJrrD51WWsyEdn7niVHKfgOZpHkEQvFlLpH0WX1g/+wCIVZxhEMd3vGm1Vm1J/GmoW1V zdY10kkenB8KG1BCgSjOKB51may/Vlqn3qHbDDzHldam9vudsTDPqe06FQcd/diHNlOy VCyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t19si1105391pfe.94.2019.06.27.20.35.33; Thu, 27 Jun 2019 20:35:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727190AbfF1Der (ORCPT + 99 others); Thu, 27 Jun 2019 23:34:47 -0400 Received: from inva021.nxp.com ([92.121.34.21]:55882 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726686AbfF1Der (ORCPT ); Thu, 27 Jun 2019 23:34:47 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 2A463200304; Fri, 28 Jun 2019 05:34:45 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 567642002F0; Fri, 28 Jun 2019 05:34:40 +0200 (CEST) Received: from titan.ap.freescale.net (TITAN.ap.freescale.net [10.192.208.233]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 308CE402B3; Fri, 28 Jun 2019 11:34:34 +0800 (SGT) From: Anson.Huang@nxp.com To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, aisheng.dong@nxp.com, abel.vesa@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Linux-imx@nxp.com Subject: [PATCH V2] soc: imx-scu: Add SoC UID(unique identifier) support Date: Fri, 28 Jun 2019 11:25:44 +0800 Message-Id: <20190628032544.8317-1-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.14.1 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Anson Huang Add i.MX SCU SoC's UID(unique identifier) support, user can read it from sysfs: root@imx8qxpmek:~# cat /sys/devices/soc0/soc_uid 7B64280B57AC1898 Signed-off-by: Anson Huang --- Changes since V1: - Improve the comment of skipping SCFW API return value check for getting UID. --- drivers/soc/imx/soc-imx-scu.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/soc/imx/soc-imx-scu.c b/drivers/soc/imx/soc-imx-scu.c index 676f612..3eacb54 100644 --- a/drivers/soc/imx/soc-imx-scu.c +++ b/drivers/soc/imx/soc-imx-scu.c @@ -27,6 +27,40 @@ struct imx_sc_msg_misc_get_soc_id { } data; } __packed; +struct imx_sc_msg_misc_get_soc_uid { + struct imx_sc_rpc_msg hdr; + u32 uid_low; + u32 uid_high; +} __packed; + +static ssize_t soc_uid_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct imx_sc_msg_misc_get_soc_uid msg; + struct imx_sc_rpc_msg *hdr = &msg.hdr; + u64 soc_uid; + + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = IMX_SC_RPC_SVC_MISC; + hdr->func = IMX_SC_MISC_FUNC_UNIQUE_ID; + hdr->size = 1; + + /* + * SCU FW API always returns an error even the + * function is successfully executed, so skip + * returned value check. + */ + imx_scu_call_rpc(soc_ipc_handle, &msg, true); + + soc_uid = msg.uid_high; + soc_uid <<= 32; + soc_uid |= msg.uid_low; + + return sprintf(buf, "%016llX\n", soc_uid); +} + +static DEVICE_ATTR_RO(soc_uid); + static int imx_scu_soc_id(void) { struct imx_sc_msg_misc_get_soc_id msg; @@ -102,6 +136,11 @@ static int imx_scu_soc_probe(struct platform_device *pdev) goto free_revision; } + ret = device_create_file(soc_device_to_device(soc_dev), + &dev_attr_soc_uid); + if (ret) + goto free_revision; + return 0; free_revision: -- 2.7.4