From patchwork Mon May 11 05:11:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanchayan X-Patchwork-Id: 6373061 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 2607BBEEE1 for ; Mon, 11 May 2015 05:17:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 31C29203A5 for ; Mon, 11 May 2015 05:17:37 +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 43FD820384 for ; Mon, 11 May 2015 05:17:36 +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 1Yrg39-0007ZC-1h; Mon, 11 May 2015 05:14:43 +0000 Received: from mail-pd0-x230.google.com ([2607:f8b0:400e:c02::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yrg2x-0007Vf-VA for linux-arm-kernel@lists.infradead.org; Mon, 11 May 2015 05:14:32 +0000 Received: by pdea3 with SMTP id a3so139015632pde.3 for ; Sun, 10 May 2015 22:14:10 -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=bSMuIsk8cN4zn4Y7/jB3tPnkE8Rb8EDdsUxH2o59FGI=; b=gBZIQhs+GXyqXnUN/XtPAvX8pZAIOeSVhXBri5rMk+SSqiOxxSC+HDHzCtClMd6lxp 7ah6lv+XVO/X1N7f4eBiwu+4ZRaUItLBphC9B0dt2ZJGeL2iBKaxlrMGfM5M4g5FlcTE SiNvMCTozKiX+PJYW6KDdKHdsMH5WcqlKY23/LX43n5TMiVQyx9qSgP2mGkqW65WqL6c e8rGh37hTESoQyVsGFMY0hmF5vquNxSZttGS7ujV67aHTtWsJb7e1FUECfse0pzIPwPb Lghw+8x6JpU7Zd7eS53KOzvUNRELjnBUMiiSqndJOajCnt11//HflVA7Dtoa1hRSO2Va IDRg== X-Received: by 10.70.108.137 with SMTP id hk9mr16206567pdb.105.1431321250754; Sun, 10 May 2015 22:14:10 -0700 (PDT) Received: from localhost ([115.115.225.206]) by mx.google.com with ESMTPSA id ms7sm11679368pdb.11.2015.05.10.22.14.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 May 2015 22:14:09 -0700 (PDT) From: Sanchayan Maity To: linux-arm-kernel@lists.infradead.org, shawn.guo@linaro.org, kernel@pengutronix.de Subject: [RFC 2/2] ARM: vf610: Add SoC bus support for Vybrid Date: Mon, 11 May 2015 10:41:39 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150510_221432_044159_D175759D X-CRM114-Status: GOOD ( 11.72 ) X-Spam-Score: -0.8 (/) Cc: Sanchayan Maity , linux-kernel@vger.kernel.org, stefan@agner.ch 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. Signed-off-by: Sanchayan Maity --- arch/arm/mach-imx/mach-vf610.c | 76 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/mach-vf610.c b/arch/arm/mach-imx/mach-vf610.c index 1ba7738..74681f1 100644 --- a/arch/arm/mach-imx/mach-vf610.c +++ b/arch/arm/mach-imx/mach-vf610.c @@ -9,13 +9,87 @@ #include #include +#include +#include +#include +#include +#include +#include #include #include #include "common.h" +#define OCOTP_CFG0_OFFSET 0x00000410 +#define OCOTP_CFG1_OFFSET 0x00000420 +#define MSCM_CPxCOUNT_OFFSET 0x0000002C +#define MSCM_CPxCFG1_OFFSET 0x00000014 +#define ROM_REVISION_REGISTER 0x00000080 + static void __init vf610_init_machine(void) { - of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); + struct regmap *ocotp_regmap, *mscm_regmap; + struct soc_device_attribute *soc_dev_attr; + struct device *parent = NULL; + struct soc_device *soc_dev; + char soc_type[] = "xx0"; + void __iomem *rom_rev; + u32 cpxcount, cpxcfg1; + u32 soc_id1, soc_id2; + 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; + } + + 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 */ + + 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, "%llx", soc_id); + soc_dev_attr->family = kasprintf(GFP_KERNEL, "Freescale Vybrid VF%s", + soc_type); + + rom_rev = ioremap(ROM_REVISION_REGISTER, SZ_1); + if (rom_rev) + soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%08x", + readl(rom_rev)); + + soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(soc_dev)) { + if (!rom_rev) + 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); vf610_pm_init(); }