Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3624771ybx; Sun, 3 Nov 2019 23:40:58 -0800 (PST) X-Google-Smtp-Source: APXvYqycu5O6Q+y1k3jWc3PQ/md1j8yIu7H9/iSiOrL/oE67zMv0b3QKWSQULCq1CaJLOZk7E87t X-Received: by 2002:a17:906:4f14:: with SMTP id t20mr21766498eju.239.1572853258550; Sun, 03 Nov 2019 23:40:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572853258; cv=none; d=google.com; s=arc-20160816; b=uypcVpztBbYZKTnQLlr0TuajpCtX2kn7mkp1Iu5DKwfaN6IGNIb81nYzoRHPDbY9VL ety1P1fHFdIFa1qcy4zCiFguQnx3B4U2p9/48Lu8yRkm/fSZgRoyG6YrB4eXTWNd0rI7 zmXKsNnMemjrlGEff9sGNxl0nvxf5cF6enA4qIFlCH/LAynp+rO0q832XS6IJbuS85Mw UND/Jh4k+Ln1T5ZKJ5SzWxzlt5THEQ4Jp3dDsTtf3hSAm8CoZX6Vb/TyUt1jeMMNh+3I OjmoMwtiie8rMd6NihKKHSggSpvBcLmaXonsMEUxCHYNlyxoVPds05PuevEQz2pYc4qv EPhg== 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=CvogtJRam8yYK0Gx3UQIFQhrU2Qvx8HaYDvi+7vl2A0=; b=jPGONrDsi3lvJxkS4V12AVRn0yQ9/0msjQ4L/qxXDpM0Z3GmXj3DE4Rgvc/A8y7pz6 kErHwvsrg4XRwrd29s8I0GzrPeL02Nwca/COcVDid+qcr5++qdPxlnturJNC9beW4Bgk zIW6mtFnTpvBxLvuLebtP6ph9CJGtvjtsSGaPOL51damsOGtIHtF9sbSrnA4+C3wCO5c ny0sCJL7oFY1JDZpf7veYstj/6SR10+fzPBHD8OFGp+iVQ2XSr4KUscl4ae3D5UA53wV cQxRoqn/Uk6dgTN2BQUAoOEzNuLNSePEQtE7jXTixy9fcqEBFExtcwKCcXkPMgbwljkK Ekwg== 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 p23si6388467ejx.366.2019.11.03.23.40.35; Sun, 03 Nov 2019 23:40:58 -0800 (PST) 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 S1727880AbfKDHg7 (ORCPT + 99 others); Mon, 4 Nov 2019 02:36:59 -0500 Received: from inva020.nxp.com ([92.121.34.13]:57612 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726391AbfKDHg7 (ORCPT ); Mon, 4 Nov 2019 02:36:59 -0500 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id DB60F1A078B; Mon, 4 Nov 2019 08:36:56 +0100 (CET) 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 BE5B91A06DD; Mon, 4 Nov 2019 08:36:52 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 5CD62402AD; Mon, 4 Nov 2019 15:36:47 +0800 (SGT) From: Anson Huang To: linux@armlinux.org.uk, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, aisheng.dong@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Linux-imx@nxp.com Subject: [PATCH] ARM: imx: Add i.MX7ULP SoC serial number support Date: Mon, 4 Nov 2019 15:35:31 +0800 Message-Id: <1572852931-24101-1-git-send-email-Anson.Huang@nxp.com> X-Mailer: git-send-email 2.7.4 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 i.MX7ULP's unique ID layout in OCOTP is different from other i.MX6/7 SoCs as below: OCOTP layout unique ID 0x4b0 bit[15:0] bit[15:0] 0x4c0 bit[15:0] bit[31:16] 0x4d0 bit[15:0] bit[47:32] 0x4e0 bit[15:0] bit[63:48] Add support for reading serial number from OCOTP on i.MX7ULP. Signed-off-by: Anson Huang --- arch/arm/mach-imx/cpu.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-imx/cpu.c b/arch/arm/mach-imx/cpu.c index d811803..d70b6fc 100644 --- a/arch/arm/mach-imx/cpu.c +++ b/arch/arm/mach-imx/cpu.c @@ -15,6 +15,11 @@ #define OCOTP_UID_H 0x420 #define OCOTP_UID_L 0x410 +#define OCOTP_ULP_UID_1 0x4b0 +#define OCOTP_ULP_UID_2 0x4c0 +#define OCOTP_ULP_UID_3 0x4d0 +#define OCOTP_ULP_UID_4 0x4e0 + unsigned int __mxc_cpu_type; static unsigned int imx_soc_revision; @@ -164,6 +169,7 @@ struct device * __init imx_soc_device_init(void) soc_id = "i.MX7D"; break; case MXC_CPU_IMX7ULP: + ocotp_compat = "fsl,imx7ulp-ocotp"; soc_id = "i.MX7ULP"; break; default: @@ -176,11 +182,25 @@ struct device * __init imx_soc_device_init(void) if (IS_ERR(ocotp)) pr_err("%s: failed to find %s regmap!\n", __func__, ocotp_compat); - regmap_read(ocotp, OCOTP_UID_H, &val); - soc_uid = val; - regmap_read(ocotp, OCOTP_UID_L, &val); - soc_uid <<= 32; - soc_uid |= val; + if (__mxc_cpu_type == MXC_CPU_IMX7ULP) { + regmap_read(ocotp, OCOTP_ULP_UID_4, &val); + soc_uid = val & 0xffff; + regmap_read(ocotp, OCOTP_ULP_UID_3, &val); + soc_uid <<= 16; + soc_uid |= val & 0xffff; + regmap_read(ocotp, OCOTP_ULP_UID_2, &val); + soc_uid <<= 16; + soc_uid |= val & 0xffff; + regmap_read(ocotp, OCOTP_ULP_UID_1, &val); + soc_uid <<= 16; + soc_uid |= val & 0xffff; + } else { + regmap_read(ocotp, OCOTP_UID_H, &val); + soc_uid = val; + regmap_read(ocotp, OCOTP_UID_L, &val); + soc_uid <<= 32; + soc_uid |= val; + } } soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%d.%d", -- 2.7.4