From patchwork Wed May 20 05:36:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanchayan X-Patchwork-Id: 6442331 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F1C9EC0432 for ; Wed, 20 May 2015 05:42:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F285720397 for ; Wed, 20 May 2015 05:42:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 17C3D2034B for ; Wed, 20 May 2015 05:42:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yuwjt-0005Iy-Vl; Wed, 20 May 2015 05:40:21 +0000 Received: from mail-pd0-x229.google.com ([2607:f8b0:400e:c02::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YuwjU-0003yL-8Q for linux-arm-kernel@lists.infradead.org; Wed, 20 May 2015 05:39:57 +0000 Received: by pdea3 with SMTP id a3so55421477pde.2 for ; Tue, 19 May 2015 22:39:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Pr4qaM+u4F/Ved3xdFSGjV6dzyBjoJ0Ya745APiJa3o=; b=DXiW+CeT+K+egQXwhD3HZ5VtvPeIPJup8wpLOnVfV8TzuMy9XwHSVOvCQuf1vCpOzo TYZAsFz3xFW2xsfJagk8bcCSw8tSlSEb6bzMQMQAe2hKL02a9LSBAgq55LwlHjUF/7xk z4NKS7ydas1TDu5gMJYjllM0Nw8ssW3ZRk3+tVVCgigvJ4MgA5fXPnJIuHgUdnRPLk2J 4Z3ZyDaEcdGYXB1HZuJxwvHRB1hzqVzEJvOCiN627w71O6hv1gNp6YKHg+Dnce2sdyAD lntquUpATJlPlCk5MKXKcFaasHg8vC42W5Ymp590XlCTt/gQ724tm039cSfPbX2PMLdy JD0A== X-Received: by 10.70.61.68 with SMTP id n4mr61433858pdr.78.1432100375223; Tue, 19 May 2015 22:39:35 -0700 (PDT) Received: from localhost ([122.166.214.162]) by mx.google.com with ESMTPSA id e5sm14763993pdc.94.2015.05.19.22.39.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 May 2015 22:39:34 -0700 (PDT) From: Sanchayan Maity To: shawn.guo@linaro.org Subject: [PATCH v2 2/2] ARM: vf610: Add SoC bus support for Vybrid Date: Wed, 20 May 2015 11:06:52 +0530 Message-Id: <27733a88b73adb7000205e020bafdb6f7ebe1843.1432099651.git.maitysanchayan@gmail.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150519_223956_397974_29AF54DE X-CRM114-Status: GOOD ( 11.85 ) X-Spam-Score: -0.1 (/) Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, stefan@agner.ch, Sanchayan Maity , kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implements SoC bus support to export SoC specific information. Read the unique SoC ID from the Vybrid On Chip One Time Programmable (OCOTP) controller, SoC specific information from the Miscellaneous System Control Module (MSCM), revision from the ROM revision register and expose it via the SoC bus infrastructure. Sample Output: root@vf:/sys/devices/soc0# cat soc_id df63c12a2e2161d4 root@vf:/sys/devices/soc0# cat family Freescale Vybrid VF500 root@vf:/sys/devices/soc0# cat revision 00000013 root@vf:/sys/devices/soc0# cat machine Freescale Vybrid Signed-off-by: Sanchayan Maity --- arch/arm/mach-imx/mach-vf610.c | 85 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/mach-vf610.c b/arch/arm/mach-imx/mach-vf610.c index 2e7c75b..b4854f1 100644 --- a/arch/arm/mach-imx/mach-vf610.c +++ b/arch/arm/mach-imx/mach-vf610.c @@ -7,10 +7,90 @@ * (at your option) any later version. */ -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include + +#define OCOTP_CFG0_OFFSET 0x00000410 +#define OCOTP_CFG1_OFFSET 0x00000420 +#define MSCM_CPxCOUNT_OFFSET 0x0000002C +#define MSCM_CPxCFG1_OFFSET 0x00000014 +#define ROM_REVISION_OFFSET 0x00000080 + +static void __init vf610_init_machine(void) +{ + struct regmap *ocotp_regmap, *mscm_regmap, *rom_regmap; + struct soc_device_attribute *soc_dev_attr; + struct device *parent = NULL; + struct soc_device *soc_dev; + char soc_type[] = "xx0"; + u32 cpxcount, cpxcfg1; + u32 soc_id1, soc_id2, rom_rev; + u64 soc_id; + + ocotp_regmap = syscon_regmap_lookup_by_compatible("fsl,vf610-ocotp"); + if (IS_ERR(ocotp_regmap)) { + pr_err("regmap lookup for octop failed\n"); + goto out; + } + + mscm_regmap = syscon_regmap_lookup_by_compatible("fsl,vf610-mscm-cpucfg"); + if (IS_ERR(mscm_regmap)) { + pr_err("regmap lookup for mscm failed"); + goto out; + } + + rom_regmap = syscon_regmap_lookup_by_compatible("fsl,vf610-ocrom"); + if (IS_ERR(rom_regmap)) { + pr_err("regmap lookup for ocrom failed"); + goto out; + } + + regmap_read(ocotp_regmap, OCOTP_CFG0_OFFSET, &soc_id1); + regmap_read(ocotp_regmap, OCOTP_CFG1_OFFSET, &soc_id2); + + soc_id = (u64) soc_id1 << 32 | soc_id2; + add_device_randomness(&soc_id, sizeof(soc_id)); + + regmap_read(mscm_regmap, MSCM_CPxCOUNT_OFFSET, &cpxcount); + regmap_read(mscm_regmap, MSCM_CPxCFG1_OFFSET, &cpxcfg1); + + soc_type[0] = cpxcount ? '6' : '5'; /* Dual Core => VF6x0 */ + soc_type[1] = cpxcfg1 ? '1' : '0'; /* L2 Cache => VFx10 */ + + regmap_read(rom_regmap, ROM_REVISION_OFFSET, &rom_rev); + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + goto out; + + soc_dev_attr->machine = kasprintf(GFP_KERNEL, "Freescale Vybrid"); + soc_dev_attr->soc_id = kasprintf(GFP_KERNEL, "%016llx", soc_id); + soc_dev_attr->family = kasprintf(GFP_KERNEL, "Freescale Vybrid VF%s", + soc_type); + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%08x", rom_rev); + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) { + kfree(soc_dev_attr->revision); + kfree(soc_dev_attr->family); + kfree(soc_dev_attr->soc_id); + kfree(soc_dev_attr->machine); + kfree(soc_dev_attr); + goto out; + } + + parent = soc_device_to_device(soc_dev); + +out: + of_platform_populate(NULL, of_default_bus_match_table, NULL, parent); +} static const char * const vf610_dt_compat[] __initconst = { "fsl,vf500", @@ -23,5 +103,6 @@ static const char * const vf610_dt_compat[] __initconst = { DT_MACHINE_START(VYBRID_VF610, "Freescale Vybrid VF5xx/VF6xx (Device Tree)") .l2c_aux_val = 0, .l2c_aux_mask = ~0, + .init_machine = vf610_init_machine, .dt_compat = vf610_dt_compat, MACHINE_END