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 --- a/arch/mips/lantiq/Makefile
29 +++ b/arch/mips/lantiq/Makefile
31 # under the terms of the GNU General Public License version 2 as published
32 # by the Free Software Foundation.
34 -obj-y := irq.o setup.o clk.o prom.o
35 +obj-y := irq.o setup.o clk.o prom.o devices.o
37 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
40 +++ b/arch/mips/lantiq/devices.c
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.
47 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
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>
65 +#include <asm/bootinfo.h>
68 +#include <lantiq_soc.h>
73 +static struct resource ltq_nor_resource = {
75 + .start = LTQ_FLASH_START,
76 + .end = LTQ_FLASH_START + LTQ_FLASH_MAX - 1,
77 + .flags = IORESOURCE_MEM,
80 +static struct platform_device ltq_nor = {
82 + .resource = <q_nor_resource,
86 +void __init ltq_register_nor(struct physmap_flash_data *data)
88 + ltq_nor.dev.platform_data = data;
89 + platform_device_register(<q_nor);
93 +static struct resource ltq_wdt_resource = {
95 + .start = LTQ_WDT_BASE_ADDR,
96 + .end = LTQ_WDT_BASE_ADDR + LTQ_WDT_SIZE - 1,
97 + .flags = IORESOURCE_MEM,
100 +void __init ltq_register_wdt(void)
102 + platform_device_register_simple("ltq_wdt", 0, <q_wdt_resource, 1);
106 +static struct resource ltq_asc0_resources[] = {
109 + .start = LTQ_ASC0_BASE_ADDR,
110 + .end = LTQ_ASC0_BASE_ADDR + LTQ_ASC_SIZE - 1,
111 + .flags = IORESOURCE_MEM,
113 + IRQ_RES(tx, LTQ_ASC_TIR(0)),
114 + IRQ_RES(rx, LTQ_ASC_RIR(0)),
115 + IRQ_RES(err, LTQ_ASC_EIR(0)),
118 +static struct resource ltq_asc1_resources[] = {
121 + .start = LTQ_ASC1_BASE_ADDR,
122 + .end = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
123 + .flags = IORESOURCE_MEM,
125 + IRQ_RES(tx, LTQ_ASC_TIR(1)),
126 + IRQ_RES(rx, LTQ_ASC_RIR(1)),
127 + IRQ_RES(err, LTQ_ASC_EIR(1)),
130 +void __init ltq_register_asc(int port)
134 + platform_device_register_simple("ltq_asc", 0,
135 + ltq_asc0_resources, ARRAY_SIZE(ltq_asc0_resources));
138 + platform_device_register_simple("ltq_asc", 1,
139 + ltq_asc1_resources, ARRAY_SIZE(ltq_asc1_resources));
148 +static struct platform_device ltq_pci = {
150 + .num_resources = 0,
153 +void __init ltq_register_pci(struct ltq_pci_data *data)
155 + ltq_pci.dev.platform_data = data;
156 + platform_device_register(<q_pci);
159 +void __init ltq_register_pci(struct ltq_pci_data *data)
161 + pr_err("kernel is compiled without PCI support\n");
165 +++ b/arch/mips/lantiq/devices.h
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.
172 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
175 +#ifndef _LTQ_DEVICES_H__
176 +#define _LTQ_DEVICES_H__
178 +#include <lantiq_platform.h>
179 +#include <linux/mtd/physmap.h>
181 +#define IRQ_RES(resname, irq) \
182 + {.name = #resname, .start = (irq), .flags = IORESOURCE_IRQ}
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);
190 --- a/arch/mips/lantiq/xway/Makefile
191 +++ b/arch/mips/lantiq/xway/Makefile
193 -obj-y := pmu.o ebu.o reset.o gpio.o
194 +obj-y := pmu.o ebu.o reset.o gpio.o devices.o
196 obj-$(CONFIG_SOC_XWAY) += clk-xway.o prom-xway.o
197 obj-$(CONFIG_SOC_AMAZON_SE) += clk-ase.o prom-ase.o
199 +++ b/arch/mips/lantiq/xway/devices.c
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.
206 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
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>
225 +#include <asm/bootinfo.h>
226 +#include <asm/irq.h>
228 +#include <lantiq_soc.h>
229 +#include <lantiq_irq.h>
230 +#include <lantiq_platform.h>
232 +#include "devices.h"
235 +static struct resource ltq_gpio_resource[] = {
238 + .start = LTQ_GPIO0_BASE_ADDR,
239 + .end = LTQ_GPIO0_BASE_ADDR + LTQ_GPIO_SIZE - 1,
240 + .flags = IORESOURCE_MEM,
243 + .start = LTQ_GPIO1_BASE_ADDR,
244 + .end = LTQ_GPIO1_BASE_ADDR + LTQ_GPIO_SIZE - 1,
245 + .flags = IORESOURCE_MEM,
248 + .start = LTQ_GPIO2_BASE_ADDR,
249 + .end = LTQ_GPIO2_BASE_ADDR + LTQ_GPIO_SIZE - 1,
250 + .flags = IORESOURCE_MEM,
254 +void __init ltq_register_gpio(void)
256 + platform_device_register_simple("ltq_gpio", 0,
257 + <q_gpio_resource[0], 1);
258 + platform_device_register_simple("ltq_gpio", 1,
259 + <q_gpio_resource[1], 1);
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 + <q_gpio_resource[2], 1);
268 +/* serial to parallel conversion */
269 +static struct resource ltq_stp_resource = {
271 + .start = LTQ_STP_BASE_ADDR,
272 + .end = LTQ_STP_BASE_ADDR + LTQ_STP_SIZE - 1,
273 + .flags = IORESOURCE_MEM,
276 +void __init ltq_register_gpio_stp(void)
278 + platform_device_register_simple("ltq_stp", 0, <q_stp_resource, 1);
281 +/* asc ports - amazon se has its own serial mapping */
282 +static struct resource ltq_ase_asc_resources[] = {
285 + .start = LTQ_ASC1_BASE_ADDR,
286 + .end = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1,
287 + .flags = IORESOURCE_MEM,
289 + IRQ_RES(tx, LTQ_ASC_ASE_TIR),
290 + IRQ_RES(rx, LTQ_ASC_ASE_RIR),
291 + IRQ_RES(err, LTQ_ASC_ASE_EIR),
294 +void __init ltq_register_ase_asc(void)
296 + platform_device_register_simple("ltq_asc", 0,
297 + ltq_ase_asc_resources, ARRAY_SIZE(ltq_ase_asc_resources));
300 +++ b/arch/mips/lantiq/xway/devices.h
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.
307 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
310 +#ifndef _LTQ_DEVICES_XWAY_H__
311 +#define _LTQ_DEVICES_XWAY_H__
313 +#include "../devices.h"
315 +extern void ltq_register_gpio(void);
316 +extern void ltq_register_gpio_stp(void);
317 +extern void ltq_register_ase_asc(void);