Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp416400ybd; Wed, 26 Jun 2019 00:05:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfBL2ts7YPGwmxRP0HB4P3EZR2Uog9pAsM+qdt9v4Sq4CyKYMXZzMrhte+P9Thjew1TQ11 X-Received: by 2002:a17:902:aa0a:: with SMTP id be10mr3442492plb.293.1561532740463; Wed, 26 Jun 2019 00:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561532740; cv=none; d=google.com; s=arc-20160816; b=WyyPr4uFwszdXnw82I8B7j1Fob+zdsNF+wMTlUwwBN58u5bKjrpTgMTZ28nIAsD8Cc 0UXKcOe3c2bDirvpavDIpT9ZsjzOBk9v5ihrwPVNmBerYDNgdvIPOQFHCA1VFizYlERl Wdqz+1Dnn3kW+9YXt0p1YjDBfnplNjFFn38zUUAIQyc0xsIpPMU2vj10SvgXQ3tCqHrw c+hihOGl8oS69OPMmBUYw9LCvnAcamlgtnhMsYAvNYIYSHPqZehIH5UDX9rO9LbFH2Z7 KHnoFYDNSlsC+7x8/KgHUy/ijp3JdQU16cETt00Q+F/XkoDWqN1zXdNLFeFUjU/yoIgZ eZEw== 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=aolDQKzVLMmn3/AxEglteslafHQO20ACS2iYwHsVfGE=; b=CVOb3ohppz8gIoT8iUEJdx8Om5TcrsURUJrfj4pYGHyS9x8wfv91k1MSAd5auVwjzq JXTUR/EUI7MsJNUyxbUtMpG/tkcYFnOVdgq02p7GPrW9ZBPiDW8dXo4TDULfFK9uWRKP GFifCFSj9gkQGhvOOXkz3uGFRXW1XOEukYjgeLOql1+qK8hVLiU5rt8OWzLXByzz8ue7 zyrkgFdlpZXYcVVbQTbOr4tbZHoN5Z2Rc+m+mkRBPEqdvDqYiQn9WooJkp9H9UeewZUy 22nSDhtpnd5+aq/MOoLVyMRLEAtnpkYAxwTdN/GEZgpmgHUe3XvB4vVwmfNSmLkR0Bnu CZSw== 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 n11si14373342pgq.498.2019.06.26.00.05.21; Wed, 26 Jun 2019 00:05:40 -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 S1726599AbfFZHFP (ORCPT + 99 others); Wed, 26 Jun 2019 03:05:15 -0400 Received: from inva021.nxp.com ([92.121.34.21]:47262 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725790AbfFZHFP (ORCPT ); Wed, 26 Jun 2019 03:05:15 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 43245200256; Wed, 26 Jun 2019 09:05:13 +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 6C4E52008FD; Wed, 26 Jun 2019 09:05:08 +0200 (CEST) Received: from mega.ap.freescale.net (mega.ap.freescale.net [10.192.208.232]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 405874030F; Wed, 26 Jun 2019 15:05:02 +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] soc: imx-scu: Add SoC UID(unique identifier) support Date: Wed, 26 Jun 2019 15:07:06 +0800 Message-Id: <20190626070706.24930-1-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.17.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 --- drivers/soc/imx/soc-imx-scu.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/soc/imx/soc-imx-scu.c b/drivers/soc/imx/soc-imx-scu.c index 676f612..8d322a1 100644 --- a/drivers/soc/imx/soc-imx-scu.c +++ b/drivers/soc/imx/soc-imx-scu.c @@ -27,6 +27,36 @@ 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; + + /* the return value of SCU FW is in correct, skip return 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 +132,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