aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--arch/arm/mach-integrator/Kconfig1
-rw-r--r--arch/arm/mach-integrator/common.h1
-rw-r--r--arch/arm/mach-integrator/core.c95
-rw-r--r--arch/arm/mach-integrator/integrator_ap.c27
-rw-r--r--arch/arm/mach-integrator/integrator_cp.c27
-rw-r--r--drivers/soc/versatile/Kconfig9
-rw-r--r--drivers/soc/versatile/Makefile1
-rw-r--r--drivers/soc/versatile/soc-integrator.c154
8 files changed, 165 insertions, 150 deletions
diff --git a/arch/arm/mach-integrator/Kconfig b/arch/arm/mach-integrator/Kconfig
index 62e6db4bd533..02d083489a26 100644
--- a/arch/arm/mach-integrator/Kconfig
+++ b/arch/arm/mach-integrator/Kconfig
@@ -14,6 +14,7 @@ config ARCH_INTEGRATOR
14 select POWER_RESET 14 select POWER_RESET
15 select POWER_RESET_VERSATILE 15 select POWER_RESET_VERSATILE
16 select POWER_SUPPLY 16 select POWER_SUPPLY
17 select SOC_INTEGRATOR_CM
17 select SPARSE_IRQ 18 select SPARSE_IRQ
18 select USE_OF 19 select USE_OF
19 select VERSATILE_FPGA_IRQ 20 select VERSATILE_FPGA_IRQ
diff --git a/arch/arm/mach-integrator/common.h b/arch/arm/mach-integrator/common.h
index 27a627aa1e8f..96c9dc56cabf 100644
--- a/arch/arm/mach-integrator/common.h
+++ b/arch/arm/mach-integrator/common.h
@@ -4,4 +4,3 @@ extern struct amba_pl010_data ap_uart_data;
4void integrator_init_early(void); 4void integrator_init_early(void);
5int integrator_init(bool is_cp); 5int integrator_init(bool is_cp);
6void integrator_reserve(void); 6void integrator_reserve(void);
7void integrator_init_sysfs(struct device *parent, u32 id);
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index b06fd9f99a46..948872a419c1 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -60,40 +60,6 @@ void cm_control(u32 mask, u32 set)
60 raw_spin_unlock_irqrestore(&cm_lock, flags); 60 raw_spin_unlock_irqrestore(&cm_lock, flags);
61} 61}
62 62
63static const char *integrator_arch_str(u32 id)
64{
65 switch ((id >> 16) & 0xff) {
66 case 0x00:
67 return "ASB little-endian";
68 case 0x01:
69 return "AHB little-endian";
70 case 0x03:
71 return "AHB-Lite system bus, bi-endian";
72 case 0x04:
73 return "AHB";
74 case 0x08:
75 return "AHB system bus, ASB processor bus";
76 default:
77 return "Unknown";
78 }
79}
80
81static const char *integrator_fpga_str(u32 id)
82{
83 switch ((id >> 12) & 0xf) {
84 case 0x01:
85 return "XC4062";
86 case 0x02:
87 return "XC4085";
88 case 0x03:
89 return "XVC600";
90 case 0x04:
91 return "EPM7256AE (Altera PLD)";
92 default:
93 return "Unknown";
94 }
95}
96
97void cm_clear_irqs(void) 63void cm_clear_irqs(void)
98{ 64{
99 /* disable core module IRQs */ 65 /* disable core module IRQs */
@@ -109,7 +75,6 @@ static const struct of_device_id cm_match[] = {
109void cm_init(void) 75void cm_init(void)
110{ 76{
111 struct device_node *cm = of_find_matching_node(NULL, cm_match); 77 struct device_node *cm = of_find_matching_node(NULL, cm_match);
112 u32 val;
113 78
114 if (!cm) { 79 if (!cm) {
115 pr_crit("no core module node found in device tree\n"); 80 pr_crit("no core module node found in device tree\n");
@@ -121,13 +86,6 @@ void cm_init(void)
121 return; 86 return;
122 } 87 }
123 cm_clear_irqs(); 88 cm_clear_irqs();
124 val = readl(cm_base + INTEGRATOR_HDR_ID_OFFSET);
125 pr_info("Detected ARM core module:\n");
126 pr_info(" Manufacturer: %02x\n", (val >> 24));
127 pr_info(" Architecture: %s\n", integrator_arch_str(val));
128 pr_info(" FPGA: %s\n", integrator_fpga_str(val));
129 pr_info(" Build: %02x\n", (val >> 4) & 0xFF);
130 pr_info(" Rev: %c\n", ('A' + (val & 0x03)));
131} 89}
132 90
133/* 91/*
@@ -139,56 +97,3 @@ void __init integrator_reserve(void)
139{ 97{
140 memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET); 98 memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);
141} 99}
142
143static u32 integrator_id;
144
145static ssize_t intcp_get_manf(struct device *dev,
146 struct device_attribute *attr,
147 char *buf)
148{
149 return sprintf(buf, "%02x\n", integrator_id >> 24);
150}
151
152static struct device_attribute intcp_manf_attr =
153 __ATTR(manufacturer, S_IRUGO, intcp_get_manf, NULL);
154
155static ssize_t intcp_get_arch(struct device *dev,
156 struct device_attribute *attr,
157 char *buf)
158{
159 return sprintf(buf, "%s\n", integrator_arch_str(integrator_id));
160}
161
162static struct device_attribute intcp_arch_attr =
163 __ATTR(architecture, S_IRUGO, intcp_get_arch, NULL);
164
165static ssize_t intcp_get_fpga(struct device *dev,
166 struct device_attribute *attr,
167 char *buf)
168{
169 return sprintf(buf, "%s\n", integrator_fpga_str(integrator_id));
170}
171
172static struct device_attribute intcp_fpga_attr =
173 __ATTR(fpga, S_IRUGO, intcp_get_fpga, NULL);
174
175static ssize_t intcp_get_build(struct device *dev,
176 struct device_attribute *attr,
177 char *buf)
178{
179 return sprintf(buf, "%02x\n", (integrator_id >> 4) & 0xFF);
180}
181
182static struct device_attribute intcp_build_attr =
183 __ATTR(build, S_IRUGO, intcp_get_build, NULL);
184
185
186
187void integrator_init_sysfs(struct device *parent, u32 id)
188{
189 integrator_id = id;
190 device_create_file(parent, &intcp_manf_attr);
191 device_create_file(parent, &intcp_arch_attr);
192 device_create_file(parent, &intcp_fpga_attr);
193 device_create_file(parent, &intcp_build_attr);
194}
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
index e6854c3f854e..30003ba447a5 100644
--- a/arch/arm/mach-integrator/integrator_ap.c
+++ b/arch/arm/mach-integrator/integrator_ap.c
@@ -35,7 +35,6 @@
35#include <linux/of_address.h> 35#include <linux/of_address.h>
36#include <linux/of_platform.h> 36#include <linux/of_platform.h>
37#include <linux/stat.h> 37#include <linux/stat.h>
38#include <linux/sys_soc.h>
39#include <linux/termios.h> 38#include <linux/termios.h>
40 39
41#include <asm/hardware/arm_timer.h> 40#include <asm/hardware/arm_timer.h>
@@ -288,10 +287,6 @@ static void __init ap_init_of(void)
288 unsigned long sc_dec; 287 unsigned long sc_dec;
289 struct device_node *syscon; 288 struct device_node *syscon;
290 struct device_node *ebi; 289 struct device_node *ebi;
291 struct device *parent;
292 struct soc_device *soc_dev;
293 struct soc_device_attribute *soc_dev_attr;
294 u32 ap_sc_id;
295 int i; 290 int i;
296 291
297 syscon = of_find_matching_node(NULL, ap_syscon_match); 292 syscon = of_find_matching_node(NULL, ap_syscon_match);
@@ -311,28 +306,6 @@ static void __init ap_init_of(void)
311 of_platform_populate(NULL, of_default_bus_match_table, 306 of_platform_populate(NULL, of_default_bus_match_table,
312 ap_auxdata_lookup, NULL); 307 ap_auxdata_lookup, NULL);
313 308
314 ap_sc_id = readl(ap_syscon_base);
315
316 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
317 if (!soc_dev_attr)
318 return;
319
320 soc_dev_attr->soc_id = "XVC";
321 soc_dev_attr->machine = "Integrator/AP";
322 soc_dev_attr->family = "Integrator";
323 soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%c",
324 'A' + (ap_sc_id & 0x0f));
325
326 soc_dev = soc_device_register(soc_dev_attr);
327 if (IS_ERR(soc_dev)) {
328 kfree(soc_dev_attr->revision);
329 kfree(soc_dev_attr);
330 return;
331 }
332
333 parent = soc_device_to_device(soc_dev);
334 integrator_init_sysfs(parent, ap_sc_id);
335
336 sc_dec = readl(ap_syscon_base + INTEGRATOR_SC_DEC_OFFSET); 309 sc_dec = readl(ap_syscon_base + INTEGRATOR_SC_DEC_OFFSET);
337 for (i = 0; i < 4; i++) { 310 for (i = 0; i < 4; i++) {
338 struct lm_device *lmdev; 311 struct lm_device *lmdev;
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index fa8475b4872d..b5fb71a36ee6 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -27,7 +27,6 @@
27#include <linux/of_irq.h> 27#include <linux/of_irq.h>
28#include <linux/of_address.h> 28#include <linux/of_address.h>
29#include <linux/of_platform.h> 29#include <linux/of_platform.h>
30#include <linux/sys_soc.h>
31#include <linux/sched_clock.h> 30#include <linux/sched_clock.h>
32 31
33#include <asm/setup.h> 32#include <asm/setup.h>
@@ -274,10 +273,6 @@ static const struct of_device_id intcp_syscon_match[] = {
274static void __init intcp_init_of(void) 273static void __init intcp_init_of(void)
275{ 274{
276 struct device_node *cpcon; 275 struct device_node *cpcon;
277 struct device *parent;
278 struct soc_device *soc_dev;
279 struct soc_device_attribute *soc_dev_attr;
280 u32 intcp_sc_id;
281 276
282 cpcon = of_find_matching_node(NULL, intcp_syscon_match); 277 cpcon = of_find_matching_node(NULL, intcp_syscon_match);
283 if (!cpcon) 278 if (!cpcon)
@@ -289,28 +284,6 @@ static void __init intcp_init_of(void)
289 284
290 of_platform_populate(NULL, of_default_bus_match_table, 285 of_platform_populate(NULL, of_default_bus_match_table,
291 intcp_auxdata_lookup, NULL); 286 intcp_auxdata_lookup, NULL);
292
293 intcp_sc_id = readl(intcp_con_base);
294
295 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
296 if (!soc_dev_attr)
297 return;
298
299 soc_dev_attr->soc_id = "XCV";
300 soc_dev_attr->machine = "Integrator/CP";
301 soc_dev_attr->family = "Integrator";
302 soc_dev_attr->revision = kasprintf(GFP_KERNEL, "%c",
303 'A' + (intcp_sc_id & 0x0f));
304
305 soc_dev = soc_device_register(soc_dev_attr);
306 if (IS_ERR(soc_dev)) {
307 kfree(soc_dev_attr->revision);
308 kfree(soc_dev_attr);
309 return;
310 }
311
312 parent = soc_device_to_device(soc_dev);
313 integrator_init_sysfs(parent, intcp_sc_id);
314} 287}
315 288
316static const char * intcp_dt_board_compat[] = { 289static const char * intcp_dt_board_compat[] = {
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);