Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp450291ybd; Wed, 26 Jun 2019 00:44:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyEDqv6hYufQDfEl1aE9DH/z8F+4yyvjtZb9NczMFRSA/5iOQt48QHdioEJETtKFc1TolSf X-Received: by 2002:a17:90a:cb87:: with SMTP id a7mr3152933pju.130.1561535047316; Wed, 26 Jun 2019 00:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561535047; cv=none; d=google.com; s=arc-20160816; b=qH+rhgVAH6Gx8/aorwq8ZQ9byX3sg7S6voIIofK2F+ERPFhp2K6Q1y/HdVm/YUnv4J WtP9RvwWYEypdMKKA6+xYkcF8K8Jx94XlXnugQBVw/mVEcDI9/ToXXfM67E6FKgri8D6 0KYf6jtq7DDGGMJ4e9VEGab5EjWW0Q0OCMBH+yFh65YDk51weHLb3rDHW4eX+bmxlnZV Sv4LPRZexuEY/sYhmLCqLZ8r5T8T1CTI2ICulY+oAFOv1inPbZzmgy//5S1sUvRixvd3 LZVKLGHI0lRzMhoChV5GMsJXL8BwttT1yAcMK6jvPZj1LasMSLWyBzJqcQSUyJGam9XY KOdw== 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=2JLusGkiDuPX/H/46bKC3omOgGsksRbSHDN0zceI8ao=; b=EUEC44pxnvbnT/UvH+VBaYyTHPLVXG8dHazHCQfqeIoKrr3p7Urblqg6RUHQslz4lA AMuMM7UVqx7uOE+5AHWzKIE0hYeaaJhX8ZFyruL9ZHllkQSrnIIHCElJZGN/aM/kMX7q uoQO9ZpGckHgiRXIakKjEbiMP7n+0qXX50aCoF4rRmh5noywldJayU1zsZrksI1A7Qde 2/BksiieESD0mzp5F8UbwFZkNFDf0/hOdlyabk9C/g0UXqEa+XWIhV0oRkZ06kcKFwdy aUmChauwbHMIzsNGAozv6aiadnGgHHy2kWuX8+wRHM6yTb6Rf+FIhvUc6qQrpCGbE1C4 Icfg== 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 t64si14636285pgd.126.2019.06.26.00.43.51; Wed, 26 Jun 2019 00:44:07 -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 S1726894AbfFZHmX (ORCPT + 99 others); Wed, 26 Jun 2019 03:42:23 -0400 Received: from inva021.nxp.com ([92.121.34.21]:37704 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725954AbfFZHmX (ORCPT ); Wed, 26 Jun 2019 03:42:23 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 98662200912; Wed, 26 Jun 2019 09:42:21 +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 514E6200905; Wed, 26 Jun 2019 09:42:16 +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 16DEA4030F; Wed, 26 Jun 2019 15:42:10 +0800 (SGT) From: Anson.Huang@nxp.com To: shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, leonard.crestez@nxp.com, abel.vesa@nxp.com, viresh.kumar@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Linux-imx@nxp.com Subject: [PATCH 1/2] soc: imx8: Add i.MX8MQ UID(unique identifier) support Date: Wed, 26 Jun 2019 15:44:14 +0800 Message-Id: <20190626074415.18224-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.MX8MQ SoC UID(unique identifier) support, user can read it from sysfs: root@imx8mqevk:~# cat /sys/devices/soc0/soc_uid D56911D6F060954B Signed-off-by: Anson Huang --- drivers/soc/imx/soc-imx8.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/soc/imx/soc-imx8.c b/drivers/soc/imx/soc-imx8.c index f924ae8..c19ef4b 100644 --- a/drivers/soc/imx/soc-imx8.c +++ b/drivers/soc/imx/soc-imx8.c @@ -16,6 +16,9 @@ #define IMX8MQ_SW_INFO_B1 0x40 #define IMX8MQ_SW_MAGIC_B1 0xff0055aa +#define OCOTP_UID_LOW 0x410 +#define OCOTP_UID_HIGH 0x420 + /* Same as ANADIG_DIGPROG_IMX7D */ #define ANADIG_DIGPROG_IMX8MM 0x800 @@ -24,6 +27,16 @@ struct imx8_soc_data { u32 (*soc_revision)(void); }; +static u64 soc_uid; + +static ssize_t soc_uid_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%016llX\n", soc_uid); +} + +static DEVICE_ATTR_RO(soc_uid); + static u32 __init imx8mq_soc_revision(void) { struct device_node *np; @@ -42,6 +55,10 @@ static u32 __init imx8mq_soc_revision(void) if (magic == IMX8MQ_SW_MAGIC_B1) rev = REV_B1; + soc_uid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH); + soc_uid <<= 32; + soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW); + iounmap(ocotp_base); out: @@ -140,6 +157,11 @@ static int __init imx8_soc_init(void) goto free_rev; } + ret = device_create_file(soc_device_to_device(soc_dev), + &dev_attr_soc_uid); + if (ret) + goto free_rev; + if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT)) platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0); -- 2.7.4