1 From 67e494e3e03ef807255f084800d8658b89ff5fec Mon Sep 17 00:00:00 2001
2 From: Rod Whitby <rod@whitby.id.au>
3 Date: Tue, 29 Jan 2008 10:00:25 +1030
4 Subject: ixp4xx: Button updates for the dsmg600 board (Patch #4769)
6 * Remove the superfluous declaration of ctrl_alt_del().
7 * Convert GPIO and IRQ handling to use the <asm/gpio.h> api.
8 * Perform the reset on the release of the power button, so that
9 NAS devices which have been set to auto-power-on (by solder
10 bridging the power button) do not continuously power cycle.
11 * Remove all superflous constants from dsmg600.h
13 Signed-off-by: Rod Whitby <rod@whitby.id.au>
14 Acked-by: Lennert Buytenhek <buytenh@wantstofly.org>
17 KernelVersion: 2.6.24-git5
19 diff --git a/arch/arm/mach-ixp4xx/dsmg600-power.c b/arch/arm/mach-ixp4xx/dsmg600-power.c
20 index 3471787..db63987 100644
21 --- a/arch/arm/mach-ixp4xx/dsmg600-power.c
22 +++ b/arch/arm/mach-ixp4xx/dsmg600-power.c
24 #include <linux/jiffies.h>
25 #include <linux/timer.h>
27 +#include <asm/gpio.h>
28 #include <asm/mach-types.h>
30 -extern void ctrl_alt_del(void);
32 /* This is used to make sure the power-button pusher is serious. The button
33 * must be held until the value of this counter reaches zero.
35 -static volatile int power_button_countdown;
36 +static int power_button_countdown;
38 /* Must hold the button down for at least this many counts to be processed */
39 #define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
40 @@ -47,22 +46,27 @@ static void dsmg600_power_handler(unsigned long data)
41 * state of the power button.
44 - if (*IXP4XX_GPIO_GPINR & DSMG600_PB_BM) {
45 + if (gpio_get_value(DSMG600_PB_GPIO)) {
47 /* IO Pin is 1 (button pushed) */
48 + if (power_button_countdown > 0)
49 + power_button_countdown--;
53 + /* Done on button release, to allow for auto-power-on mods. */
54 if (power_button_countdown == 0) {
55 - /* Signal init to do the ctrlaltdel action, this will bypass
56 - * init if it hasn't started and do a kernel_restart.
57 + /* Signal init to do the ctrlaltdel action,
58 + * this will bypass init if it hasn't started
59 + * and do a kernel_restart.
63 /* Change the state of the power LED to "blink" */
64 gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
66 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
68 - power_button_countdown--;
71 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
74 mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
75 @@ -81,12 +85,12 @@ static int __init dsmg600_power_init(void)
76 if (!(machine_is_dsmg600()))
79 - if (request_irq(DSMG600_RB_IRQ, &dsmg600_reset_handler,
80 + if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
81 IRQF_DISABLED | IRQF_TRIGGER_LOW, "DSM-G600 reset button",
84 printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
86 + gpio_to_irq(DSMG600_RB_GPIO));
90 @@ -114,7 +118,7 @@ static void __exit dsmg600_power_exit(void)
92 del_timer_sync(&dsmg600_power_timer);
94 - free_irq(DSMG600_RB_IRQ, NULL);
95 + free_irq(gpio_to_irq(DSMG600_RB_GPIO), NULL);
98 module_init(dsmg600_power_init);
99 diff --git a/include/asm-arm/arch-ixp4xx/dsmg600.h b/include/asm-arm/arch-ixp4xx/dsmg600.h
100 index a19605a..b7673e1 100644
101 --- a/include/asm-arm/arch-ixp4xx/dsmg600.h
102 +++ b/include/asm-arm/arch-ixp4xx/dsmg600.h
106 #define DSMG600_PB_GPIO 15 /* power button */
107 -#define DSMG600_PB_BM (1L << DSMG600_PB_GPIO)
109 #define DSMG600_RB_GPIO 3 /* reset button */
111 -#define DSMG600_RB_IRQ IRQ_IXP4XX_GPIO3
114 #define DSMG600_PO_GPIO 2 /* power off */
118 #define DSMG600_LED_PWR_GPIO 0
119 -#define DSMG600_LED_PWR_BM (1L << DSMG600_LED_PWR_GPIO)
121 #define DSMG600_LED_WLAN_GPIO 14
122 -#define DSMG600_LED_WLAN_BM (1L << DSMG600_LED_WLAN_GPIO)