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