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
6 This patch adds the wrappers for registering our platform devices.
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>
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
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
33 # under the terms of the GNU General Public License version 2 as published
34 # by the Free Software Foundation.
36 -obj-y := irq.o setup.o clk.o prom.o
37 +obj-y := irq.o setup.o clk.o prom.o devices.o
39 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
41 diff --git a/arch/mips/lantiq/devices.c b/arch/mips/lantiq/devices.c
43 index 0000000..7b82c34
45 +++ b/arch/mips/lantiq/devices.c
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.
52 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
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>
70 +#include <asm/bootinfo.h>
73 +#include <lantiq_soc.h>
78 +static struct resource ltq_nor_resource = {
80 + .start = LTQ_FLASH_START,
81 + .end = LTQ_FLASH_START + LTQ_FLASH_MAX - 1,
82 + .flags = IORESOURCE_MEM,
85 +static struct platform_device ltq_nor = {
87 + .resource = <q_nor_resource,
91 +void __init ltq_register_nor(struct physmap_flash_data *data)
93 + ltq_nor.dev.platform_data = data;
94 + platform_device_register(<q_nor);
98 +static struct resource ltq_wdt_resource = {
100 + .start = LTQ_WDT_BASE_ADDR,
101 + .end = LTQ_WDT_BASE_ADDR + LTQ_WDT_SIZE - 1,
102 + .flags = IORESOURCE_MEM,
105 +void __init ltq_register_wdt(void)
107 + platform_device_register_simple("ltq_wdt", 0, <q_wdt_resource, 1);
111 +static struct resource ltq_asc0_resources[] = {
114 + .start = LTQ_ASC0_BASE_ADDR,
115 + .end = LTQ_ASC0_BASE_ADDR + LTQ_ASC_SIZE - 1,
116 + .flags = IORESOURCE_MEM,
118 + IRQ_RES(tx, LTQ_ASC_TIR(0)),
119 + IRQ_RES(rx, LTQ_ASC_RIR(0)),
120 + IRQ_RES(err, LTQ_ASC_EIR(0)),
123 +static struct resource ltq_asc1_resources[] = {
126 + .start = LTQ_ASC1_BASE_ADDR,
127 + .end = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
128 + .flags = IORESOURCE_MEM,
130 + IRQ_RES(tx, LTQ_ASC_TIR(1)),
131 + IRQ_RES(rx, LTQ_ASC_RIR(1)),
132 + IRQ_RES(err, LTQ_ASC_EIR(1)),
135 +void __init ltq_register_asc(int port)
139 + platform_device_register_simple("ltq_asc", 0,
140 + ltq_asc0_resources, ARRAY_SIZE(ltq_asc0_resources));
143 + platform_device_register_simple("ltq_asc", 1,
144 + ltq_asc1_resources, ARRAY_SIZE(ltq_asc1_resources));
153 +static struct platform_device ltq_pci = {
155 + .num_resources = 0,
158 +void __init ltq_register_pci(struct ltq_pci_data *data)
160 + ltq_pci.dev.platform_data = data;
161 + platform_device_register(<q_pci);
164 +void __init ltq_register_pci(struct ltq_pci_data *data)
166 + pr_err("kernel is compiled without PCI support\n");
169 diff --git a/arch/mips/lantiq/devices.h b/arch/mips/lantiq/devices.h
171 index 0000000..2947bb1
173 +++ b/arch/mips/lantiq/devices.h
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.
180 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
183 +#ifndef _LTQ_DEVICES_H__
184 +#define _LTQ_DEVICES_H__
186 +#include <lantiq_platform.h>
187 +#include <linux/mtd/physmap.h>
189 +#define IRQ_RES(resname, irq) \
190 + {.name = #resname, .start = (irq), .flags = IORESOURCE_IRQ}
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);
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
203 -obj-y := pmu.o ebu.o reset.o gpio.o
204 +obj-y := pmu.o ebu.o reset.o gpio.o devices.o
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
210 index 0000000..a71b3b5
212 +++ b/arch/mips/lantiq/xway/devices.c
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.
219 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
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>
238 +#include <asm/bootinfo.h>
239 +#include <asm/irq.h>
241 +#include <lantiq_soc.h>
242 +#include <lantiq_irq.h>
243 +#include <lantiq_platform.h>
245 +#include "devices.h"
248 +static struct resource ltq_gpio_resource[] = {
251 + .start = LTQ_GPIO0_BASE_ADDR,
252 + .end = LTQ_GPIO0_BASE_ADDR + LTQ_GPIO_SIZE - 1,
253 + .flags = IORESOURCE_MEM,
256 + .start = LTQ_GPIO1_BASE_ADDR,
257 + .end = LTQ_GPIO1_BASE_ADDR + LTQ_GPIO_SIZE - 1,
258 + .flags = IORESOURCE_MEM,
261 + .start = LTQ_GPIO2_BASE_ADDR,
262 + .end = LTQ_GPIO2_BASE_ADDR + LTQ_GPIO_SIZE - 1,
263 + .flags = IORESOURCE_MEM,
267 +void __init ltq_register_gpio(void)
269 + platform_device_register_simple("ltq_gpio", 0,
270 + <q_gpio_resource[0], 1);
271 + platform_device_register_simple("ltq_gpio", 1,
272 + <q_gpio_resource[1], 1);
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 + <q_gpio_resource[2], 1);
281 +/* serial to parallel conversion */
282 +static struct resource ltq_stp_resource = {
284 + .start = LTQ_STP_BASE_ADDR,
285 + .end = LTQ_STP_BASE_ADDR + LTQ_STP_SIZE - 1,
286 + .flags = IORESOURCE_MEM,
289 +void __init ltq_register_gpio_stp(void)
291 + platform_device_register_simple("ltq_stp", 0, <q_stp_resource, 1);
294 +/* asc ports - amazon se has its own serial mapping */
295 +static struct resource ltq_ase_asc_resources[] = {
298 + .start = LTQ_ASC1_BASE_ADDR,
299 + .end = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
300 + .flags = IORESOURCE_MEM,
302 + IRQ_RES(tx, LTQ_ASC_ASE_TIR),
303 + IRQ_RES(rx, LTQ_ASC_ASE_RIR),
304 + IRQ_RES(err, LTQ_ASC_ASE_EIR),
307 +void __init ltq_register_ase_asc(void)
309 + platform_device_register_simple("ltq_asc", 0,
310 + ltq_ase_asc_resources, ARRAY_SIZE(ltq_ase_asc_resources));
312 diff --git a/arch/mips/lantiq/xway/devices.h b/arch/mips/lantiq/xway/devices.h
314 index 0000000..51f56b5
316 +++ b/arch/mips/lantiq/xway/devices.h
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.
323 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
326 +#ifndef _LTQ_DEVICES_XWAY_H__
327 +#define _LTQ_DEVICES_XWAY_H__
329 +#include "../devices.h"
331 +extern void ltq_register_gpio(void);
332 +extern void ltq_register_gpio_stp(void);
333 +extern void ltq_register_ase_asc(void);