]> err.no Git - linux-2.6/blob - arch/arm/mach-ixp4xx/nslu2-setup.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild-fix
[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 #include <asm/mach/time.h>
26
27 static struct flash_platform_data nslu2_flash_data = {
28         .map_name               = "cfi_probe",
29         .width                  = 2,
30 };
31
32 static struct resource nslu2_flash_resource = {
33         .flags                  = IORESOURCE_MEM,
34 };
35
36 static struct platform_device nslu2_flash = {
37         .name                   = "IXP4XX-Flash",
38         .id                     = 0,
39         .dev.platform_data      = &nslu2_flash_data,
40         .num_resources          = 1,
41         .resource               = &nslu2_flash_resource,
42 };
43
44 static struct ixp4xx_i2c_pins nslu2_i2c_gpio_pins = {
45         .sda_pin                = NSLU2_SDA_PIN,
46         .scl_pin                = NSLU2_SCL_PIN,
47 };
48
49 #ifdef CONFIG_LEDS_IXP4XX
50 static struct resource nslu2_led_resources[] = {
51         {
52                 .name           = "ready",  /* green led */
53                 .start          = NSLU2_LED_GRN_GPIO,
54                 .end            = NSLU2_LED_GRN_GPIO,
55                 .flags          = IXP4XX_GPIO_HIGH,
56         },
57         {
58                 .name           = "status", /* red led */
59                 .start          = NSLU2_LED_RED_GPIO,
60                 .end            = NSLU2_LED_RED_GPIO,
61                 .flags          = IXP4XX_GPIO_HIGH,
62         },
63         {
64                 .name           = "disk-1",
65                 .start          = NSLU2_LED_DISK1_GPIO,
66                 .end            = NSLU2_LED_DISK1_GPIO,
67                 .flags          = IXP4XX_GPIO_LOW,
68         },
69         {
70                 .name           = "disk-2",
71                 .start          = NSLU2_LED_DISK2_GPIO,
72                 .end            = NSLU2_LED_DISK2_GPIO,
73                 .flags          = IXP4XX_GPIO_LOW,
74         },
75 };
76
77 static struct platform_device nslu2_leds = {
78         .name                   = "IXP4XX-GPIO-LED",
79         .id                     = -1,
80         .num_resources          = ARRAY_SIZE(nslu2_led_resources),
81         .resource               = nslu2_led_resources,
82 };
83 #endif
84
85 static struct platform_device nslu2_i2c_controller = {
86         .name                   = "IXP4XX-I2C",
87         .id                     = 0,
88         .dev.platform_data      = &nslu2_i2c_gpio_pins,
89         .num_resources          = 0,
90 };
91
92 static struct platform_device nslu2_beeper = {
93         .name                   = "ixp4xx-beeper",
94         .id                     = NSLU2_GPIO_BUZZ,
95         .num_resources          = 0,
96 };
97
98 static struct resource nslu2_uart_resources[] = {
99         {
100                 .start          = IXP4XX_UART1_BASE_PHYS,
101                 .end            = IXP4XX_UART1_BASE_PHYS + 0x0fff,
102                 .flags          = IORESOURCE_MEM,
103         },
104         {
105                 .start          = IXP4XX_UART2_BASE_PHYS,
106                 .end            = IXP4XX_UART2_BASE_PHYS + 0x0fff,
107                 .flags          = IORESOURCE_MEM,
108         }
109 };
110
111 static struct plat_serial8250_port nslu2_uart_data[] = {
112         {
113                 .mapbase        = IXP4XX_UART1_BASE_PHYS,
114                 .membase        = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
115                 .irq            = IRQ_IXP4XX_UART1,
116                 .flags          = UPF_BOOT_AUTOCONF,
117                 .iotype         = UPIO_MEM,
118                 .regshift       = 2,
119                 .uartclk        = IXP4XX_UART_XTAL,
120         },
121         {
122                 .mapbase        = IXP4XX_UART2_BASE_PHYS,
123                 .membase        = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
124                 .irq            = IRQ_IXP4XX_UART2,
125                 .flags          = UPF_BOOT_AUTOCONF,
126                 .iotype         = UPIO_MEM,
127                 .regshift       = 2,
128                 .uartclk        = IXP4XX_UART_XTAL,
129         },
130         { }
131 };
132
133 static struct platform_device nslu2_uart = {
134         .name                   = "serial8250",
135         .id                     = PLAT8250_DEV_PLATFORM,
136         .dev.platform_data      = nslu2_uart_data,
137         .num_resources          = 2,
138         .resource               = nslu2_uart_resources,
139 };
140
141 static struct platform_device *nslu2_devices[] __initdata = {
142         &nslu2_i2c_controller,
143         &nslu2_flash,
144         &nslu2_beeper,
145 #ifdef CONFIG_LEDS_IXP4XX
146         &nslu2_leds,
147 #endif
148 };
149
150 static void nslu2_power_off(void)
151 {
152         /* This causes the box to drop the power and go dead. */
153
154         /* enable the pwr cntl gpio */
155         gpio_line_config(NSLU2_PO_GPIO, IXP4XX_GPIO_OUT);
156
157         /* do the deed */
158         gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
159 }
160
161 static void __init nslu2_timer_init(void)
162 {
163     /* The xtal on this machine is non-standard. */
164     ixp4xx_timer_freq = NSLU2_FREQ;
165
166     /* Call standard timer_init function. */
167     ixp4xx_timer_init();
168 }
169
170 static struct sys_timer nslu2_timer = {
171     .init   = nslu2_timer_init,
172 };
173
174 static void __init nslu2_init(void)
175 {
176         ixp4xx_sys_init();
177
178         nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0);
179         nslu2_flash_resource.end =
180                 IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1;
181
182         pm_power_off = nslu2_power_off;
183
184         /*
185          * This is only useful on a modified machine, but it is valuable
186          * to have it first in order to see debug messages, and so that
187          * it does *not* get removed if platform_add_devices fails!
188          */
189         (void)platform_device_register(&nslu2_uart);
190
191         platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
192 }
193
194 MACHINE_START(NSLU2, "Linksys NSLU2")
195         /* Maintainer: www.nslu2-linux.org */
196         .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
197         .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
198         .boot_params    = 0x00000100,
199         .map_io         = ixp4xx_map_io,
200         .init_irq       = ixp4xx_init_irq,
201         .timer          = &nslu2_timer,
202         .init_machine   = nslu2_init,
203 MACHINE_END