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