aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/soc
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2014-10-24 06:51:20 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-11-13 04:32:05 -0500
commitf956a785a282f6b5a3e7d59937548f8b7c04d1ac (patch)
tree62813b553257c642da747b406358532b0306930f /drivers/soc
parentbcc397de5af74ed31f35c0ca4cbd9faadb775c2e (diff)
soc: move SoC driver for the ARM Integrator
This creates a new SoC bus driver for the ARM Integrator family core modules to register the SoC bus and provide sysfs info for the core module. We delete the corresponding code from the Integrator machine and select this driver to get a clean result. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/soc')
-rw-r--r--drivers/soc/versatile/Kconfig9
-rw-r--r--drivers/soc/versatile/Makefile1
-rw-r--r--drivers/soc/versatile/soc-integrator.c154
3 files changed, 164 insertions, 0 deletions
diff --git a/drivers/soc/versatile/Kconfig b/drivers/soc/versatile/Kconfig
index bf5ee9c85330..a928a7fc6be4 100644
--- a/drivers/soc/versatile/Kconfig
+++ b/drivers/soc/versatile/Kconfig
@@ -1,6 +1,15 @@
1# 1#
2# ARM Versatile SoC drivers 2# ARM Versatile SoC drivers
3# 3#
4config SOC_INTEGRATOR_CM
5 bool "SoC bus device for the ARM Integrator platform core modules"
6 depends on ARCH_INTEGRATOR
7 select SOC_BUS
8 help
9 Include support for the SoC bus on the ARM Integrator platform
10 core modules providing some sysfs information about the ASIC
11 variant.
12
4config SOC_REALVIEW 13config SOC_REALVIEW
5 bool "SoC bus device for the ARM RealView platforms" 14 bool "SoC bus device for the ARM RealView platforms"
6 depends on ARCH_REALVIEW 15 depends on ARCH_REALVIEW
diff --git a/drivers/soc/versatile/Makefile b/drivers/soc/versatile/Makefile
index ad547435648e..cf612fe3a659 100644
--- a/drivers/soc/versatile/Makefile
+++ b/drivers/soc/versatile/Makefile
@@ -1 +1,2 @@
1obj-$(CONFIG_SOC_INTEGRATOR_CM) += soc-integrator.o
1obj-$(CONFIG_SOC_REALVIEW) += soc-realview.o 2obj-$(CONFIG_SOC_REALVIEW) += soc-realview.o
diff --git a/drivers/soc/versatile/soc-integrator.c b/drivers/soc/versatile/soc-integrator.c
new file mode 100644
index 000000000000..ccaa53739ab4
--- /dev/null
+++ b/drivers/soc/versatile/soc-integrator.c
@@ -0,0 +1,154 @@
1/*
2 * Copyright (C) 2014 Linaro Ltd.
3 *
4 * Author: Linus Walleij <linus.walleij@linaro.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
9 *
10 */
11#include <linux/init.h>
12#include <linux/io.h>
13#include <linux/slab.h>
14#include <linux/sys_soc.h>
15#include <linux/platform_device.h>
16#include <linux/mfd/syscon.h>
17#include <linux/regmap.h>
18#include <linux/of.h>
19
20#define INTEGRATOR_HDR_ID_OFFSET 0x00
21
22static u32 integrator_coreid;
23
24static const struct of_device_id integrator_cm_match[] = {
25 { .compatible = "arm,core-module-integrator", },
26};
27
28static const char *integrator_arch_str(u32 id)
29{
30 switch ((id >> 16) & 0xff) {
31 case 0x00:
32 return "ASB little-endian";
33 case 0x01:
34 return "AHB little-endian";
35 case 0x03:
36 return "AHB-Lite system bus, bi-endian";
37 case 0x04:
38 return "AHB";
39 case 0x08:
40 return "AHB system bus, ASB processor bus";
41 default:
42 return "Unknown";
43 }
44}
45
46static const char *integrator_fpga_str(u32 id)
47{
48 switch ((id >> 12) & 0xf) {
49 case 0x01:
50 return "XC4062";
51 case 0x02:
52 return "XC4085";
53 case 0x03:
54 return "XVC600";
55 case 0x04:
56 return "EPM7256AE (Altera PLD)";
57 default:
58 return "Unknown";
59 }
60}
61
62static ssize_t integrator_get_manf(struct device *dev,
63 struct device_attribute *attr,
64 char *buf)
65{
66 return sprintf(buf, "%02x\n", integrator_coreid >> 24);
67}
68
69static struct device_attribute integrator_manf_attr =
70 __ATTR(manufacturer, S_IRUGO, integrator_get_manf, NULL);
71
72static ssize_t integrator_get_arch(struct device *dev,
73 struct device_attribute *attr,
74 char *buf)
75{
76 return sprintf(buf, "%s\n", integrator_arch_str(integrator_coreid));
77}
78
79static struct device_attribute integrator_arch_attr =
80 __ATTR(arch, S_IRUGO, integrator_get_arch, NULL);
81
82static ssize_t integrator_get_fpga(struct device *dev,
83 struct device_attribute *attr,
84 char *buf)
85{
86 return sprintf(buf, "%s\n", integrator_fpga_str(integrator_coreid));
87}
88
89static struct device_attribute integrator_fpga_attr =
90 __ATTR(fpga, S_IRUGO, integrator_get_fpga, NULL);
91
92static ssize_t integrator_get_build(struct device *dev,
93 struct device_attribute *attr,
94 char *buf)
95{
96 return sprintf(buf, "%02x\n", (integrator_coreid >> 4) & 0xFF);
97}
98
99static struct device_attribute integrator_build_attr =
100 __ATTR(build, S_IRUGO, integrator_get_build, NULL);
101
102static int __init integrator_soc_init(void)
103{
104 static struct regmap *syscon_regmap;
105 struct soc_device *soc_dev;
106 struct soc_device_attribute *soc_dev_attr;
107 struct device_node *np;
108 struct device *dev;
109 u32 val;
110 int ret;
111
112 np = of_find_matching_node(NULL, integrator_cm_match);
113 if (!np)
114 return -ENODEV;
115
116 syscon_regmap = syscon_node_to_regmap(np);
117 if (IS_ERR(syscon_regmap))
118 return PTR_ERR(syscon_regmap);
119
120 ret = regmap_read(syscon_regmap, INTEGRATOR_HDR_ID_OFFSET,
121 &val);
122 if (ret)
123 return -ENODEV;
124 integrator_coreid = val;
125
126 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
127 if (!soc_dev_attr)
128 return -ENOMEM;
129
130 soc_dev_attr->soc_id = "Integrator";
131 soc_dev_attr->machine = "Integrator";
132 soc_dev_attr->family = "Versatile";
133 soc_dev = soc_device_register(soc_dev_attr);
134 if (IS_ERR(soc_dev)) {
135 kfree(soc_dev_attr);
136 return -ENODEV;
137 }
138 dev = soc_device_to_device(soc_dev);
139
140 device_create_file(dev, &integrator_manf_attr);
141 device_create_file(dev, &integrator_arch_attr);
142 device_create_file(dev, &integrator_fpga_attr);
143 device_create_file(dev, &integrator_build_attr);
144
145 dev_info(dev, "Detected ARM core module:\n");
146 dev_info(dev, " Manufacturer: %02x\n", (val >> 24));
147 dev_info(dev, " Architecture: %s\n", integrator_arch_str(val));
148 dev_info(dev, " FPGA: %s\n", integrator_fpga_str(val));
149 dev_info(dev, " Build: %02x\n", (val >> 4) & 0xFF);
150 dev_info(dev, " Rev: %c\n", ('A' + (val & 0x03)));
151
152 return 0;
153}
154device_initcall(integrator_soc_init);