Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp312491ybh; Thu, 12 Mar 2020 02:26:40 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtIwLnOPQHBDsFgmD6qPZqZDeqZrONHlGzkXsGlunmOlosEkoTgzhWqlFU2ykdy8fqiBYU4 X-Received: by 2002:a54:4114:: with SMTP id l20mr1925483oic.127.1584005200533; Thu, 12 Mar 2020 02:26:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1584005200; cv=pass; d=google.com; s=arc-20160816; b=YTvMg3wS1hudRPGTxc1SJmKFmJcwyNxosfNFPLAP9uU3pbiETPQtKUbp8IUKoZ+NqD 9yO5SgSGi/7C8W5qj/9LQhCeUeSTrgmvEKLwwWplGZ89w3ipIALADoG0LTMdTKhqWxCR N5CHSYvgBRDQrAhXPTMxgJ0xSgNjcNNxNwH2zKFY75I//+o9B5b33r804dZB9aBx0Po4 LQiIlYQx7AowTmSdj3g/iCkNshF2oVcK/DeXWkiNa2wUkfAFMUl+iXntUizauwUV+1LB 2rO1bU+3XRaOT+BgRIfxE9E1VfYp4/1ETQTuhgoDg6b8S0y+24clU6ldnLAWLR6q9HFu cyHA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=YqvdGD/HwGf711iaWqfgq2vY+0tQlzWLLV3Ax9eNSwY=; b=njioArjUVdwgwYd+RVehry9aRXXFwr+YPxPJtPftuorDrqw7D2WABg/1/Q+uT8ohdE Ow9rjK21cghr3EvXRuGBMbUXnRwFg7/S4RGHBHTSSHdez4Tx4tRzKrXqYw/pfrhNHxlv WGOexg2ruGE+1czrHqaC3rgJ+qgZ8oZAzddPWfk2TFqMsvpOiXgshiJyINxRydA313BM wz+CwDfONgffymct9TZql3Au7B96p5kgygQDyerBqWGFqsZGa1poQvrkylzibXHNCMqg sRG9UBEc97qXDhHaz4G3ctilFHpd7G3ypc6XV83nhCFI1ivt4HTI9h3C+a6vkva9yoYY qc9g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=sHLLeNx+; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (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 s199si2390408oih.169.2020.03.12.02.26.28; Thu, 12 Mar 2020 02:26: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; dkim=pass header.i=@nxp.com header.s=selector2 header.b=sHLLeNx+; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726736AbgCLJYe (ORCPT + 99 others); Thu, 12 Mar 2020 05:24:34 -0400 Received: from mail-eopbgr60083.outbound.protection.outlook.com ([40.107.6.83]:62096 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726632AbgCLJYd (ORCPT ); Thu, 12 Mar 2020 05:24:33 -0400 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 Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, allison@lohutok.net, info@metux.net, Anson.Huang@nxp.com, leonard.crestez@nxp.com, git@andred.net, abel.vesa@nxp.com, ard.biesheuvel@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan 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> Content-Type: text/plain 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); -- 2.16.4