From patchwork Fri May 22 10:51:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanchayan X-Patchwork-Id: 6463631 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 19D9FC0433 for ; Fri, 22 May 2015 10:57:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1607C20458 for ; Fri, 22 May 2015 10:57:26 +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 1D1432045E for ; Fri, 22 May 2015 10:57:25 +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 1Yvkbm-00036n-R2; Fri, 22 May 2015 10:55:18 +0000 Received: from mail-pa0-x242.google.com ([2607:f8b0:400e:c03::242]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YvkbS-0001ts-5O for linux-arm-kernel@lists.infradead.org; Fri, 22 May 2015 10:55:00 +0000 Received: by pablj1 with SMTP id lj1so2322290pab.1 for ; Fri, 22 May 2015 03:54:37 -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=LGqOH1h+rf/3FvvbVdGxojuZBFuC6JAhlv1pnR0tIOE=; b=JLEF/KF69doERKsHO+HQO9Txb+DWG7Rat2LFH5TJN7gVoYWCJghaEQzeon7uoGxyof 6W+MHjh/u1rX956hFv3fFwmQuPhEHGeDW28Y4POnaDubY35zSRN/G0O9fCv6xBF7qoiZ 1THY9iHqkYsEGYma1Uf59gsoI8mNl/UNX8Qw6x5Sdd/fxr2ij0etu35xAN5pUZcn/EWg DVgu+Xd5B2N3pr4iD3sUmh6eaGpBwMvjjUNFO95xMCUp8vbwuVnsFtFXcRJcR7BEY4PL OM9y144dxbY9IlGQrQ93R2ZQ3li+GoOb2hxhydKBYsTjUJ3QTYKvL/fe21OM3HA2eWLQ /0ZQ== X-Received: by 10.68.57.170 with SMTP id j10mr14570753pbq.150.1432292076957; Fri, 22 May 2015 03:54:36 -0700 (PDT) Received: from localhost ([122.166.214.162]) by mx.google.com with ESMTPSA id yv6sm1797582pac.29.2015.05.22.03.54.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 May 2015 03:54:35 -0700 (PDT) From: Sanchayan Maity To: arnd@arndb.de, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 2/2] soc: Add driver for Freescale Vybrid Platform Date: Fri, 22 May 2015 16:21:54 +0530 Message-Id: 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-20150522_035458_288310_C500AB97 X-CRM114-Status: GOOD ( 17.44 ) X-Spam-Score: -0.8 (/) Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, stefan@agner.ch, Sanchayan Maity , kernel@pengutronix.de, shawn.guo@linaro.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 This adds a SoC driver to be used by the Freescale Vybrid SoC's. We create the "fsl" directory for holding the different Freescale designs. Driver utilises syscon to get the various register values needed. After this sysfs exposes some SoC specific properties as below: > cd /sys/devices/soc0 > ls family machine power revision soc_id subsystem uevent > cat family Freescale Vybrid VF610 > cat machine Freescale Vybrid > cat revision 00000013 > cat soc_id df6472a60c1c39d4 Signed-off-by: Sanchayan Maity --- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/fsl/Kconfig | 9 ++++ drivers/soc/fsl/Makefile | 1 + drivers/soc/fsl/soc-vf610.c | 113 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 125 insertions(+) create mode 100644 drivers/soc/fsl/Kconfig create mode 100644 drivers/soc/fsl/Makefile create mode 100644 drivers/soc/fsl/soc-vf610.c diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index d8bde82..8b4dd2b 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -1,5 +1,6 @@ menu "SOC (System On Chip) specific Drivers" +source "drivers/soc/fsl/Kconfig" source "drivers/soc/mediatek/Kconfig" source "drivers/soc/qcom/Kconfig" source "drivers/soc/ti/Kconfig" diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 70042b2..142676e 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -2,6 +2,7 @@ # Makefile for the Linux Kernel SOC specific device drivers. # +obj-$(CONFIG_SOC_VF610) += fsl/ obj-$(CONFIG_ARCH_MEDIATEK) += mediatek/ obj-$(CONFIG_ARCH_QCOM) += qcom/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig new file mode 100644 index 0000000..d0ac671 --- /dev/null +++ b/drivers/soc/fsl/Kconfig @@ -0,0 +1,9 @@ +# +# Freescale SoC drivers + +config SOC_VF610 + bool "SoC bus device for the Freescale Vybrid platform" + select SOC_BUS + help + Include support for the SoC bus on the Freescale Vybrid platform + providing some sysfs information about the module variant. \ No newline at end of file diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile new file mode 100644 index 0000000..5fccbba --- /dev/null +++ b/drivers/soc/fsl/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_SOC_VF610) += soc-vf610.o diff --git a/drivers/soc/fsl/soc-vf610.c b/drivers/soc/fsl/soc-vf610.c new file mode 100644 index 0000000..faeb567 --- /dev/null +++ b/drivers/soc/fsl/soc-vf610.c @@ -0,0 +1,113 @@ +/* + * Copyright 2015 Toradex AG + * + * Author: Sanchayan Maity + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, as + * published by the Free Software Foundation. + * + */ + +#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 const struct of_device_id vf610_soc_bus_match[] = { + { .compatible = "fsl,vf610-mscm-cpucfg", }, + { /* sentinel */ } +}; + +static int __init vf610_soc_init(void) +{ + struct regmap *ocotp_regmap, *mscm_regmap, *rom_regmap; + struct soc_device_attribute *soc_dev_attr; + struct soc_device *soc_dev; + struct device_node *np; + char soc_type[] = "xx0"; + u32 cpxcount, cpxcfg1; + u32 soc_id1, soc_id2, rom_rev; + u64 soc_id; + int ret; + + np = of_find_matching_node(NULL, vf610_soc_bus_match); + if (!np) + return -ENODEV; + + ocotp_regmap = syscon_regmap_lookup_by_compatible("fsl,vf610-ocotp"); + if (IS_ERR(ocotp_regmap)) { + pr_err("regmap lookup for octop failed\n"); + return PTR_ERR(ocotp_regmap); + } + + mscm_regmap = syscon_regmap_lookup_by_compatible("fsl,vf610-mscm-cpucfg"); + if (IS_ERR(mscm_regmap)) { + pr_err("regmap lookup for mscm failed"); + return PTR_ERR(mscm_regmap); + } + + rom_regmap = syscon_regmap_lookup_by_compatible("fsl,vf610-ocrom"); + if (IS_ERR(rom_regmap)) { + pr_err("regmap lookup for ocrom failed"); + return PTR_ERR(rom_regmap); + } + + ret = regmap_read(ocotp_regmap, OCOTP_CFG0_OFFSET, &soc_id1); + if (ret) + return -ENODEV; + + ret = regmap_read(ocotp_regmap, OCOTP_CFG1_OFFSET, &soc_id2); + if (ret) + return -ENODEV; + + soc_id = (u64) soc_id1 << 32 | soc_id2; + add_device_randomness(&soc_id, sizeof(soc_id)); + + ret = regmap_read(mscm_regmap, MSCM_CPxCOUNT_OFFSET, &cpxcount); + if (ret) + return -ENODEV; + + ret = regmap_read(mscm_regmap, MSCM_CPxCFG1_OFFSET, &cpxcfg1); + if (ret) + return -ENODEV; + + soc_type[0] = cpxcount ? '6' : '5'; /* Dual Core => VF6x0 */ + soc_type[1] = cpxcfg1 ? '1' : '0'; /* L2 Cache => VFx10 */ + + ret = regmap_read(rom_regmap, ROM_REVISION_OFFSET, &rom_rev); + if (ret) + return -ENODEV; + + soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); + if (!soc_dev_attr) + return -ENOMEM; + + 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); + return -ENODEV; + } + + return 0; +} +device_initcall(vf610_soc_init);