diff options
Diffstat (limited to 'arch/arm/mach-ixp4xx/nas100d-setup.c')
-rw-r--r-- | arch/arm/mach-ixp4xx/nas100d-setup.c | 90 |
1 files changed, 86 insertions, 4 deletions
diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c index a432226b2050..4cecae84837b 100644 --- a/arch/arm/mach-ixp4xx/nas100d-setup.c +++ b/arch/arm/mach-ixp4xx/nas100d-setup.c | |||
@@ -3,8 +3,14 @@ | |||
3 | * | 3 | * |
4 | * NAS 100d board-setup | 4 | * NAS 100d 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 nas100d-power.c: | ||
11 | * Copyright (C) 2005 Tower Technologies | ||
12 | * based on nas100d-io.c | ||
13 | * Copyright (C) 2004 Karen Spearel | ||
8 | * | 14 | * |
9 | * Author: Alessandro Zummo <a.zummo@towertech.it> | 15 | * Author: Alessandro Zummo <a.zummo@towertech.it> |
10 | * Author: Rod Whitby <rod@whitby.id.au> | 16 | * Author: Rod Whitby <rod@whitby.id.au> |
@@ -13,10 +19,13 @@ | |||
13 | */ | 19 | */ |
14 | 20 | ||
15 | #include <linux/if_ether.h> | 21 | #include <linux/if_ether.h> |
16 | #include <linux/kernel.h> | 22 | #include <linux/irq.h> |
23 | #include <linux/jiffies.h> | ||
24 | #include <linux/timer.h> | ||
17 | #include <linux/serial.h> | 25 | #include <linux/serial.h> |
18 | #include <linux/serial_8250.h> | 26 | #include <linux/serial_8250.h> |
19 | #include <linux/leds.h> | 27 | #include <linux/leds.h> |
28 | #include <linux/reboot.h> | ||
20 | #include <linux/i2c.h> | 29 | #include <linux/i2c.h> |
21 | #include <linux/i2c-gpio.h> | 30 | #include <linux/i2c-gpio.h> |
22 | 31 | ||
@@ -24,6 +33,7 @@ | |||
24 | #include <asm/mach/arch.h> | 33 | #include <asm/mach/arch.h> |
25 | #include <asm/mach/flash.h> | 34 | #include <asm/mach/flash.h> |
26 | #include <asm/io.h> | 35 | #include <asm/io.h> |
36 | #include <asm/gpio.h> | ||
27 | 37 | ||
28 | static struct flash_platform_data nas100d_flash_data = { | 38 | static struct flash_platform_data nas100d_flash_data = { |
29 | .map_name = "cfi_probe", | 39 | .map_name = "cfi_probe", |
@@ -168,6 +178,57 @@ static void nas100d_power_off(void) | |||
168 | gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH); | 178 | gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH); |
169 | } | 179 | } |
170 | 180 | ||
181 | /* This is used to make sure the power-button pusher is serious. The button | ||
182 | * must be held until the value of this counter reaches zero. | ||
183 | */ | ||
184 | static int power_button_countdown; | ||
185 | |||
186 | /* Must hold the button down for at least this many counts to be processed */ | ||
187 | #define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */ | ||
188 | |||
189 | static void nas100d_power_handler(unsigned long data); | ||
190 | static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0); | ||
191 | |||
192 | static void nas100d_power_handler(unsigned long data) | ||
193 | { | ||
194 | /* This routine is called twice per second to check the | ||
195 | * state of the power button. | ||
196 | */ | ||
197 | |||
198 | if (gpio_get_value(NAS100D_PB_GPIO)) { | ||
199 | |||
200 | /* IO Pin is 1 (button pushed) */ | ||
201 | if (power_button_countdown > 0) | ||
202 | power_button_countdown--; | ||
203 | |||
204 | } else { | ||
205 | |||
206 | /* Done on button release, to allow for auto-power-on mods. */ | ||
207 | if (power_button_countdown == 0) { | ||
208 | /* Signal init to do the ctrlaltdel action, | ||
209 | * this will bypass init if it hasn't started | ||
210 | * and do a kernel_restart. | ||
211 | */ | ||
212 | ctrl_alt_del(); | ||
213 | |||
214 | /* Change the state of the power LED to "blink" */ | ||
215 | gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW); | ||
216 | } else { | ||
217 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500)); | ||
222 | } | ||
223 | |||
224 | static irqreturn_t nas100d_reset_handler(int irq, void *dev_id) | ||
225 | { | ||
226 | /* This is the paper-clip reset, it shuts the machine down directly. */ | ||
227 | machine_power_off(); | ||
228 | |||
229 | return IRQ_HANDLED; | ||
230 | } | ||
231 | |||
171 | static void __init nas100d_init(void) | 232 | static void __init nas100d_init(void) |
172 | { | 233 | { |
173 | DECLARE_MAC_BUF(mac_buf); | 234 | DECLARE_MAC_BUF(mac_buf); |
@@ -183,8 +244,6 @@ static void __init nas100d_init(void) | |||
183 | nas100d_flash_resource.end = | 244 | nas100d_flash_resource.end = |
184 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; | 245 | IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; |
185 | 246 | ||
186 | pm_power_off = nas100d_power_off; | ||
187 | |||
188 | i2c_register_board_info(0, nas100d_i2c_board_info, | 247 | i2c_register_board_info(0, nas100d_i2c_board_info, |
189 | ARRAY_SIZE(nas100d_i2c_board_info)); | 248 | ARRAY_SIZE(nas100d_i2c_board_info)); |
190 | 249 | ||
@@ -197,6 +256,29 @@ static void __init nas100d_init(void) | |||
197 | 256 | ||
198 | platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices)); | 257 | platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices)); |
199 | 258 | ||
259 | pm_power_off = nas100d_power_off; | ||
260 | |||
261 | if (request_irq(gpio_to_irq(NAS100D_RB_GPIO), &nas100d_reset_handler, | ||
262 | IRQF_DISABLED | IRQF_TRIGGER_LOW, | ||
263 | "NAS100D reset button", NULL) < 0) { | ||
264 | |||
265 | printk(KERN_DEBUG "Reset Button IRQ %d not available\n", | ||
266 | gpio_to_irq(NAS100D_RB_GPIO)); | ||
267 | } | ||
268 | |||
269 | /* The power button on the Iomega NAS100d is on GPIO 14, but | ||
270 | * it cannot handle interrupts on that GPIO line. So we'll | ||
271 | * have to poll it with a kernel timer. | ||
272 | */ | ||
273 | |||
274 | /* Make sure that the power button GPIO is set up as an input */ | ||
275 | gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN); | ||
276 | |||
277 | /* Set the initial value for the power button IRQ handler */ | ||
278 | power_button_countdown = PBUTTON_HOLDDOWN_COUNT; | ||
279 | |||
280 | mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500)); | ||
281 | |||
200 | /* | 282 | /* |
201 | * Map in a portion of the flash and read the MAC address. | 283 | * Map in a portion of the flash and read the MAC address. |
202 | * Since it is stored in BE in the flash itself, we need to | 284 | * Since it is stored in BE in the flash itself, we need to |