diff options
Diffstat (limited to 'arch/arm/mach-ixp4xx/nslu2-setup.c')
-rw-r--r-- | arch/arm/mach-ixp4xx/nslu2-setup.c | 137 |
1 files changed, 112 insertions, 25 deletions
diff --git a/arch/arm/mach-ixp4xx/nslu2-setup.c b/arch/arm/mach-ixp4xx/nslu2-setup.c index 77277d27fcc5..acaebcbce53a 100644 --- a/arch/arm/mach-ixp4xx/nslu2-setup.c +++ b/arch/arm/mach-ixp4xx/nslu2-setup.c | |||
@@ -3,27 +3,35 @@ | |||
3 | * | 3 | * |
4 | * NSLU2 board-setup | 4 | * NSLU2 board-setup |
5 | * | 5 | * |
6 | * based ixdp425-setup.c: | 6 | * Copyright (C) 2008 Rod Whitby <rod@whitby.id.au> |
7 | * | ||
8 | * based on ixdp425-setup.c: | ||
7 | * Copyright (C) 2003-2004 MontaVista Software, Inc. | 9 | * Copyright (C) 2003-2004 MontaVista Software, Inc. |
10 | * based on nslu2-power.c: | ||
11 | * Copyright (C) 2005 Tower Technologies | ||
8 | * | 12 | * |
9 | * Author: Mark Rakes <mrakes at mac.com> | 13 | * Author: Mark Rakes <mrakes at mac.com> |
10 | * Author: Rod Whitby <rod@whitby.id.au> | 14 | * Author: Rod Whitby <rod@whitby.id.au> |
15 | * Author: Alessandro Zummo <a.zummo@towertech.it> | ||
11 | * Maintainers: http://www.nslu2-linux.org/ | 16 | * Maintainers: http://www.nslu2-linux.org/ |
12 | * | 17 | * |
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 | */ | 18 | */ |
16 | 19 | ||
17 | #include <linux/kernel.h> | 20 | #include <linux/if_ether.h> |
21 | #include <linux/irq.h> | ||
18 | #include <linux/serial.h> | 22 | #include <linux/serial.h> |
19 | #include <linux/serial_8250.h> | 23 | #include <linux/serial_8250.h> |
20 | #include <linux/leds.h> | 24 | #include <linux/leds.h> |
25 | #include <linux/reboot.h> | ||
26 | #include <linux/i2c.h> | ||
21 | #include <linux/i2c-gpio.h> | 27 | #include <linux/i2c-gpio.h> |
22 | 28 | ||
23 | #include <asm/mach-types.h> | 29 | #include <asm/mach-types.h> |
24 | #include <asm/mach/arch.h> | 30 | #include <asm/mach/arch.h> |
25 | #include <asm/mach/flash.h> | 31 | #include <asm/mach/flash.h> |
26 | #include <asm/mach/time.h> | 32 | #include <asm/mach/time.h> |
33 | #include <asm/io.h> | ||
34 | #include <asm/gpio.h> | ||
27 | 35 | ||
28 | static struct flash_platform_data nslu2_flash_data = { | 36 | static struct flash_platform_data nslu2_flash_data = { |
29 | .map_name = "cfi_probe", | 37 | .map_name = "cfi_probe", |
@@ -47,41 +55,43 @@ static struct i2c_gpio_platform_data nslu2_i2c_gpio_data = { | |||
47 | .scl_pin = NSLU2_SCL_PIN, | 55 | .scl_pin = NSLU2_SCL_PIN, |
48 | }; | 56 | }; |
49 | 57 | ||
50 | #ifdef CONFIG_LEDS_IXP4XX | 58 | static struct i2c_board_info __initdata nslu2_i2c_board_info [] = { |
51 | static struct resource nslu2_led_resources[] = { | 59 | { |
60 | I2C_BOARD_INFO("rtc-x1205", 0x6f), | ||
61 | }, | ||
62 | }; | ||
63 | |||
64 | static struct gpio_led nslu2_led_pins[] = { | ||
52 | { | 65 | { |
53 | .name = "ready", /* green led */ | 66 | .name = "ready", /* green led */ |
54 | .start = NSLU2_LED_GRN_GPIO, | 67 | .gpio = NSLU2_LED_GRN_GPIO, |
55 | .end = NSLU2_LED_GRN_GPIO, | ||
56 | .flags = IXP4XX_GPIO_HIGH, | ||
57 | }, | 68 | }, |
58 | { | 69 | { |
59 | .name = "status", /* red led */ | 70 | .name = "status", /* red led */ |
60 | .start = NSLU2_LED_RED_GPIO, | 71 | .gpio = NSLU2_LED_RED_GPIO, |
61 | .end = NSLU2_LED_RED_GPIO, | ||
62 | .flags = IXP4XX_GPIO_HIGH, | ||
63 | }, | 72 | }, |
64 | { | 73 | { |
65 | .name = "disk-1", | 74 | .name = "disk-1", |
66 | .start = NSLU2_LED_DISK1_GPIO, | 75 | .gpio = NSLU2_LED_DISK1_GPIO, |
67 | .end = NSLU2_LED_DISK1_GPIO, | 76 | .active_low = true, |
68 | .flags = IXP4XX_GPIO_LOW, | ||
69 | }, | 77 | }, |
70 | { | 78 | { |
71 | .name = "disk-2", | 79 | .name = "disk-2", |
72 | .start = NSLU2_LED_DISK2_GPIO, | 80 | .gpio = NSLU2_LED_DISK2_GPIO, |
73 | .end = NSLU2_LED_DISK2_GPIO, | 81 | .active_low = true, |
74 | .flags = IXP4XX_GPIO_LOW, | ||
75 | }, | 82 | }, |
76 | }; | 83 | }; |
77 | 84 | ||
85 | static struct gpio_led_platform_data nslu2_led_data = { | ||
86 | .num_leds = ARRAY_SIZE(nslu2_led_pins), | ||
87 | .leds = nslu2_led_pins, | ||
88 | }; | ||
89 | |||
78 | static struct platform_device nslu2_leds = { | 90 | static struct platform_device nslu2_leds = { |
79 | .name = "IXP4XX-GPIO-LED", | 91 | .name = "leds-gpio", |
80 | .id = -1, | 92 | .id = -1, |
81 | .num_resources = ARRAY_SIZE(nslu2_led_resources), | 93 | .dev.platform_data = &nslu2_led_data, |
82 | .resource = nslu2_led_resources, | ||
83 | }; | 94 | }; |
84 | #endif | ||
85 | 95 | ||
86 | static struct platform_device nslu2_i2c_gpio = { | 96 | static struct platform_device nslu2_i2c_gpio = { |
87 | .name = "i2c-gpio", | 97 | .name = "i2c-gpio", |
@@ -140,13 +150,29 @@ static struct platform_device nslu2_uart = { | |||
140 | .resource = nslu2_uart_resources, | 150 | .resource = nslu2_uart_resources, |
141 | }; | 151 | }; |
142 | 152 | ||
153 | /* Built-in 10/100 Ethernet MAC interfaces */ | ||
154 | static struct eth_plat_info nslu2_plat_eth[] = { | ||
155 | { | ||
156 | .phy = 1, | ||
157 | .rxq = 3, | ||
158 | .txreadyq = 20, | ||
159 | } | ||
160 | }; | ||
161 | |||
162 | static struct platform_device nslu2_eth[] = { | ||
163 | { | ||
164 | .name = "ixp4xx_eth", | ||
165 | .id = IXP4XX_ETH_NPEB, | ||
166 | .dev.platform_data = nslu2_plat_eth, | ||
167 | } | ||
168 | }; | ||
169 | |||
143 | static struct platform_device *nslu2_devices[] __initdata = { | 170 | static struct platform_device *nslu2_devices[] __initdata = { |
144 | &nslu2_i2c_gpio, | 171 | &nslu2_i2c_gpio, |
145 | &nslu2_flash, | 172 | &nslu2_flash, |
146 | &nslu2_beeper, | 173 | &nslu2_beeper, |
147 | #ifdef CONFIG_LEDS_IXP4XX | ||
148 | &nslu2_leds, | 174 | &nslu2_leds, |
149 | #endif | 175 | &nslu2_eth[0], |
150 | }; | 176 | }; |
151 | 177 | ||
152 | static void nslu2_power_off(void) | 178 | static void nslu2_power_off(void) |
@@ -160,6 +186,25 @@ static void nslu2_power_off(void) | |||
160 | gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH); | 186 | gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH); |
161 | } | 187 | } |
162 | 188 | ||
189 | static irqreturn_t nslu2_power_handler(int irq, void *dev_id) | ||
190 | { | ||
191 | /* Signal init to do the ctrlaltdel action, this will bypass init if | ||
192 | * it hasn't started and do a kernel_restart. | ||
193 | */ | ||
194 | ctrl_alt_del(); | ||
195 | |||
196 | return IRQ_HANDLED; | ||
197 | } | ||
198 | |||
199 | static irqreturn_t nslu2_reset_handler(int irq, void *dev_id) | ||
200 | { | ||
201 | /* This is the paper-clip reset, it shuts the machine down directly. | ||
202 | */ | ||
203 | machine_power_off(); | ||
204 | |||
205 | return IRQ_HANDLED; | ||
206 | } | ||
207 | |||
163 | static void __init nslu2_timer_init(void) | 208 | static void __init nslu2_timer_init(void) |
164 | { | 209 | { |
165 | /* The xtal on this machine is non-standard. */ | 210 | /* The xtal on this machine is non-standard. */ |
@@ -175,13 +220,18 @@ static struct sys_timer nslu2_timer = { | |||
175 | 220 | ||
176 | static void __init nslu2_init(void) | 221 | static void __init nslu2_init(void) |
177 | { | 222 | { |
223 | DECLARE_MAC_BUF(mac_buf); | ||
224 | uint8_t __iomem *f; | ||
225 | int i; | ||
226 | |||
178 | ixp4xx_sys_init(); | 227 | ixp4xx_sys_init(); |
179 | 228 | ||
180 | nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); | 229 | nslu2_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); |
181 | nslu2_flash_resource.end = | 230 | nslu2_flash_resource.end = |
182 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; | 231 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; |
183 | 232 | ||
184 | pm_power_off = nslu2_power_off; | 233 | i2c_register_board_info(0, nslu2_i2c_board_info, |
234 | ARRAY_SIZE(nslu2_i2c_board_info)); | ||
185 | 235 | ||
186 | /* | 236 | /* |
187 | * This is only useful on a modified machine, but it is valuable | 237 | * This is only useful on a modified machine, but it is valuable |
@@ -191,6 +241,43 @@ static void __init nslu2_init(void) | |||
191 | (void)platform_device_register(&nslu2_uart); | 241 | (void)platform_device_register(&nslu2_uart); |
192 | 242 | ||
193 | platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices)); | 243 | platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices)); |
244 | |||
245 | pm_power_off = nslu2_power_off; | ||
246 | |||
247 | if (request_irq(gpio_to_irq(NSLU2_RB_GPIO), &nslu2_reset_handler, | ||
248 | IRQF_DISABLED | IRQF_TRIGGER_LOW, | ||
249 | "NSLU2 reset button", NULL) < 0) { | ||
250 | |||
251 | printk(KERN_DEBUG "Reset Button IRQ %d not available\n", | ||
252 | gpio_to_irq(NSLU2_RB_GPIO)); | ||
253 | } | ||
254 | |||
255 | if (request_irq(gpio_to_irq(NSLU2_PB_GPIO), &nslu2_power_handler, | ||
256 | IRQF_DISABLED | IRQF_TRIGGER_HIGH, | ||
257 | "NSLU2 power button", NULL) < 0) { | ||
258 | |||
259 | printk(KERN_DEBUG "Power Button IRQ %d not available\n", | ||
260 | gpio_to_irq(NSLU2_PB_GPIO)); | ||
261 | } | ||
262 | |||
263 | /* | ||
264 | * Map in a portion of the flash and read the MAC address. | ||
265 | * Since it is stored in BE in the flash itself, we need to | ||
266 | * byteswap it if we're in LE mode. | ||
267 | */ | ||
268 | f = ioremap(IXP4XX_EXP_BUS_BASE(0), 0x40000); | ||
269 | if (f) { | ||
270 | for (i = 0; i < 6; i++) | ||
271 | #ifdef __ARMEB__ | ||
272 | nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + i); | ||
273 | #else | ||
274 | nslu2_plat_eth[0].hwaddr[i] = readb(f + 0x3FFB0 + (i^3)); | ||
275 | #endif | ||
276 | iounmap(f); | ||
277 | } | ||
278 | printk(KERN_INFO "NSLU2: Using MAC address %s for port 0\n", | ||
279 | print_mac(mac_buf, nslu2_plat_eth[0].hwaddr)); | ||
280 | |||
194 | } | 281 | } |
195 | 282 | ||
196 | MACHINE_START(NSLU2, "Linksys NSLU2") | 283 | MACHINE_START(NSLU2, "Linksys NSLU2") |