move ARM to the GNU EABI
[openwrt.git] / target / linux / ixp4xx / patches / 050-dsmg600_upstream_support.patch
1 This patch adds support for the D-Link DSM-G600 Rev A.
2 This is an ARM XScale IXP4xx system relatively similar to
3 the NSLU2 and NAS-100D already supported by mainline. An
4 important difference is Gigabit Ethernet support using
5 the Via Velocity chipset.
6
7 This patch is the combined work of Michael Westerhof and
8 Alessandro Zummo, with contributions from Michael-Luke
9 Jones. This version addresses review comments from rmk
10 and Deepak Saxena.
11
12 Signed-off-by: Michael-Luke Jones <mlj28@cam.ac.uk>
13 Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
14 Signed-off-by: Michael Westerhof <mwester@dls.net>
15
16 ---
17 arch/arm/mach-ixp4xx/Kconfig | 9 +
18 arch/arm/mach-ixp4xx/Makefile | 2
19 arch/arm/mach-ixp4xx/dsmg600-pci.c | 74 +++++++++++++
20 arch/arm/mach-ixp4xx/dsmg600-power.c | 130 ++++++++++++++++++++++++
21 arch/arm/mach-ixp4xx/dsmg600-setup.c | 175 +++++++++++++++++++++++++++++++++
22 include/asm-arm/arch-ixp4xx/dsmg600.h | 57 ++++++++++
23 include/asm-arm/arch-ixp4xx/hardware.h | 1
24 include/asm-arm/arch-ixp4xx/irqs.h | 10 +
25 8 files changed, 458 insertions(+)
26
27 Index: linux-2.6.21.1-armeb/arch/arm/mach-ixp4xx/Kconfig
28 ===================================================================
29 --- linux-2.6.21.1-armeb.orig/arch/arm/mach-ixp4xx/Kconfig
30 +++ linux-2.6.21.1-armeb/arch/arm/mach-ixp4xx/Kconfig
31 @@ -89,6 +89,15 @@
32 NAS 100d device. For more information on this platform,
33 see http://www.nslu2-linux.org/wiki/NAS100d/HomePage
34
35 +config MACH_DSMG600
36 + bool
37 + prompt "D-Link DSM-G600 RevA"
38 + select PCI
39 + help
40 + Say 'Y' here if you want your kernel to support D-Link's
41 + DSM-G600 RevA device. For more information on this platform,
42 + see http://www.nslu2-linux.org/wiki/DSMG600/HomePage
43 +
44 #
45 # Avila and IXDP share the same source for now. Will change in future
46 #
47 Index: linux-2.6.21.1-armeb/arch/arm/mach-ixp4xx/Makefile
48 ===================================================================
49 --- linux-2.6.21.1-armeb.orig/arch/arm/mach-ixp4xx/Makefile
50 +++ linux-2.6.21.1-armeb/arch/arm/mach-ixp4xx/Makefile
51 @@ -12,6 +12,7 @@
52 obj-pci-$(CONFIG_MACH_GTWX5715) += gtwx5715-pci.o
53 obj-pci-$(CONFIG_MACH_NSLU2) += nslu2-pci.o
54 obj-pci-$(CONFIG_MACH_NAS100D) += nas100d-pci.o
55 +obj-pci-$(CONFIG_MACH_DSMG600) += dsmg600-pci.o
56
57 obj-y += common.o
58
59 @@ -22,5 +23,6 @@
60 obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-setup.o
61 obj-$(CONFIG_MACH_NSLU2) += nslu2-setup.o nslu2-power.o
62 obj-$(CONFIG_MACH_NAS100D) += nas100d-setup.o nas100d-power.o
63 +obj-$(CONFIG_MACH_DSMG600) += dsmg600-setup.o dsmg600-power.o
64
65 obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o
66 Index: linux-2.6.21.1-armeb/arch/arm/mach-ixp4xx/dsmg600-pci.c
67 ===================================================================
68 --- /dev/null
69 +++ linux-2.6.21.1-armeb/arch/arm/mach-ixp4xx/dsmg600-pci.c
70 @@ -0,0 +1,74 @@
71 +/*
72 + * DSM-G600 board-level PCI initialization
73 + *
74 + * Copyright (C) 2006 Tower Technologies
75 + * Author: Alessandro Zummo <a.zummo@towertech.it>
76 + *
77 + * based on ixdp425-pci.c:
78 + * Copyright (C) 2002 Intel Corporation.
79 + * Copyright (C) 2003-2004 MontaVista Software, Inc.
80 + *
81 + * Maintainer: http://www.nslu2-linux.org/
82 + *
83 + * This program is free software; you can redistribute it and/or modify
84 + * it under the terms of the GNU General Public License version 2 as
85 + * published by the Free Software Foundation.
86 + *
87 + */
88 +
89 +#include <linux/pci.h>
90 +#include <linux/init.h>
91 +#include <linux/irq.h>
92 +
93 +#include <asm/mach/pci.h>
94 +#include <asm/mach-types.h>
95 +
96 +void __init dsmg600_pci_preinit(void)
97 +{
98 + set_irq_type(IRQ_DSMG600_PCI_INTA, IRQT_LOW);
99 + set_irq_type(IRQ_DSMG600_PCI_INTB, IRQT_LOW);
100 + set_irq_type(IRQ_DSMG600_PCI_INTC, IRQT_LOW);
101 + set_irq_type(IRQ_DSMG600_PCI_INTD, IRQT_LOW);
102 + set_irq_type(IRQ_DSMG600_PCI_INTE, IRQT_LOW);
103 + set_irq_type(IRQ_DSMG600_PCI_INTF, IRQT_LOW);
104 +
105 + ixp4xx_pci_preinit();
106 +}
107 +
108 +static int __init dsmg600_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
109 +{
110 + static int pci_irq_table[DSMG600_PCI_MAX_DEV][DSMG600_PCI_IRQ_LINES] =
111 + {
112 + { IRQ_DSMG600_PCI_INTE, -1, -1 },
113 + { IRQ_DSMG600_PCI_INTA, -1, -1 },
114 + { IRQ_DSMG600_PCI_INTB, IRQ_DSMG600_PCI_INTC, IRQ_DSMG600_PCI_INTD },
115 + { IRQ_DSMG600_PCI_INTF, -1, -1 },
116 + };
117 +
118 + int irq = -1;
119 +
120 + if (slot >= 1 && slot <= DSMG600_PCI_MAX_DEV &&
121 + pin >= 1 && pin <= DSMG600_PCI_IRQ_LINES)
122 + irq = pci_irq_table[slot-1][pin-1];
123 +
124 + return irq;
125 +}
126 +
127 +struct hw_pci __initdata dsmg600_pci = {
128 + .nr_controllers = 1,
129 + .preinit = dsmg600_pci_preinit,
130 + .swizzle = pci_std_swizzle,
131 + .setup = ixp4xx_setup,
132 + .scan = ixp4xx_scan_bus,
133 + .map_irq = dsmg600_map_irq,
134 +};
135 +
136 +int __init dsmg600_pci_init(void)
137 +{
138 + if (machine_is_dsmg600())
139 + pci_common_init(&dsmg600_pci);
140 +
141 + return 0;
142 +}
143 +
144 +subsys_initcall(dsmg600_pci_init);
145 Index: linux-2.6.21.1-armeb/arch/arm/mach-ixp4xx/dsmg600-power.c
146 ===================================================================
147 --- /dev/null
148 +++ linux-2.6.21.1-armeb/arch/arm/mach-ixp4xx/dsmg600-power.c
149 @@ -0,0 +1,130 @@
150 +/*
151 + * arch/arm/mach-ixp4xx/dsmg600-power.c
152 + *
153 + * DSM-G600 Power/Reset driver
154 + * Author: Michael Westerhof <mwester@dls.net>
155 + *
156 + * Based on nslu2-power.c
157 + * Copyright (C) 2005 Tower Technologies
158 + * Author: Alessandro Zummo <a.zummo@towertech.it>
159 + *
160 + * which was based on nslu2-io.c
161 + * Copyright (C) 2004 Karen Spearel
162 + *
163 + * Maintainers: http://www.nslu2-linux.org/
164 + *
165 + * This program is free software; you can redistribute it and/or modify
166 + * it under the terms of the GNU General Public License version 2 as
167 + * published by the Free Software Foundation.
168 + *
169 + */
170 +
171 +#include <linux/module.h>
172 +#include <linux/reboot.h>
173 +#include <linux/interrupt.h>
174 +#include <linux/irq.h>
175 +#include <linux/jiffies.h>
176 +#include <linux/timer.h>
177 +
178 +#include <asm/mach-types.h>
179 +
180 +extern void ctrl_alt_del(void);
181 +
182 +/* This is used to make sure the power-button pusher is serious. The button
183 + * must be held until the value of this counter reaches zero.
184 + */
185 +static volatile int power_button_countdown;
186 +
187 +/* Must hold the button down for at least this many counts to be processed */
188 +#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
189 +
190 +static void dsmg600_power_handler(unsigned long data);
191 +static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0);
192 +
193 +static void dsmg600_power_handler(unsigned long data)
194 +{
195 + /* This routine is called twice per second to check the
196 + * state of the power button.
197 + */
198 +
199 + if (*IXP4XX_GPIO_GPINR & DSMG600_PB_BM) {
200 +
201 + /* IO Pin is 1 (button pushed) */
202 + if (power_button_countdown > 0) {
203 + power_button_countdown--;
204 + }
205 +
206 + } else {
207 +
208 + /* Done on button release, to allow for auto-power-on mods. */
209 + if (power_button_countdown == 0) {
210 + /* Signal init to do the ctrlaltdel action, this will bypass
211 + * init if it hasn't started and do a kernel_restart.
212 + */
213 + ctrl_alt_del();
214 +
215 + /* Change the state of the power LED to "blink" */
216 + gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
217 + } else {
218 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
219 + }
220 + }
221 +
222 + mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
223 +}
224 +
225 +static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id)
226 +{
227 + /* This is the paper-clip reset, it shuts the machine down directly. */
228 + machine_power_off();
229 +
230 + return IRQ_HANDLED;
231 +}
232 +
233 +static int __init dsmg600_power_init(void)
234 +{
235 + if (!(machine_is_dsmg600()))
236 + return 0;
237 +
238 + if (request_irq(DSMG600_RB_IRQ, &dsmg600_reset_handler,
239 + IRQF_DISABLED | IRQF_TRIGGER_LOW, "DSM-G600 reset button",
240 + NULL) < 0) {
241 +
242 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
243 + DSMG600_RB_IRQ);
244 +
245 + return -EIO;
246 + }
247 +
248 + /* The power button on the D-Link DSM-G600 is on GPIO 15, but
249 + * it cannot handle interrupts on that GPIO line. So we'll
250 + * have to poll it with a kernel timer.
251 + */
252 +
253 + /* Make sure that the power button GPIO is set up as an input */
254 + gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN);
255 +
256 + /* Set the initial value for the power button IRQ handler */
257 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
258 +
259 + mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
260 +
261 + return 0;
262 +}
263 +
264 +static void __exit dsmg600_power_exit(void)
265 +{
266 + if (!(machine_is_dsmg600()))
267 + return;
268 +
269 + del_timer_sync(&dsmg600_power_timer);
270 +
271 + free_irq(DSMG600_RB_IRQ, NULL);
272 +}
273 +
274 +module_init(dsmg600_power_init);
275 +module_exit(dsmg600_power_exit);
276 +
277 +MODULE_AUTHOR("Michael Westerhof <mwester@dls.net>");
278 +MODULE_DESCRIPTION("DSM-G600 Power/Reset driver");
279 +MODULE_LICENSE("GPL");
280 Index: linux-2.6.21.1-armeb/arch/arm/mach-ixp4xx/dsmg600-setup.c
281 ===================================================================
282 --- /dev/null
283 +++ linux-2.6.21.1-armeb/arch/arm/mach-ixp4xx/dsmg600-setup.c
284 @@ -0,0 +1,175 @@
285 +/*
286 + * DSM-G600 board-setup
287 + *
288 + * Copyright (C) 2006 Tower Technologies
289 + * Author: Alessandro Zummo <a.zummo@towertech.it>
290 + *
291 + * based ixdp425-setup.c:
292 + * Copyright (C) 2003-2004 MontaVista Software, Inc.
293 + *
294 + * Author: Alessandro Zummo <a.zummo@towertech.it>
295 + * Maintainers: http://www.nslu2-linux.org/
296 + */
297 +
298 +#include <linux/kernel.h>
299 +#include <linux/serial.h>
300 +#include <linux/serial_8250.h>
301 +
302 +#include <asm/mach-types.h>
303 +#include <asm/mach/arch.h>
304 +#include <asm/mach/flash.h>
305 +
306 +static struct flash_platform_data dsmg600_flash_data = {
307 + .map_name = "cfi_probe",
308 + .width = 2,
309 +};
310 +
311 +static struct resource dsmg600_flash_resource = {
312 + .flags = IORESOURCE_MEM,
313 +};
314 +
315 +static struct platform_device dsmg600_flash = {
316 + .name = "IXP4XX-Flash",
317 + .id = 0,
318 + .dev.platform_data = &dsmg600_flash_data,
319 + .num_resources = 1,
320 + .resource = &dsmg600_flash_resource,
321 +};
322 +
323 +static struct ixp4xx_i2c_pins dsmg600_i2c_gpio_pins = {
324 + .sda_pin = DSMG600_SDA_PIN,
325 + .scl_pin = DSMG600_SCL_PIN,
326 +};
327 +
328 +static struct platform_device dsmg600_i2c_controller = {
329 + .name = "IXP4XX-I2C",
330 + .id = 0,
331 + .dev.platform_data = &dsmg600_i2c_gpio_pins,
332 +};
333 +
334 +#ifdef CONFIG_LEDS_CLASS
335 +static struct resource dsmg600_led_resources[] = {
336 + {
337 + .name = "power",
338 + .start = DSMG600_LED_PWR_GPIO,
339 + .end = DSMG600_LED_PWR_GPIO,
340 + .flags = IXP4XX_GPIO_HIGH,
341 + },
342 + {
343 + .name = "wlan",
344 + .start = DSMG600_LED_WLAN_GPIO,
345 + .end = DSMG600_LED_WLAN_GPIO,
346 + .flags = IXP4XX_GPIO_LOW,
347 + },
348 +};
349 +
350 +static struct platform_device dsmg600_leds = {
351 + .name = "IXP4XX-GPIO-LED",
352 + .id = -1,
353 + .num_resources = ARRAY_SIZE(dsmg600_led_resources),
354 + .resource = dsmg600_led_resources,
355 +};
356 +#endif
357 +
358 +static struct resource dsmg600_uart_resources[] = {
359 + {
360 + .start = IXP4XX_UART1_BASE_PHYS,
361 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
362 + .flags = IORESOURCE_MEM,
363 + },
364 + {
365 + .start = IXP4XX_UART2_BASE_PHYS,
366 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
367 + .flags = IORESOURCE_MEM,
368 + }
369 +};
370 +
371 +static struct plat_serial8250_port dsmg600_uart_data[] = {
372 + {
373 + .mapbase = IXP4XX_UART1_BASE_PHYS,
374 + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
375 + .irq = IRQ_IXP4XX_UART1,
376 + .flags = UPF_BOOT_AUTOCONF,
377 + .iotype = UPIO_MEM,
378 + .regshift = 2,
379 + .uartclk = IXP4XX_UART_XTAL,
380 + },
381 + {
382 + .mapbase = IXP4XX_UART2_BASE_PHYS,
383 + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
384 + .irq = IRQ_IXP4XX_UART2,
385 + .flags = UPF_BOOT_AUTOCONF,
386 + .iotype = UPIO_MEM,
387 + .regshift = 2,
388 + .uartclk = IXP4XX_UART_XTAL,
389 + },
390 + { }
391 +};
392 +
393 +static struct platform_device dsmg600_uart = {
394 + .name = "serial8250",
395 + .id = PLAT8250_DEV_PLATFORM,
396 + .dev.platform_data = dsmg600_uart_data,
397 + .num_resources = ARRAY_SIZE(dsmg600_uart_resources),
398 + .resource = dsmg600_uart_resources,
399 +};
400 +
401 +static struct platform_device *dsmg600_devices[] __initdata = {
402 + &dsmg600_i2c_controller,
403 + &dsmg600_flash,
404 +};
405 +
406 +static void dsmg600_power_off(void)
407 +{
408 + /* enable the pwr cntl gpio */
409 + gpio_line_config(DSMG600_PO_GPIO, IXP4XX_GPIO_OUT);
410 +
411 + /* poweroff */
412 + gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH);
413 +}
414 +
415 +static void __init dsmg600_init(void)
416 +{
417 + ixp4xx_sys_init();
418 +
419 + /* Make sure that GPIO14 and GPIO15 are not used as clocks */
420 + *IXP4XX_GPIO_GPCLKR = 0;
421 +
422 + dsmg600_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
423 + dsmg600_flash_resource.end =
424 + IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
425 +
426 + pm_power_off = dsmg600_power_off;
427 +
428 + /* The UART is required on the DSM-G600 (Redboot cannot use the
429 + * NIC) -- do it here so that it does *not* get removed if
430 + * platform_add_devices fails!
431 + */
432 + (void)platform_device_register(&dsmg600_uart);
433 +
434 + platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
435 +
436 +#ifdef CONFIG_LEDS_CLASS
437 + /* We don't care whether or not this works. */
438 + (void)platform_device_register(&dsmg600_leds);
439 +#endif
440 +}
441 +
442 +static void __init dsmg600_fixup(struct machine_desc *desc,
443 + struct tag *tags, char **cmdline, struct meminfo *mi)
444 +{
445 + /* The xtal on this machine is non-standard. */
446 + ixp4xx_timer_freq = DSMG600_FREQ;
447 +}
448 +
449 +MACHINE_START(DSMG600, "D-Link DSM-G600 RevA")
450 + /* Maintainer: www.nslu2-linux.org */
451 + .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS,
452 + .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
453 + .boot_params = 0x00000100,
454 + .fixup = dsmg600_fixup,
455 + .map_io = ixp4xx_map_io,
456 + .init_irq = ixp4xx_init_irq,
457 + .timer = &ixp4xx_timer,
458 + .init_machine = dsmg600_init,
459 +MACHINE_END
460 Index: linux-2.6.21.1-armeb/include/asm-arm/arch-ixp4xx/dsmg600.h
461 ===================================================================
462 --- /dev/null
463 +++ linux-2.6.21.1-armeb/include/asm-arm/arch-ixp4xx/dsmg600.h
464 @@ -0,0 +1,57 @@
465 +/*
466 + * DSM-G600 platform specific definitions
467 + *
468 + * Copyright (C) 2006 Tower Technologies
469 + * Author: Alessandro Zummo <a.zummo@towertech.it>
470 + *
471 + * based on ixdp425.h:
472 + * Copyright 2004 (C) MontaVista, Software, Inc.
473 + *
474 + * This file is licensed under the terms of the GNU General Public
475 + * License version 2. This program is licensed "as is" without any
476 + * warranty of any kind, whether express or implied.
477 + */
478 +
479 +#ifndef __ASM_ARCH_HARDWARE_H__
480 +#error "Do not include this directly, instead #include <asm/hardware.h>"
481 +#endif
482 +
483 +#define DSMG600_SDA_PIN 5
484 +#define DSMG600_SCL_PIN 4
485 +
486 +/*
487 + * DSMG600 PCI IRQs
488 + */
489 +#define DSMG600_PCI_MAX_DEV 4
490 +#define DSMG600_PCI_IRQ_LINES 3
491 +
492 +
493 +/* PCI controller GPIO to IRQ pin mappings */
494 +#define DSMG600_PCI_INTA_PIN 11
495 +#define DSMG600_PCI_INTB_PIN 10
496 +#define DSMG600_PCI_INTC_PIN 9
497 +#define DSMG600_PCI_INTD_PIN 8
498 +#define DSMG600_PCI_INTE_PIN 7
499 +#define DSMG600_PCI_INTF_PIN 6
500 +
501 +/* DSM-G600 Timer Setting */
502 +#define DSMG600_FREQ 66000000
503 +
504 +/* Buttons */
505 +
506 +#define DSMG600_PB_GPIO 15 /* power button */
507 +#define DSMG600_PB_BM (1L << DSMG600_PB_GPIO)
508 +
509 +#define DSMG600_RB_GPIO 3 /* reset button */
510 +
511 +#define DSMG600_RB_IRQ IRQ_IXP4XX_GPIO3
512 +
513 +#define DSMG600_PO_GPIO 2 /* power off */
514 +
515 +/* LEDs */
516 +
517 +#define DSMG600_LED_PWR_GPIO 0
518 +#define DSMG600_LED_PWR_BM (1L << DSMG600_LED_PWR_GPIO)
519 +
520 +#define DSMG600_LED_WLAN_GPIO 14
521 +#define DSMG600_LED_WLAN_BM (1L << DSMG600_LED_WLAN_GPIO)
522 Index: linux-2.6.21.1-armeb/include/asm-arm/arch-ixp4xx/hardware.h
523 ===================================================================
524 --- linux-2.6.21.1-armeb.orig/include/asm-arm/arch-ixp4xx/hardware.h
525 +++ linux-2.6.21.1-armeb/include/asm-arm/arch-ixp4xx/hardware.h
526 @@ -47,5 +47,6 @@
527 #include "prpmc1100.h"
528 #include "nslu2.h"
529 #include "nas100d.h"
530 +#include "dsmg600.h"
531
532 #endif /* _ASM_ARCH_HARDWARE_H */
533 Index: linux-2.6.21.1-armeb/include/asm-arm/arch-ixp4xx/irqs.h
534 ===================================================================
535 --- linux-2.6.21.1-armeb.orig/include/asm-arm/arch-ixp4xx/irqs.h
536 +++ linux-2.6.21.1-armeb/include/asm-arm/arch-ixp4xx/irqs.h
537 @@ -118,4 +118,14 @@
538 #define IRQ_NAS100D_PCI_INTD IRQ_IXP4XX_GPIO8
539 #define IRQ_NAS100D_PCI_INTE IRQ_IXP4XX_GPIO7
540
541 +/*
542 + * D-Link DSM-G600 RevA board IRQs
543 + */
544 +#define IRQ_DSMG600_PCI_INTA IRQ_IXP4XX_GPIO11
545 +#define IRQ_DSMG600_PCI_INTB IRQ_IXP4XX_GPIO10
546 +#define IRQ_DSMG600_PCI_INTC IRQ_IXP4XX_GPIO9
547 +#define IRQ_DSMG600_PCI_INTD IRQ_IXP4XX_GPIO8
548 +#define IRQ_DSMG600_PCI_INTE IRQ_IXP4XX_GPIO7
549 +#define IRQ_DSMG600_PCI_INTF IRQ_IXP4XX_GPIO6
550 +
551 #endif
This page took 0.067517 seconds and 5 git commands to generate.