From patchwork Fri Jun 5 09:22:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanchayan X-Patchwork-Id: 6552301 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 406239F1CC for ; Fri, 5 Jun 2015 09:31:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 216502070B for ; Fri, 5 Jun 2015 09:31:02 +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 D731C2070C for ; Fri, 5 Jun 2015 09:30:56 +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 1Z0ntv-0001AL-JZ; Fri, 05 Jun 2015 09:26:55 +0000 Received: from mail-pd0-f175.google.com ([209.85.192.175]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z0ntj-00010q-7i for linux-arm-kernel@lists.infradead.org; Fri, 05 Jun 2015 09:26:51 +0000 Received: by pdbnf5 with SMTP id nf5so49871272pdb.2 for ; Fri, 05 Jun 2015 02:25: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=0fxN/ayNRuUr0DrYLy5l+Izb+Gvlu4CBz/sYpIRgC6w=; b=V5oMB4IfbKVxlXkHjkZc3CKz1VRbCfvM1UDP7Z2DQvgUf6UU3/zOCprOZv+0iKuJek +sO1aABgJix1HoSr/vjJdob/uK1kuowni6guklXcJ23Ni7Q9r8YBnqc+ZMsW/RDEzx8J 5pWX9oBQTmPXxfqfSti25H7PZFo/G1VJjpmOW72gNNkdQJ8HcmzGCERpVcLoQDOZ1pZL xTr/Wh+Kw7/tZLseKE/4Gdc86Nf7SA2nxvy09VaikYB7XMmy6QkBynQL3aMjhFyM1Jb0 zxmXGsK38hdwQGgS72hrVb+MbSjz93Y/BMS9RrWeqvB4L45u+en0XcM1N1MTqm+ZJlmX ixZA== X-Received: by 10.66.232.104 with SMTP id tn8mr4432631pac.73.1433496337329; Fri, 05 Jun 2015 02:25:37 -0700 (PDT) Received: from localhost ([115.115.225.206]) by mx.google.com with ESMTPSA id v4sm6125959pbs.0.2015.06.05.02.25.32 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jun 2015 02:25:36 -0700 (PDT) From: Sanchayan Maity To: arnd@arndb.de, shawn.guo@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 2/2] soc: Add driver for Freescale Vybrid Platform Date: Fri, 5 Jun 2015 14:52:38 +0530 Message-Id: X-Mailer: git-send-email 2.4.2 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150605_022643_379501_CE2D1224 X-CRM114-Status: GOOD ( 17.92 ) X-Spam-Score: -1.9 (-) Cc: devicetree@vger.kernel.org, Sanchayan Maity , stefan@agner.ch, kernel@pengutronix.de, linux-kernel@vger.kernel.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 | 10 +++ drivers/soc/fsl/Makefile | 1 + drivers/soc/fsl/soc-vf610.c | 166 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 179 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..5752f77 --- /dev/null +++ b/drivers/soc/fsl/Kconfig @@ -0,0 +1,10 @@ +# +# Freescale SoC drivers + +config SOC_BUS_VF610 + tristate "SoC bus device for the Freescale Vybrid platform" + depends on SOC_VF610 + select SOC_BUS + help + Include support for the SoC bus on the Freescale Vybrid platform + providing some sysfs information about the module variant. diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile new file mode 100644 index 0000000..3d6b331 --- /dev/null +++ b/drivers/soc/fsl/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_SOC_BUS_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..d66360e --- /dev/null +++ b/drivers/soc/fsl/soc-vf610.c @@ -0,0 +1,166 @@ +/* + * 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 + +#define DRIVER_NAME "vf610-soc-bus" + +#define MSCM_CPxCOUNT_OFFSET 0x0000002C +#define MSCM_CPxCFG1_OFFSET 0x00000014 + +struct vf610_soc { + struct device *dev; + struct soc_device_attribute *soc_dev_attr; + struct soc_device *soc_dev; +}; + +static int vf610_soc_probe(struct platform_device *pdev) +{ + struct vf610_soc *info; + struct regmap *ocotp_regmap, *mscm_regmap, *rom_regmap; + struct device *dev = &pdev->dev; + struct device_node *node = pdev->dev.of_node; + struct device_node *soc_node; + struct of_phandle_args pargs; + char soc_type[] = "xx0"; + u32 cfg0_offset, cfg1_offset, rom_rev_offset; + u32 soc_id1, soc_id2, rom_rev; + u32 cpxcount, cpxcfg1; + u64 soc_id; + int ret; + + info = devm_kzalloc(&pdev->dev, sizeof(struct vf610_soc), GFP_KERNEL); + if (!info) + return -ENOMEM; + + info->dev = &pdev->dev; + platform_set_drvdata(pdev, info); + + mscm_regmap = syscon_node_to_regmap(node); + if (IS_ERR(mscm_regmap)) { + dev_err(dev, "regmap lookup for mscm failed\n"); + return PTR_ERR(mscm_regmap); + } + + soc_node = of_find_node_by_path("/soc"); + + ret = of_parse_phandle_with_fixed_args(soc_node, + "ocotp-cfg", 2, 0, &pargs); + if (ret) { + dev_err(dev, "lookup failed for ocotp-cfg node %d\n", ret); + return ret; + } + + ocotp_regmap = syscon_node_to_regmap(pargs.np); + if (IS_ERR(ocotp_regmap)) { + of_node_put(pargs.np); + dev_err(dev, "regmap lookup for ocotp failed\n"); + return PTR_ERR(ocotp_regmap); + } + + cfg0_offset = pargs.args[0]; + cfg1_offset = pargs.args[1]; + of_node_put(pargs.np); + + ret = of_parse_phandle_with_fixed_args(soc_node, + "rom-revision", 1, 0, &pargs); + if (ret) { + dev_err(dev, "lookup failed for rom-revision node %d\n", ret); + return ret; + } + + rom_regmap = syscon_node_to_regmap(pargs.np); + if (IS_ERR(rom_regmap)) { + of_node_put(pargs.np); + dev_err(dev, "regmap lookup for ocrom failed\n"); + return PTR_ERR(rom_regmap); + } + + rom_rev_offset = pargs.args[0]; + of_node_put(pargs.np); + + ret = regmap_read(ocotp_regmap, cfg0_offset, &soc_id1); + if (ret) + return -ENODEV; + + ret = regmap_read(ocotp_regmap, 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_rev_offset, &rom_rev); + if (ret) + return -ENODEV; + + info->soc_dev_attr = devm_kzalloc(&pdev->dev, + sizeof(info->soc_dev_attr), GFP_KERNEL); + if (!info->soc_dev_attr) + return -ENOMEM; + + info->soc_dev_attr->machine = devm_kasprintf(&pdev->dev, + GFP_KERNEL, "Freescale Vybrid"); + info->soc_dev_attr->soc_id = devm_kasprintf(&pdev->dev, + GFP_KERNEL, "%016llx", soc_id); + info->soc_dev_attr->family = devm_kasprintf(&pdev->dev, + GFP_KERNEL, "Freescale Vybrid VF%s", + soc_type); + info->soc_dev_attr->revision = devm_kasprintf(&pdev->dev, + GFP_KERNEL, "%08x", rom_rev); + + info->soc_dev = soc_device_register(info->soc_dev_attr); + if (IS_ERR(info->soc_dev)) + return -ENODEV; + + return 0; +} + +static int vf610_soc_remove(struct platform_device *pdev) +{ + struct vf610_soc *info = platform_get_drvdata(pdev); + + if (info->soc_dev) + soc_device_unregister(info->soc_dev); + + return 0; +} + +static const struct of_device_id vf610_soc_bus_match[] = { + { .compatible = "fsl,vf610-mscm-cpucfg", }, + { /* sentinel */ } +}; + +static struct platform_driver vf610_soc_driver = { + .probe = vf610_soc_probe, + .remove = vf610_soc_remove, + .driver = { + .name = DRIVER_NAME, + .of_match_table = vf610_soc_bus_match, + }, +}; +module_platform_driver(vf610_soc_driver);