917993fdbac3791f558e58fc981efef31b12842c
[openwrt/svn-archive/archive.git] / target / linux / lantiq / patches-2.6.39 / 0005-MIPS-Lantiq-Add-platform-device-support.patch
1 From 09e57348261c1ae0ff89c68679126fc76a28b2a2 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Wed, 30 Mar 2011 09:27:53 +0200
4 Subject: [PATCH 05/13] MIPS: Lantiq: Add platform device support
5
6 This patch adds the wrappers for registering our platform devices.
7
8 Signed-off-by: John Crispin <blogic@openwrt.org>
9 Signed-off-by: Ralph Hempel <ralph.hempel@lantiq.com>
10 Cc: linux-mips@linux-mips.org
11 Patchwork: https://patchwork.linux-mips.org/patch/2254/
12 Patchwork: https://patchwork.linux-mips.org/patch/2360/
13 Patchwork: https://patchwork.linux-mips.org/patch/2359/
14 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
15 ---
16 arch/mips/lantiq/Makefile | 2 +-
17 arch/mips/lantiq/devices.c | 122 +++++++++++++++++++++++++++++++++++++++
18 arch/mips/lantiq/devices.h | 23 +++++++
19 arch/mips/lantiq/xway/Makefile | 2 +-
20 arch/mips/lantiq/xway/devices.c | 98 +++++++++++++++++++++++++++++++
21 arch/mips/lantiq/xway/devices.h | 18 ++++++
22 6 files changed, 263 insertions(+), 2 deletions(-)
23 create mode 100644 arch/mips/lantiq/devices.c
24 create mode 100644 arch/mips/lantiq/devices.h
25 create mode 100644 arch/mips/lantiq/xway/devices.c
26 create mode 100644 arch/mips/lantiq/xway/devices.h
27
28 diff --git a/arch/mips/lantiq/Makefile b/arch/mips/lantiq/Makefile
29 index a268391..e5dae0e 100644
30 --- a/arch/mips/lantiq/Makefile
31 +++ b/arch/mips/lantiq/Makefile
32 @@ -4,7 +4,7 @@
33 # under the terms of the GNU General Public License version 2 as published
34 # by the Free Software Foundation.
35
36 -obj-y := irq.o setup.o clk.o prom.o
37 +obj-y := irq.o setup.o clk.o prom.o devices.o
38
39 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
40
41 diff --git a/arch/mips/lantiq/devices.c b/arch/mips/lantiq/devices.c
42 new file mode 100644
43 index 0000000..7b82c34
44 --- /dev/null
45 +++ b/arch/mips/lantiq/devices.c
46 @@ -0,0 +1,122 @@
47 +/*
48 + * This program is free software; you can redistribute it and/or modify it
49 + * under the terms of the GNU General Public License version 2 as published
50 + * by the Free Software Foundation.
51 + *
52 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
53 + */
54 +
55 +#include <linux/init.h>
56 +#include <linux/module.h>
57 +#include <linux/types.h>
58 +#include <linux/string.h>
59 +#include <linux/kernel.h>
60 +#include <linux/reboot.h>
61 +#include <linux/platform_device.h>
62 +#include <linux/leds.h>
63 +#include <linux/etherdevice.h>
64 +#include <linux/reboot.h>
65 +#include <linux/time.h>
66 +#include <linux/io.h>
67 +#include <linux/gpio.h>
68 +#include <linux/leds.h>
69 +
70 +#include <asm/bootinfo.h>
71 +#include <asm/irq.h>
72 +
73 +#include <lantiq_soc.h>
74 +
75 +#include "devices.h"
76 +
77 +/* nor flash */
78 +static struct resource ltq_nor_resource = {
79 + .name = "nor",
80 + .start = LTQ_FLASH_START,
81 + .end = LTQ_FLASH_START + LTQ_FLASH_MAX - 1,
82 + .flags = IORESOURCE_MEM,
83 +};
84 +
85 +static struct platform_device ltq_nor = {
86 + .name = "ltq_nor",
87 + .resource = &ltq_nor_resource,
88 + .num_resources = 1,
89 +};
90 +
91 +void __init ltq_register_nor(struct physmap_flash_data *data)
92 +{
93 + ltq_nor.dev.platform_data = data;
94 + platform_device_register(&ltq_nor);
95 +}
96 +
97 +/* watchdog */
98 +static struct resource ltq_wdt_resource = {
99 + .name = "watchdog",
100 + .start = LTQ_WDT_BASE_ADDR,
101 + .end = LTQ_WDT_BASE_ADDR + LTQ_WDT_SIZE - 1,
102 + .flags = IORESOURCE_MEM,
103 +};
104 +
105 +void __init ltq_register_wdt(void)
106 +{
107 + platform_device_register_simple("ltq_wdt", 0, &ltq_wdt_resource, 1);
108 +}
109 +
110 +/* asc ports */
111 +static struct resource ltq_asc0_resources[] = {
112 + {
113 + .name = "asc0",
114 + .start = LTQ_ASC0_BASE_ADDR,
115 + .end = LTQ_ASC0_BASE_ADDR + LTQ_ASC_SIZE - 1,
116 + .flags = IORESOURCE_MEM,
117 + },
118 + IRQ_RES(tx, LTQ_ASC_TIR(0)),
119 + IRQ_RES(rx, LTQ_ASC_RIR(0)),
120 + IRQ_RES(err, LTQ_ASC_EIR(0)),
121 +};
122 +
123 +static struct resource ltq_asc1_resources[] = {
124 + {
125 + .name = "asc1",
126 + .start = LTQ_ASC1_BASE_ADDR,
127 + .end = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
128 + .flags = IORESOURCE_MEM,
129 + },
130 + IRQ_RES(tx, LTQ_ASC_TIR(1)),
131 + IRQ_RES(rx, LTQ_ASC_RIR(1)),
132 + IRQ_RES(err, LTQ_ASC_EIR(1)),
133 +};
134 +
135 +void __init ltq_register_asc(int port)
136 +{
137 + switch (port) {
138 + case 0:
139 + platform_device_register_simple("ltq_asc", 0,
140 + ltq_asc0_resources, ARRAY_SIZE(ltq_asc0_resources));
141 + break;
142 + case 1:
143 + platform_device_register_simple("ltq_asc", 1,
144 + ltq_asc1_resources, ARRAY_SIZE(ltq_asc1_resources));
145 + break;
146 + default:
147 + break;
148 + }
149 +}
150 +
151 +#ifdef CONFIG_PCI
152 +/* pci */
153 +static struct platform_device ltq_pci = {
154 + .name = "ltq_pci",
155 + .num_resources = 0,
156 +};
157 +
158 +void __init ltq_register_pci(struct ltq_pci_data *data)
159 +{
160 + ltq_pci.dev.platform_data = data;
161 + platform_device_register(&ltq_pci);
162 +}
163 +#else
164 +void __init ltq_register_pci(struct ltq_pci_data *data)
165 +{
166 + pr_err("kernel is compiled without PCI support\n");
167 +}
168 +#endif
169 diff --git a/arch/mips/lantiq/devices.h b/arch/mips/lantiq/devices.h
170 new file mode 100644
171 index 0000000..2947bb1
172 --- /dev/null
173 +++ b/arch/mips/lantiq/devices.h
174 @@ -0,0 +1,23 @@
175 +/*
176 + * This program is free software; you can redistribute it and/or modify it
177 + * under the terms of the GNU General Public License version 2 as published
178 + * by the Free Software Foundation.
179 + *
180 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
181 + */
182 +
183 +#ifndef _LTQ_DEVICES_H__
184 +#define _LTQ_DEVICES_H__
185 +
186 +#include <lantiq_platform.h>
187 +#include <linux/mtd/physmap.h>
188 +
189 +#define IRQ_RES(resname, irq) \
190 + {.name = #resname, .start = (irq), .flags = IORESOURCE_IRQ}
191 +
192 +extern void ltq_register_nor(struct physmap_flash_data *data);
193 +extern void ltq_register_wdt(void);
194 +extern void ltq_register_asc(int port);
195 +extern void ltq_register_pci(struct ltq_pci_data *data);
196 +
197 +#endif
198 diff --git a/arch/mips/lantiq/xway/Makefile b/arch/mips/lantiq/xway/Makefile
199 index 9c85ff9..74ce438 100644
200 --- a/arch/mips/lantiq/xway/Makefile
201 +++ b/arch/mips/lantiq/xway/Makefile
202 @@ -1,4 +1,4 @@
203 -obj-y := pmu.o ebu.o reset.o gpio.o
204 +obj-y := pmu.o ebu.o reset.o gpio.o devices.o
205
206 obj-$(CONFIG_SOC_XWAY) += clk-xway.o prom-xway.o
207 obj-$(CONFIG_SOC_AMAZON_SE) += clk-ase.o prom-ase.o
208 diff --git a/arch/mips/lantiq/xway/devices.c b/arch/mips/lantiq/xway/devices.c
209 new file mode 100644
210 index 0000000..a71b3b5
211 --- /dev/null
212 +++ b/arch/mips/lantiq/xway/devices.c
213 @@ -0,0 +1,98 @@
214 +/*
215 + * This program is free software; you can redistribute it and/or modify it
216 + * under the terms of the GNU General Public License version 2 as published
217 + * by the Free Software Foundation.
218 + *
219 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
220 + */
221 +
222 +#include <linux/init.h>
223 +#include <linux/module.h>
224 +#include <linux/types.h>
225 +#include <linux/string.h>
226 +#include <linux/mtd/physmap.h>
227 +#include <linux/kernel.h>
228 +#include <linux/reboot.h>
229 +#include <linux/platform_device.h>
230 +#include <linux/leds.h>
231 +#include <linux/etherdevice.h>
232 +#include <linux/reboot.h>
233 +#include <linux/time.h>
234 +#include <linux/io.h>
235 +#include <linux/gpio.h>
236 +#include <linux/leds.h>
237 +
238 +#include <asm/bootinfo.h>
239 +#include <asm/irq.h>
240 +
241 +#include <lantiq_soc.h>
242 +#include <lantiq_irq.h>
243 +#include <lantiq_platform.h>
244 +
245 +#include "devices.h"
246 +
247 +/* gpio */
248 +static struct resource ltq_gpio_resource[] = {
249 + {
250 + .name = "gpio0",
251 + .start = LTQ_GPIO0_BASE_ADDR,
252 + .end = LTQ_GPIO0_BASE_ADDR + LTQ_GPIO_SIZE - 1,
253 + .flags = IORESOURCE_MEM,
254 + }, {
255 + .name = "gpio1",
256 + .start = LTQ_GPIO1_BASE_ADDR,
257 + .end = LTQ_GPIO1_BASE_ADDR + LTQ_GPIO_SIZE - 1,
258 + .flags = IORESOURCE_MEM,
259 + }, {
260 + .name = "gpio2",
261 + .start = LTQ_GPIO2_BASE_ADDR,
262 + .end = LTQ_GPIO2_BASE_ADDR + LTQ_GPIO_SIZE - 1,
263 + .flags = IORESOURCE_MEM,
264 + }
265 +};
266 +
267 +void __init ltq_register_gpio(void)
268 +{
269 + platform_device_register_simple("ltq_gpio", 0,
270 + &ltq_gpio_resource[0], 1);
271 + platform_device_register_simple("ltq_gpio", 1,
272 + &ltq_gpio_resource[1], 1);
273 +
274 + /* AR9 and VR9 have an extra gpio block */
275 + if (ltq_is_ar9() || ltq_is_vr9()) {
276 + platform_device_register_simple("ltq_gpio", 2,
277 + &ltq_gpio_resource[2], 1);
278 + }
279 +}
280 +
281 +/* serial to parallel conversion */
282 +static struct resource ltq_stp_resource = {
283 + .name = "stp",
284 + .start = LTQ_STP_BASE_ADDR,
285 + .end = LTQ_STP_BASE_ADDR + LTQ_STP_SIZE - 1,
286 + .flags = IORESOURCE_MEM,
287 +};
288 +
289 +void __init ltq_register_gpio_stp(void)
290 +{
291 + platform_device_register_simple("ltq_stp", 0, &ltq_stp_resource, 1);
292 +}
293 +
294 +/* asc ports - amazon se has its own serial mapping */
295 +static struct resource ltq_ase_asc_resources[] = {
296 + {
297 + .name = "asc0",
298 + .start = LTQ_ASC1_BASE_ADDR,
299 + .end = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
300 + .flags = IORESOURCE_MEM,
301 + },
302 + IRQ_RES(tx, LTQ_ASC_ASE_TIR),
303 + IRQ_RES(rx, LTQ_ASC_ASE_RIR),
304 + IRQ_RES(err, LTQ_ASC_ASE_EIR),
305 +};
306 +
307 +void __init ltq_register_ase_asc(void)
308 +{
309 + platform_device_register_simple("ltq_asc", 0,
310 + ltq_ase_asc_resources, ARRAY_SIZE(ltq_ase_asc_resources));
311 +}
312 diff --git a/arch/mips/lantiq/xway/devices.h b/arch/mips/lantiq/xway/devices.h
313 new file mode 100644
314 index 0000000..51f56b5
315 --- /dev/null
316 +++ b/arch/mips/lantiq/xway/devices.h
317 @@ -0,0 +1,18 @@
318 +/*
319 + * This program is free software; you can redistribute it and/or modify it
320 + * under the terms of the GNU General Public License version 2 as published
321 + * by the Free Software Foundation.
322 + *
323 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
324 + */
325 +
326 +#ifndef _LTQ_DEVICES_XWAY_H__
327 +#define _LTQ_DEVICES_XWAY_H__
328 +
329 +#include "../devices.h"
330 +
331 +extern void ltq_register_gpio(void);
332 +extern void ltq_register_gpio_stp(void);
333 +extern void ltq_register_ase_asc(void);
334 +
335 +#endif
336 --
337 1.7.2.3
338