summaryrefslogtreecommitdiff
path: root/drivers/soc
diff options
context:
space:
mode:
authorSanchayan Maity <maitysanchayan@gmail.com>2016-03-04 17:01:22 +0530
committerStefan Agner <stefan.agner@toradex.com>2016-03-09 14:05:58 -0800
commitb1ca2804f4126a5ab1028b733340565d5c085766 (patch)
tree06be320e9840179dc032c0211817b37d86d6154f /drivers/soc
parent920879df35a9fc87283dbe853a8330f11bacefa4 (diff)
soc: Add SoC bus driver for Freescale Vybrid platform
This adds SoC driver to be used by the Freescale Vybrid SoC's. Driver utilises syscon and nvmem container API's to get the various register values needed and sysfs exposes the SoC specific properties. > 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 e302a4e9352371d4 Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com> [added add_device_randomness] Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Diffstat (limited to 'drivers/soc')
-rw-r--r--drivers/soc/Kconfig1
-rw-r--r--drivers/soc/Makefile1
-rw-r--r--drivers/soc/fsl/Kconfig10
-rw-r--r--drivers/soc/fsl/Makefile1
-rw-r--r--drivers/soc/fsl/soc-vf610.c161
5 files changed, 174 insertions, 0 deletions
diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig
index 4e853ed2c82b..9864fd55a0ab 100644
--- a/drivers/soc/Kconfig
+++ b/drivers/soc/Kconfig
@@ -1,6 +1,7 @@
menu "SOC (System On Chip) specific Drivers"
source "drivers/soc/brcmstb/Kconfig"
+source "drivers/soc/fsl/Kconfig"
source "drivers/soc/mediatek/Kconfig"
source "drivers/soc/qcom/Kconfig"
source "drivers/soc/rockchip/Kconfig"
diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile
index f2ba2e932ae1..21c9c3a0c98f 100644
--- a/drivers/soc/Makefile
+++ b/drivers/soc/Makefile
@@ -10,4 +10,5 @@ obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
obj-$(CONFIG_ARCH_SUNXI) += sunxi/
obj-$(CONFIG_ARCH_TEGRA) += tegra/
obj-$(CONFIG_SOC_TI) += ti/
+obj-$(CONFIG_SOC_VF610) += fsl/
obj-$(CONFIG_PLAT_VERSATILE) += versatile/
diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig
new file mode 100644
index 000000000000..5568c34474f7
--- /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 && NVMEM && NVMEM_VF610_OCOTP
+ 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 000000000000..41ee22fe311f
--- /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 000000000000..864bf5688f56
--- /dev/null
+++ b/drivers/soc/fsl/soc-vf610.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2016 Toradex AG.
+ *
+ * Author: Sanchayan Maity <sanchayan.maity@toradex.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/device.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/nvmem-consumer.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/random.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/sys_soc.h>
+
+struct vf610_soc {
+ struct device *dev;
+ struct soc_device_attribute *soc_dev_attr;
+ struct soc_device *soc_dev;
+ struct nvmem_cell *ocotp_cfg0;
+ struct nvmem_cell *ocotp_cfg1;
+};
+
+static int vf610_soc_probe(struct platform_device *pdev)
+{
+ struct vf610_soc *info;
+ struct device *dev = &pdev->dev;
+ struct device_node *soc_node;
+ char soc_type[] = "xx0";
+ size_t id1_len;
+ size_t id2_len;
+ u32 cpucount;
+ u32 l2size;
+ u32 rom_rev;
+ u8 *socid1;
+ u8 *socid2;
+ int ret;
+
+ info = devm_kzalloc(dev, sizeof(struct vf610_soc), GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+ info->dev = dev;
+
+ info->ocotp_cfg0 = devm_nvmem_cell_get(dev, "cfg0");
+ if (IS_ERR(info->ocotp_cfg0))
+ return -EPROBE_DEFER;
+
+ info->ocotp_cfg1 = devm_nvmem_cell_get(dev, "cfg1");
+ if (IS_ERR(info->ocotp_cfg1))
+ return -EPROBE_DEFER;
+
+ socid1 = nvmem_cell_read(info->ocotp_cfg0, &id1_len);
+ if (IS_ERR(socid1)) {
+ dev_err(dev, "Could not read nvmem cell %ld\n",
+ PTR_ERR(socid1));
+ return PTR_ERR(socid1);
+ }
+
+ socid2 = nvmem_cell_read(info->ocotp_cfg1, &id2_len);
+ if (IS_ERR(socid2)) {
+ dev_err(dev, "Could not read nvmem cell %ld\n",
+ PTR_ERR(socid2));
+ return PTR_ERR(socid2);
+ }
+ add_device_randomness(socid1, id1_len);
+ add_device_randomness(socid2, id2_len);
+
+ soc_node = of_find_node_by_path("/soc");
+ if (soc_node == NULL)
+ return -ENODEV;
+
+ ret = syscon_regmap_read_from_offset(soc_node,
+ "fsl,rom-revision", &rom_rev);
+ if (ret) {
+ of_node_put(soc_node);
+ return ret;
+ }
+
+ ret = syscon_regmap_read_from_offset(soc_node,
+ "fsl,cpu-count", &cpucount);
+ if (ret) {
+ of_node_put(soc_node);
+ return ret;
+ }
+
+ ret = syscon_regmap_read_from_offset(soc_node,
+ "fsl,l2-size", &l2size);
+ if (ret) {
+ of_node_put(soc_node);
+ return ret;
+ }
+
+ of_node_put(soc_node);
+
+ soc_type[0] = cpucount ? '6' : '5'; /* Dual Core => VF6x0 */
+ soc_type[1] = l2size ? '1' : '0'; /* L2 Cache => VFx10 */
+
+ info->soc_dev_attr = devm_kzalloc(dev,
+ sizeof(info->soc_dev_attr), GFP_KERNEL);
+ if (!info->soc_dev_attr)
+ return -ENOMEM;
+
+ info->soc_dev_attr->machine = devm_kasprintf(dev,
+ GFP_KERNEL, "Freescale Vybrid");
+ info->soc_dev_attr->soc_id = devm_kasprintf(dev,
+ GFP_KERNEL,
+ "%02x%02x%02x%02x%02x%02x%02x%02x",
+ socid1[3], socid1[2], socid1[1],
+ socid1[0], socid2[3], socid2[2],
+ socid2[1], socid2[0]);
+ info->soc_dev_attr->family = devm_kasprintf(&pdev->dev,
+ GFP_KERNEL, "Freescale Vybrid VF%s",
+ soc_type);
+ info->soc_dev_attr->revision = devm_kasprintf(dev,
+ GFP_KERNEL, "%08x", rom_rev);
+
+ platform_set_drvdata(pdev, info);
+
+ 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-soc-bus", },
+ { /* */ }
+};
+
+static struct platform_driver vf610_soc_driver = {
+ .probe = vf610_soc_probe,
+ .remove = vf610_soc_remove,
+ .driver = {
+ .name = "vf610-soc-bus",
+ .of_match_table = vf610_soc_bus_match,
+ },
+};
+module_platform_driver(vf610_soc_driver);