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.
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
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>
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(+)
27 Index: linux-2.6.21.7/arch/arm/mach-ixp4xx/Kconfig
28 ===================================================================
29 --- linux-2.6.21.7.orig/arch/arm/mach-ixp4xx/Kconfig
30 +++ linux-2.6.21.7/arch/arm/mach-ixp4xx/Kconfig
31 @@ -89,6 +89,15 @@ config MACH_NAS100D
32 NAS 100d device. For more information on this platform,
33 see http://www.nslu2-linux.org/wiki/NAS100d/HomePage
37 + prompt "D-Link DSM-G600 RevA"
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
45 # Avila and IXDP share the same source for now. Will change in future
47 Index: linux-2.6.21.7/arch/arm/mach-ixp4xx/Makefile
48 ===================================================================
49 --- linux-2.6.21.7.orig/arch/arm/mach-ixp4xx/Makefile
50 +++ linux-2.6.21.7/arch/arm/mach-ixp4xx/Makefile
51 @@ -12,6 +12,7 @@ obj-pci-$(CONFIG_ARCH_ADI_COYOTE) += coy
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
59 @@ -22,5 +23,6 @@ obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-
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
65 obj-$(CONFIG_PCI) += $(obj-pci-$(CONFIG_PCI)) common-pci.o
66 Index: linux-2.6.21.7/arch/arm/mach-ixp4xx/dsmg600-pci.c
67 ===================================================================
69 +++ linux-2.6.21.7/arch/arm/mach-ixp4xx/dsmg600-pci.c
72 + * DSM-G600 board-level PCI initialization
74 + * Copyright (C) 2006 Tower Technologies
75 + * Author: Alessandro Zummo <a.zummo@towertech.it>
77 + * based on ixdp425-pci.c:
78 + * Copyright (C) 2002 Intel Corporation.
79 + * Copyright (C) 2003-2004 MontaVista Software, Inc.
81 + * Maintainer: http://www.nslu2-linux.org/
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.
89 +#include <linux/pci.h>
90 +#include <linux/init.h>
91 +#include <linux/irq.h>
93 +#include <asm/mach/pci.h>
94 +#include <asm/mach-types.h>
96 +void __init dsmg600_pci_preinit(void)
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);
105 + ixp4xx_pci_preinit();
108 +static int __init dsmg600_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
110 + static int pci_irq_table[DSMG600_PCI_MAX_DEV][DSMG600_PCI_IRQ_LINES] =
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 },
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];
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,
136 +int __init dsmg600_pci_init(void)
138 + if (machine_is_dsmg600())
139 + pci_common_init(&dsmg600_pci);
144 +subsys_initcall(dsmg600_pci_init);
145 Index: linux-2.6.21.7/arch/arm/mach-ixp4xx/dsmg600-power.c
146 ===================================================================
148 +++ linux-2.6.21.7/arch/arm/mach-ixp4xx/dsmg600-power.c
151 + * arch/arm/mach-ixp4xx/dsmg600-power.c
153 + * DSM-G600 Power/Reset driver
154 + * Author: Michael Westerhof <mwester@dls.net>
156 + * Based on nslu2-power.c
157 + * Copyright (C) 2005 Tower Technologies
158 + * Author: Alessandro Zummo <a.zummo@towertech.it>
160 + * which was based on nslu2-io.c
161 + * Copyright (C) 2004 Karen Spearel
163 + * Maintainers: http://www.nslu2-linux.org/
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.
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>
178 +#include <asm/mach-types.h>
180 +extern void ctrl_alt_del(void);
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.
185 +static volatile int power_button_countdown;
187 +/* Must hold the button down for at least this many counts to be processed */
188 +#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
190 +static void dsmg600_power_handler(unsigned long data);
191 +static DEFINE_TIMER(dsmg600_power_timer, dsmg600_power_handler, 0, 0);
193 +static void dsmg600_power_handler(unsigned long data)
195 + /* This routine is called twice per second to check the
196 + * state of the power button.
199 + if (*IXP4XX_GPIO_GPINR & DSMG600_PB_BM) {
201 + /* IO Pin is 1 (button pushed) */
202 + if (power_button_countdown > 0) {
203 + power_button_countdown--;
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.
215 + /* Change the state of the power LED to "blink" */
216 + gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
218 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
222 + mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
225 +static irqreturn_t dsmg600_reset_handler(int irq, void *dev_id)
227 + /* This is the paper-clip reset, it shuts the machine down directly. */
228 + machine_power_off();
230 + return IRQ_HANDLED;
233 +static int __init dsmg600_power_init(void)
235 + if (!(machine_is_dsmg600()))
238 + if (request_irq(DSMG600_RB_IRQ, &dsmg600_reset_handler,
239 + IRQF_DISABLED | IRQF_TRIGGER_LOW, "DSM-G600 reset button",
242 + printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
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.
253 + /* Make sure that the power button GPIO is set up as an input */
254 + gpio_line_config(DSMG600_PB_GPIO, IXP4XX_GPIO_IN);
256 + /* Set the initial value for the power button IRQ handler */
257 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
259 + mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
264 +static void __exit dsmg600_power_exit(void)
266 + if (!(machine_is_dsmg600()))
269 + del_timer_sync(&dsmg600_power_timer);
271 + free_irq(DSMG600_RB_IRQ, NULL);
274 +module_init(dsmg600_power_init);
275 +module_exit(dsmg600_power_exit);
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.7/arch/arm/mach-ixp4xx/dsmg600-setup.c
281 ===================================================================
283 +++ linux-2.6.21.7/arch/arm/mach-ixp4xx/dsmg600-setup.c
286 + * DSM-G600 board-setup
288 + * Copyright (C) 2006 Tower Technologies
289 + * Author: Alessandro Zummo <a.zummo@towertech.it>
291 + * based ixdp425-setup.c:
292 + * Copyright (C) 2003-2004 MontaVista Software, Inc.
294 + * Author: Alessandro Zummo <a.zummo@towertech.it>
295 + * Maintainers: http://www.nslu2-linux.org/
298 +#include <linux/kernel.h>
299 +#include <linux/serial.h>
300 +#include <linux/serial_8250.h>
302 +#include <asm/mach-types.h>
303 +#include <asm/mach/arch.h>
304 +#include <asm/mach/flash.h>
306 +static struct flash_platform_data dsmg600_flash_data = {
307 + .map_name = "cfi_probe",
311 +static struct resource dsmg600_flash_resource = {
312 + .flags = IORESOURCE_MEM,
315 +static struct platform_device dsmg600_flash = {
316 + .name = "IXP4XX-Flash",
318 + .dev.platform_data = &dsmg600_flash_data,
319 + .num_resources = 1,
320 + .resource = &dsmg600_flash_resource,
323 +static struct ixp4xx_i2c_pins dsmg600_i2c_gpio_pins = {
324 + .sda_pin = DSMG600_SDA_PIN,
325 + .scl_pin = DSMG600_SCL_PIN,
328 +static struct platform_device dsmg600_i2c_controller = {
329 + .name = "IXP4XX-I2C",
331 + .dev.platform_data = &dsmg600_i2c_gpio_pins,
334 +#ifdef CONFIG_LEDS_CLASS
335 +static struct resource dsmg600_led_resources[] = {
338 + .start = DSMG600_LED_PWR_GPIO,
339 + .end = DSMG600_LED_PWR_GPIO,
340 + .flags = IXP4XX_GPIO_HIGH,
344 + .start = DSMG600_LED_WLAN_GPIO,
345 + .end = DSMG600_LED_WLAN_GPIO,
346 + .flags = IXP4XX_GPIO_LOW,
350 +static struct platform_device dsmg600_leds = {
351 + .name = "IXP4XX-GPIO-LED",
353 + .num_resources = ARRAY_SIZE(dsmg600_led_resources),
354 + .resource = dsmg600_led_resources,
358 +static struct resource dsmg600_uart_resources[] = {
360 + .start = IXP4XX_UART1_BASE_PHYS,
361 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
362 + .flags = IORESOURCE_MEM,
365 + .start = IXP4XX_UART2_BASE_PHYS,
366 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
367 + .flags = IORESOURCE_MEM,
371 +static struct plat_serial8250_port dsmg600_uart_data[] = {
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,
379 + .uartclk = IXP4XX_UART_XTAL,
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,
388 + .uartclk = IXP4XX_UART_XTAL,
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,
401 +static struct platform_device *dsmg600_devices[] __initdata = {
402 + &dsmg600_i2c_controller,
406 +static void dsmg600_power_off(void)
408 + /* enable the pwr cntl gpio */
409 + gpio_line_config(DSMG600_PO_GPIO, IXP4XX_GPIO_OUT);
412 + gpio_line_set(DSMG600_PO_GPIO, IXP4XX_GPIO_HIGH);
415 +static void __init dsmg600_init(void)
419 + /* Make sure that GPIO14 and GPIO15 are not used as clocks */
420 + *IXP4XX_GPIO_GPCLKR = 0;
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;
426 + pm_power_off = dsmg600_power_off;
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!
432 + (void)platform_device_register(&dsmg600_uart);
434 + platform_add_devices(dsmg600_devices, ARRAY_SIZE(dsmg600_devices));
436 +#ifdef CONFIG_LEDS_CLASS
437 + /* We don't care whether or not this works. */
438 + (void)platform_device_register(&dsmg600_leds);
442 +static void __init dsmg600_fixup(struct machine_desc *desc,
443 + struct tag *tags, char **cmdline, struct meminfo *mi)
445 + /* The xtal on this machine is non-standard. */
446 + ixp4xx_timer_freq = DSMG600_FREQ;
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,
460 Index: linux-2.6.21.7/include/asm-arm/arch-ixp4xx/dsmg600.h
461 ===================================================================
463 +++ linux-2.6.21.7/include/asm-arm/arch-ixp4xx/dsmg600.h
466 + * DSM-G600 platform specific definitions
468 + * Copyright (C) 2006 Tower Technologies
469 + * Author: Alessandro Zummo <a.zummo@towertech.it>
471 + * based on ixdp425.h:
472 + * Copyright 2004 (C) MontaVista, Software, Inc.
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.
479 +#ifndef __ASM_ARCH_HARDWARE_H__
480 +#error "Do not include this directly, instead #include <asm/hardware.h>"
483 +#define DSMG600_SDA_PIN 5
484 +#define DSMG600_SCL_PIN 4
489 +#define DSMG600_PCI_MAX_DEV 4
490 +#define DSMG600_PCI_IRQ_LINES 3
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
501 +/* DSM-G600 Timer Setting */
502 +#define DSMG600_FREQ 66000000
506 +#define DSMG600_PB_GPIO 15 /* power button */
507 +#define DSMG600_PB_BM (1L << DSMG600_PB_GPIO)
509 +#define DSMG600_RB_GPIO 3 /* reset button */
511 +#define DSMG600_RB_IRQ IRQ_IXP4XX_GPIO3
513 +#define DSMG600_PO_GPIO 2 /* power off */
517 +#define DSMG600_LED_PWR_GPIO 0
518 +#define DSMG600_LED_PWR_BM (1L << DSMG600_LED_PWR_GPIO)
520 +#define DSMG600_LED_WLAN_GPIO 14
521 +#define DSMG600_LED_WLAN_BM (1L << DSMG600_LED_WLAN_GPIO)
522 Index: linux-2.6.21.7/include/asm-arm/arch-ixp4xx/hardware.h
523 ===================================================================
524 --- linux-2.6.21.7.orig/include/asm-arm/arch-ixp4xx/hardware.h
525 +++ linux-2.6.21.7/include/asm-arm/arch-ixp4xx/hardware.h
526 @@ -47,5 +47,6 @@ extern unsigned int processor_id;
527 #include "prpmc1100.h"
530 +#include "dsmg600.h"
532 #endif /* _ASM_ARCH_HARDWARE_H */
533 Index: linux-2.6.21.7/include/asm-arm/arch-ixp4xx/irqs.h
534 ===================================================================
535 --- linux-2.6.21.7.orig/include/asm-arm/arch-ixp4xx/irqs.h
536 +++ linux-2.6.21.7/include/asm-arm/arch-ixp4xx/irqs.h
538 #define IRQ_NAS100D_PCI_INTD IRQ_IXP4XX_GPIO8
539 #define IRQ_NAS100D_PCI_INTE IRQ_IXP4XX_GPIO7
542 + * D-Link DSM-G600 RevA board IRQs
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