Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3038235ybi; Tue, 2 Jul 2019 00:55:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKcxEbZd/4wSHvRVW4LRdRj8AuwubddS7VDQSZS8Bw/ceIUAJ17GCdW62TLZ0z0qmnaSrh X-Received: by 2002:a17:902:2ae7:: with SMTP id j94mr33899114plb.270.1562054125676; Tue, 02 Jul 2019 00:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562054125; cv=none; d=google.com; s=arc-20160816; b=bevOSMhVQUgff9JOSbBR12JbSAbEWk2xWWgyo7I7uT9BK75Wkbs0vqlbUsXoLZuPOm 3770Lt84TwOd/oIMwsE9pC4zQMbAtOYlAp4EgyCxo9DImuckplmT8iRuBdv8BTGCyp0S HR+C7mO3kk/t3xtIC3bGAepND/KfnDUsU2jqxqrL8/bRPQtVSYdaMRHKr2H419mTfrPt cSycLS6nC5/JhY4pbMI4S0QqPt2JLTJGCVyOETuK7LCqI5YmWUBZItXGWBYcuznoETOw 3xy9mSz8xnuMwFpA5lhZwKaBr/9KLultEdBqcPgOY7SrF0T1J+/XwdEZGEQ7ALRx/L5g 3R5w== 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=1j2fMjbHVsrAjRSXAetvnJzVXoh8HwbG/rAA5bCV0ok=; b=wjzJvrgbSMc4XqfGIJEGSuFh4Mx3GPLaomtJQPcZATQKOkIIJTNfrDABGorO6Kno3F TkKoRUQOSgGDjPZ5KYU7XfjOUJj0H9+8ApVoS+fvfUentRYrVUHdYS9AHdL9rg+YT2G/ 0GbK+YF2VCgb9T2FZ6El+dcvWy4pFltCKTdi611CL5qmtSPMawXEOKlB4zgmKqs9bLCa nbckpCNp6gLMiTUpgDBc/buS3vmbaktrRdUemp9IANETZ6+Tr64Qsy82xFCOXI10Gsi2 T/6HZQrhduhRUo84udXlwxZPrFErZDIVHC74Cth4wuqLV94TtoLk8LrSGRH7BIOD5DiZ K9hA== 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 w14si1658696pjn.15.2019.07.02.00.55.10; Tue, 02 Jul 2019 00:55:25 -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 S1725972AbfGBHyu (ORCPT + 99 others); Tue, 2 Jul 2019 03:54:50 -0400 Received: from inva020.nxp.com ([92.121.34.13]:34662 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725851AbfGBHyu (ORCPT ); Tue, 2 Jul 2019 03:54:50 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 43E0B1A0BA2; Tue, 2 Jul 2019 09:54:48 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id F285E1A01F0; Tue, 2 Jul 2019 09:54:42 +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 42722402B6; Tue, 2 Jul 2019 15:54:36 +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, m.felsch@pengutronix.de Cc: Linux-imx@nxp.com Subject: [PATCH V3] soc: imx-scu: Add SoC UID(unique identifier) support Date: Tue, 2 Jul 2019 15:45:45 +0800 Message-Id: <20190702074545.48267-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 Reviewed-by: Daniel Baluta --- Change since V2: - The SCU FW API for getting UID does NOT have response, so we should set imx_scu_call_rpc()'s 3rd parameter as false and still can check the returned value, and comment is no needed any more. --- 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..50831eb 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; + int ret; + + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = IMX_SC_RPC_SVC_MISC; + hdr->func = IMX_SC_MISC_FUNC_UNIQUE_ID; + hdr->size = 1; + + ret = imx_scu_call_rpc(soc_ipc_handle, &msg, false); + if (ret) { + pr_err("%s: get soc uid failed, ret %d\n", __func__, ret); + return ret; + } + + 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