Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mfashe...
[linux-2.6] / arch / arm / mach-ixp4xx / nslu2-setup.c
1 /*
2  * arch/arm/mach-ixp4xx/nslu2-setup.c
3  *
4  * NSLU2 board-setup
5  *
6  * based ixdp425-setup.c:
7  *      Copyright (C) 2003-2004 MontaVista Software, Inc.
8  *
9  * Author: Mark Rakes <mrakes at mac.com>
10  * Author: Rod Whitby <rod@whitby.id.au>
11  * Maintainers: http://www.nslu2-linux.org/
12  *
13  * Fixed missing init_time in MACHINE_START kas11 10/22/04
14  * Changed to conform to new style __init ixdp425 kas11 10/22/04
15  */
16
17 #include <linux/kernel.h>
18 #include <linux/serial.h>
19 #include <linux/serial_8250.h>
20 #include <linux/leds.h>
21
22 #include <asm/mach-types.h>
23 #include <asm/mach/arch.h>
24 #include <asm/mach/flash.h>
25
26 static struct flash_platform_data nslu2_flash_data = {
27         .map_name               = "cfi_probe",
28         .width                  = 2,
29 };
30
31 static struct resource nslu2_flash_resource = {
32         .flags                  = IORESOURCE_MEM,
33 };
34
35 static struct platform_device nslu2_flash = {
36         .name                   = "IXP4XX-Flash",
37         .id                     = 0,
38         .dev.platform_data      = &nslu2_flash_data,
39         .num_resources          = 1,
40         .resource               = &nslu2_flash_resource,
41 };
42
43 static struct ixp4xx_i2c_pins nslu2_i2c_gpio_pins = {
44         .sda_pin                = NSLU2_SDA_PIN,
45         .scl_pin                = NSLU2_SCL_PIN,
46 };
47
48 #ifdef CONFIG_LEDS_IXP4XX
49 static struct resource nslu2_led_resources[] = {
50         {
51                 .name           = "ready",  /* green led */
52                 .start          = NSLU2_LED_GRN,
53                 .end            = NSLU2_LED_GRN,
54                 .flags          = IXP4XX_GPIO_HIGH,
55         },
56         {
57                 .name           = "status", /* red led */
58                 .start          = NSLU2_LED_RED,
59                 .end            = NSLU2_LED_RED,
60                 .flags          = IXP4XX_GPIO_HIGH,
61         },
62         {
63                 .name           = "disk-1",
64                 .start          = NSLU2_LED_DISK1,
65                 .end            = NSLU2_LED_DISK1,
66                 .flags          = IXP4XX_GPIO_LOW,
67         },
68         {
69                 .name           = "disk-2",
70                 .start          = NSLU2_LED_DISK2,
71                 .end            = NSLU2_LED_DISK2,
72                 .flags          = IXP4XX_GPIO_LOW,
73         },
74 };
75
76 static struct platform_device nslu2_leds = {
77         .name                   = "IXP4XX-GPIO-LED",
78         .id                     = -1,
79         .num_resources          = ARRAY_SIZE(nslu2_led_resources),
80         .resource               = nslu2_led_resources,
81 };
82 #endif
83
84 static struct platform_device nslu2_i2c_controller = {
85         .name                   = "IXP4XX-I2C",
86         .id                     = 0,
87         .dev.platform_data      = &nslu2_i2c_gpio_pins,
88         .num_resources          = 0,
89 };
90
91 static struct platform_device nslu2_beeper = {
92         .name                   = "ixp4xx-beeper",
93         .id                     = NSLU2_GPIO_BUZZ,
94         .num_resources          = 0,
95 };
96
97 static struct resource nslu2_uart_resources[] = {
98         {
99                 .start          = IXP4XX_UART1_BASE_PHYS,
100                 .end            = IXP4XX_UART1_BASE_PHYS + 0x0fff,
101                 .flags          = IORESOURCE_MEM,
102         },
103         {
104                 .start          = IXP4XX_UART2_BASE_PHYS,
105                 .end            = IXP4XX_UART2_BASE_PHYS + 0x0fff,
106                 .flags          = IORESOURCE_MEM,
107         }
108 };
109
110 static struct plat_serial8250_port nslu2_uart_data[] = {
111         {
112                 .mapbase        = IXP4XX_UART1_BASE_PHYS,
113                 .membase        = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
114                 .irq            = IRQ_IXP4XX_UART1,
115                 .flags          = UPF_BOOT_AUTOCONF,
116                 .iotype         = UPIO_MEM,
117                 .regshift       = 2,
118                 .uartclk        = IXP4XX_UART_XTAL,
119         },
120         {
121                 .mapbase        = IXP4XX_UART2_BASE_PHYS,
122                 .membase        = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
123                 .irq            = IRQ_IXP4XX_UART2,
124                 .flags          = UPF_BOOT_AUTOCONF,
125                 .iotype         = UPIO_MEM,
126                 .regshift       = 2,
127                 .uartclk        = IXP4XX_UART_XTAL,
128         },
129         { }
130 };
131
132 static struct platform_device nslu2_uart = {
133         .name                   = "serial8250",
134         .id                     = PLAT8250_DEV_PLATFORM,
135         .dev.platform_data      = nslu2_uart_data,
136         .num_resources          = 2,
137         .resource               = nslu2_uart_resources,
138 };
139
140 static struct platform_device *nslu2_devices[] __initdata = {
141         &nslu2_i2c_controller,
142         &nslu2_flash,
143         &nslu2_beeper,
144 #ifdef CONFIG_LEDS_IXP4XX
145         &nslu2_leds,
146 #endif
147 };
148
149 static void nslu2_power_off(void)
150 {
151         /* This causes the box to drop the power and go dead. */
152
153         /* enable the pwr cntl gpio */
154         gpio_line_config(NSLU2_PO_GPIO, IXP4XX_GPIO_OUT);
155
156         /* do the deed */
157         gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
158 }
159
160 static void __init nslu2_init(void)
161 {
162         ixp4xx_sys_init();
163
164         nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
165         nslu2_flash_resource.end =
166                 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
167
168         pm_power_off = nslu2_power_off;
169
170         /* This is only useful on a modified machine, but it is valuable
171          * to have it first in order to see debug messages, and so that
172          * it does *not* get removed if platform_add_devices fails!
173          */
174         (void)platform_device_register(&nslu2_uart);
175
176         platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
177 }
178
179 MACHINE_START(NSLU2, "Linksys NSLU2")
180         /* Maintainer: www.nslu2-linux.org */
181         .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
182         .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
183         .boot_params    = 0x00000100,
184         .map_io         = ixp4xx_map_io,
185         .init_irq       = ixp4xx_init_irq,
186         .timer          = &ixp4xx_timer,
187         .init_machine   = nslu2_init,
188 MACHINE_END