From patchwork Thu Mar 12 09:17:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 11433705 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D1A12921 for ; Thu, 12 Mar 2020 09:25:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A817E2067C for ; Thu, 12 Mar 2020 09:25:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="l+VUqYA7"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="sHLLeNx+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A817E2067C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/VMwANQGt9rF8S97zxUvJS/sHkk1sxiJHZK6KgnBwmA=; b=l+VUqYA7tEp7y2 t/KpeWoRk6JLM7Kwn9ejTdjjK0LeTRa8tAh7ID+aDPoYZsuaB+JaIVXnxc1CoX6hR+mLhVvcIQmww 7HaUoLuG6uhH0WYv/XAHWcGDyCG9Lmcm0PdQT6kQToTKlUZ6Nsx8CHlwfvnAtFdCLXN4Ps70jkne/ khVVdeqOmb8UC4GN3LtVRFzQTROzbt0oxem73pZzKW78fnc2SjqKXaRmGYwSCW6IBCXRu7ZuX+KNs /Cj7baQDRJOd/cEqvIdDCVr8T43qLDkjz9uL6Yrq+ByrxC5koS7/yU3FbPyVLMHegTmRpzsOMwv2j BqwWUYKS9in59kheuMgw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jCK65-0006ZO-JX; Thu, 12 Mar 2020 09:25:45 +0000 Received: from mail-eopbgr130055.outbound.protection.outlook.com ([40.107.13.55] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jCK4r-0004Cs-3k for linux-arm-kernel@lists.infradead.org; Thu, 12 Mar 2020 09:24:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dnWP8mUaITGFhfNz0bqsJkhqZPMqVvTFan5sNydU5EQvKPq47k15WzWtuLBlV1y3EpoLrk5ygD7mUI55GlRqPjY1Oi1Msb+V1OYZ4lw6EpY5exwSLJBz0o9Y+UOgDoCa9WLwKcyuK5hkXcxyS2CBwbRCoQCMFK/NlkQ6jy2unUnqk5L8LjwzaRAZLhlDS0hzT/vqv7/e4MHDzk7jgNiMixvIsaAQgceyRFsurBOt6UoQMrJrwD2+KM9BSrCBLWoHBM6EBjZIy2jIvpmd3OJRIBOdqneodIMttFO9kiUfQzVNaZaUkNT9/5bhGCnOIgCCoE3vwNa0APz78Xa7NmgyqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YqvdGD/HwGf711iaWqfgq2vY+0tQlzWLLV3Ax9eNSwY=; b=fAabO8XzBw99Pyihbeux2drvVscpxn85hacm9F93z65SStpU+y6BqlrCKXqt4nvaYEmvYROIy1uodcuaI8B9rMryJcSvLLdVs+stkMdjC3qqD2E+GzAb+XU+1ik0hipWDe3uodt4zpb9QOpwhpe2pDlsIKeIVLJJsrbKS1lhs63it6eNYjZ9opR/EIJBDxneaRtRH6vIUfqBjc/qiO3SfaPCBo2xpcppkc4Hg2yFExggCfvTJ8zHw/vTjVomsh8oMz6eYGWPU2id4cjcMKzmH/u/ywDSQTLgo9Nm1LMuRNPe0SDil6nLlHWUudwUDY2/xkD7KkxDaET8/GbMLWW3oQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YqvdGD/HwGf711iaWqfgq2vY+0tQlzWLLV3Ax9eNSwY=; b=sHLLeNx+AfKInsqFcd230J11tFj25znB+eE+7/pqmJ5xNFSvUlDZxbCVRERlsjmnmdz8UoL41esxI0MUgoafJJjxeI3CmxwfGbbAJc2KKC7WSTko9uYQyWhurHvWcos9mXbMXsEa8rmGGc6SR0FiYfAiY3JJlGgVtLk6rgMqWXQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; Received: from AM0PR04MB4481.eurprd04.prod.outlook.com (52.135.147.15) by AM0PR04MB5042.eurprd04.prod.outlook.com (20.177.41.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2793.17; Thu, 12 Mar 2020 09:24:25 +0000 Received: from AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::548f:4941:d4eb:4c11]) by AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::548f:4941:d4eb:4c11%6]) with mapi id 15.20.2793.018; Thu, 12 Mar 2020 09:24:25 +0000 From: peng.fan@nxp.com To: shawnguo@kernel.org, s.hauer@pengutronix.de Subject: [PATCH V1 4/4] soc: imx: move cpu code to drivers/soc/imx Date: Thu, 12 Mar 2020 17:17:25 +0800 Message-Id: <1584004645-26720-5-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1584004645-26720-1-git-send-email-peng.fan@nxp.com> References: <1584004645-26720-1-git-send-email-peng.fan@nxp.com> X-ClientProxiedBy: SG2PR0302CA0001.apcprd03.prod.outlook.com (2603:1096:3:2::11) To AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.66) by SG2PR0302CA0001.apcprd03.prod.outlook.com (2603:1096:3:2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2835.7 via Frontend Transport; Thu, 12 Mar 2020 09:24:21 +0000 X-Mailer: git-send-email 2.7.4 X-Originating-IP: [119.31.174.66] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: eeed14d5-8454-4bd0-78c3-08d7c6672815 X-MS-TrafficTypeDiagnostic: AM0PR04MB5042:|AM0PR04MB5042: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:108; X-Forefront-PRVS: 0340850FCD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(136003)(366004)(396003)(376002)(39860400002)(346002)(199004)(316002)(52116002)(8676002)(8936002)(6506007)(36756003)(81166006)(81156014)(186003)(9686003)(6486002)(16526019)(4326008)(66556008)(66476007)(26005)(7416002)(6512007)(956004)(5660300002)(86362001)(478600001)(2616005)(2906002)(66946007)(69590400007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR04MB5042; H:AM0PR04MB4481.eurprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: g/deKmNwBhEC2w/iROf/lW+wb3CKHmGdPKoVTlIpa1Ul9se4Xz/7fEhcIuO2qI3JlhxHjUFY+EvO0Wm8OXptuXVBn2QHTySJTnsieoxOrABE6gapf7nQDnud9NV1Cqsu4y5LkXMirFGlRtnL6y26SYkHmhsHON8Y6rQZ8mBNCPr5OTflyDfmEovlqI1NLcW9aYFYhf/PFp4BEgFb+0diq9ERnudIJaRX5s3d2Ed+PCmWM3iUBhJbCX4lVKm4nyRua8XWRubpRPzJEibj1il7XDDEGP6PJe6LcN4cr5DpPDgGKfE5wRS4BD0ZZRw8hV73/FByISP26i+woGkY8yHx8j+JvPBxzESpThr06/xbxte147OBKsf73GqfwFnyn1vAjE3f+M46r9r1okjXcNQBXWwMei0VADEsKK226ekqzfU1a8LeCi/GHIzcfhIZ4wOs4ZF6MCEUteUCO8VzNCsNhmKiypuMY3nw345utYxrlEyfymV5pLIyyc5Q0636rdKx X-MS-Exchange-AntiSpam-MessageData: tw05M+UVVRJGgG8Qb6hZvOH6Jtv14hZ/mF9CmPuPte8Jxrfqmnb4hljB7Ze96hy2Qs9ruASJNilVI8LxUwhGjHUca+S5NekhSfn5pNeXCLFxgs5EkirnnPYEKu0d4mXK6d+nYKtN2TeOV7BoHciS/g== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: eeed14d5-8454-4bd0-78c3-08d7c6672815 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2020 09:24:25.5979 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 51jsrLCFv+ikQ+jkMeg8PQVs9nzNljd2eMsKr/3TyajwS0CPQ/ROEezEByRLlovCYOMEbn8sbpK+qPWcSY2bKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB5042 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200312_022429_207518_793E7341 X-CRM114-Status: GOOD ( 16.58 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [40.107.13.55 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 MSGID_FROM_MTA_HEADER Message-Id was added by a relay X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Peng Fan , abel.vesa@nxp.com, Anson.Huang@nxp.com, ard.biesheuvel@linaro.org, festevam@gmail.com, linux-kernel@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, git@andred.net, leonard.crestez@nxp.com, info@metux.net, allison@lohutok.net Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Peng Fan Move the soc device register code to drivers/soc/imx to align with i.MX8. Signed-off-by: Peng Fan --- arch/arm/mach-imx/cpu.c | 136 ------------------------------------------ drivers/soc/imx/Makefile | 3 + drivers/soc/imx/soc-imx.c | 146 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 136 deletions(-) create mode 100644 drivers/soc/imx/soc-imx.c diff --git a/arch/arm/mach-imx/cpu.c b/arch/arm/mach-imx/cpu.c index 0302cb66134b..65c7224f5250 100644 --- a/arch/arm/mach-imx/cpu.c +++ b/arch/arm/mach-imx/cpu.c @@ -1,25 +1,13 @@ // SPDX-License-Identifier: GPL-2.0 #include -#include #include #include #include #include -#include -#include -#include #include "hardware.h" #include "common.h" -#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; @@ -82,127 +70,3 @@ void __init imx_aips_allow_unprivileged_access( imx_set_aips(aips_base_addr); } } - -static int __init imx_soc_device_init(void) -{ - struct soc_device_attribute *soc_dev_attr; - const char *ocotp_compat = NULL; - struct soc_device *soc_dev; - struct device_node *root; - struct regmap *ocotp = NULL; - const char *soc_id; - u64 soc_uid = 0; - u32 val; - int ret; - - soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); - if (!soc_dev_attr) - return PTR_ERR(soc_dev_attr); - - soc_dev_attr->family = "Freescale i.MX"; - - root = of_find_node_by_path("/"); - ret = of_property_read_string(root, "model", &soc_dev_attr->machine); - of_node_put(root); - if (ret) - goto free_soc; - - switch (__mxc_cpu_type) { - case MXC_CPU_IMX6SL: - ocotp_compat = "fsl,imx6sl-ocotp"; - soc_id = "i.MX6SL"; - break; - case MXC_CPU_IMX6DL: - ocotp_compat = "fsl,imx6q-ocotp"; - soc_id = "i.MX6DL"; - break; - case MXC_CPU_IMX6SX: - ocotp_compat = "fsl,imx6sx-ocotp"; - soc_id = "i.MX6SX"; - break; - case MXC_CPU_IMX6Q: - ocotp_compat = "fsl,imx6q-ocotp"; - soc_id = "i.MX6Q"; - break; - case MXC_CPU_IMX6UL: - ocotp_compat = "fsl,imx6ul-ocotp"; - soc_id = "i.MX6UL"; - break; - case MXC_CPU_IMX6ULL: - ocotp_compat = "fsl,imx6ull-ocotp"; - soc_id = "i.MX6ULL"; - break; - case MXC_CPU_IMX6ULZ: - ocotp_compat = "fsl,imx6ull-ocotp"; - soc_id = "i.MX6ULZ"; - break; - case MXC_CPU_IMX6SLL: - ocotp_compat = "fsl,imx6sll-ocotp"; - soc_id = "i.MX6SLL"; - break; - case MXC_CPU_IMX7D: - ocotp_compat = "fsl,imx7d-ocotp"; - soc_id = "i.MX7D"; - break; - case MXC_CPU_IMX7ULP: - ocotp_compat = "fsl,imx7ulp-ocotp"; - soc_id = "i.MX7ULP"; - break; - default: - soc_id = "Unknown"; - } - soc_dev_attr->soc_id = soc_id; - - if (ocotp_compat) { - ocotp = syscon_regmap_lookup_by_compatible(ocotp_compat); - if (IS_ERR(ocotp)) - pr_err("%s: failed to find %s regmap!\n", __func__, ocotp_compat); - } - - if (!IS_ERR_OR_NULL(ocotp)) { - 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", - (imx_soc_revision >> 4) & 0xf, - imx_soc_revision & 0xf); - if (!soc_dev_attr->revision) - goto free_soc; - - soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid); - if (!soc_dev_attr->serial_number) - goto free_rev; - - soc_dev = soc_device_register(soc_dev_attr); - if (IS_ERR(soc_dev)) - goto free_serial_number; - - return 0; - -free_serial_number: - kfree(soc_dev_attr->serial_number); -free_rev: - kfree(soc_dev_attr->revision); -free_soc: - kfree(soc_dev_attr); - return -ENOMEM; -} -device_initcall(imx_soc_device_init); diff --git a/drivers/soc/imx/Makefile b/drivers/soc/imx/Makefile index 103e2c93c342..45dd49df3044 100644 --- a/drivers/soc/imx/Makefile +++ b/drivers/soc/imx/Makefile @@ -1,5 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o +obj-$(CONFIG_SOC_IMX6)+= soc-imx.o +obj-$(CONFIG_SOC_IMX7D)+= soc-imx.o +obj-$(CONFIG_SOC_IMX7ULP)+= soc-imx.o obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o obj-$(CONFIG_IMX_SCU_SOC) += soc-imx-scu.o diff --git a/drivers/soc/imx/soc-imx.c b/drivers/soc/imx/soc-imx.c new file mode 100644 index 000000000000..e01c7ccf1f4b --- /dev/null +++ b/drivers/soc/imx/soc-imx.c @@ -0,0 +1,146 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2020 NXP. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#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 + +static int __init imx_soc_device_init(void) +{ + struct soc_device_attribute *soc_dev_attr; + const char *ocotp_compat = NULL; + struct soc_device *soc_dev; + struct device_node *root; + struct regmap *ocotp = NULL; + const char *soc_id; + u64 soc_uid = 0; + u32 val; + int ret; + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return PTR_ERR(soc_dev_attr); + + soc_dev_attr->family = "Freescale i.MX"; + + root = of_find_node_by_path("/"); + ret = of_property_read_string(root, "model", &soc_dev_attr->machine); + of_node_put(root); + if (ret) + goto free_soc; + + switch (__mxc_cpu_type) { + case MXC_CPU_IMX6SL: + ocotp_compat = "fsl,imx6sl-ocotp"; + soc_id = "i.MX6SL"; + break; + case MXC_CPU_IMX6DL: + ocotp_compat = "fsl,imx6q-ocotp"; + soc_id = "i.MX6DL"; + break; + case MXC_CPU_IMX6SX: + ocotp_compat = "fsl,imx6sx-ocotp"; + soc_id = "i.MX6SX"; + break; + case MXC_CPU_IMX6Q: + ocotp_compat = "fsl,imx6q-ocotp"; + soc_id = "i.MX6Q"; + break; + case MXC_CPU_IMX6UL: + ocotp_compat = "fsl,imx6ul-ocotp"; + soc_id = "i.MX6UL"; + break; + case MXC_CPU_IMX6ULL: + ocotp_compat = "fsl,imx6ull-ocotp"; + soc_id = "i.MX6ULL"; + break; + case MXC_CPU_IMX6ULZ: + ocotp_compat = "fsl,imx6ull-ocotp"; + soc_id = "i.MX6ULZ"; + break; + case MXC_CPU_IMX6SLL: + ocotp_compat = "fsl,imx6sll-ocotp"; + soc_id = "i.MX6SLL"; + break; + case MXC_CPU_IMX7D: + ocotp_compat = "fsl,imx7d-ocotp"; + soc_id = "i.MX7D"; + break; + case MXC_CPU_IMX7ULP: + ocotp_compat = "fsl,imx7ulp-ocotp"; + soc_id = "i.MX7ULP"; + break; + default: + soc_id = "Unknown"; + } + soc_dev_attr->soc_id = soc_id; + + if (ocotp_compat) { + ocotp = syscon_regmap_lookup_by_compatible(ocotp_compat); + if (IS_ERR(ocotp)) + pr_err("%s: failed to find %s regmap!\n", __func__, ocotp_compat); + } + + if (!IS_ERR_OR_NULL(ocotp)) { + 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", + (imx_get_soc_revision() >> 4) & 0xf, + imx_get_soc_revision() & 0xf); + if (!soc_dev_attr->revision) + goto free_soc; + + soc_dev_attr->serial_number = kasprintf(GFP_KERNEL, "%016llX", soc_uid); + if (!soc_dev_attr->serial_number) + goto free_rev; + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) + goto free_serial_number; + + return 0; + +free_serial_number: + kfree(soc_dev_attr->serial_number); +free_rev: + kfree(soc_dev_attr->revision); +free_soc: + kfree(soc_dev_attr); + return -ENOMEM; +} +device_initcall(imx_soc_device_init);