cpmac: fix race condition (closes #3019)
[openwrt.git] / target / linux / ixp4xx / patches-2.6.23 / 016-dsmg600_auto_power_on.patch
1 Upgrade the power and reset button handling for the DSMG600:
2 * Remove the superfluous declaration of ctrl_alt_del().
3 * Convert GPIO and IRQ handling to use the <asm/gpio.h> api.
4 * Perform the reset on the release of the power button, so that
5 NAS devices which have been set to auto-power-on (by bridging
6 the power button) do not continuously power cycle.
7 * Remove all superflous constants from dsmg600.h
8
9 Signed-off-by: Rod Whitby <rod@whitby.id.au>
10
11 ---
12 arch/arm/mach-ixp4xx/dsmg600-power.c | 24 ++++++++++++++----------
13 include/asm-arm/arch-ixp4xx/dsmg600.h | 7 +------
14 2 files changed, 15 insertions(+), 16 deletions(-)
15
16 Index: linux-2.6.23.12-armeb/arch/arm/mach-ixp4xx/dsmg600-power.c
17 ===================================================================
18 --- linux-2.6.23.12-armeb.orig/arch/arm/mach-ixp4xx/dsmg600-power.c 2008-01-11 16:20:26.000000000 +1030
19 +++ linux-2.6.23.12-armeb/arch/arm/mach-ixp4xx/dsmg600-power.c 2008-01-11 16:20:30.000000000 +1030
20 @@ -26,10 +26,9 @@
21 #include <linux/jiffies.h>
22 #include <linux/timer.h>
23
24 +#include <asm/gpio.h>
25 #include <asm/mach-types.h>
26
27 -extern void ctrl_alt_del(void);
28 -
29 /* This is used to make sure the power-button pusher is serious. The button
30 * must be held until the value of this counter reaches zero.
31 */
32 @@ -47,9 +46,16 @@
33 * state of the power button.
34 */
35
36 - if (*IXP4XX_GPIO_GPINR & DSMG600_PB_BM) {
37 + if (gpio_get_value(DSMG600_PB_GPIO)) {
38
39 /* IO Pin is 1 (button pushed) */
40 + if (power_button_countdown > 0) {
41 + power_button_countdown--;
42 + }
43 +
44 + } else {
45 +
46 + /* Done on button release, to allow for auto-power-on mods. */
47 if (power_button_countdown == 0) {
48 /* Signal init to do the ctrlaltdel action, this will bypass
49 * init if it hasn't started and do a kernel_restart.
50 @@ -58,11 +64,9 @@
51
52 /* Change the state of the power LED to "blink" */
53 gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
54 + } else {
55 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
56 }
57 - power_button_countdown--;
58 -
59 - } else {
60 - power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
61 }
62
63 mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
64 @@ -81,12 +85,12 @@
65 if (!(machine_is_dsmg600()))
66 return 0;
67
68 - if (request_irq(DSMG600_RB_IRQ, &dsmg600_reset_handler,
69 + if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
70 IRQF_DISABLED | IRQF_TRIGGER_LOW, "DSM-G600 reset button",
71 NULL) < 0) {
72
73 printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
74 - DSMG600_RB_IRQ);
75 + gpio_to_irq(DSMG600_RB_GPIO));
76
77 return -EIO;
78 }
79 @@ -114,7 +118,7 @@
80
81 del_timer_sync(&dsmg600_power_timer);
82
83 - free_irq(DSMG600_RB_IRQ, NULL);
84 + free_irq(gpio_to_irq(DSMG600_RB_GPIO), NULL);
85 }
86
87 module_init(dsmg600_power_init);
88 Index: linux-2.6.23.12-armeb/include/asm-arm/arch-ixp4xx/dsmg600.h
89 ===================================================================
90 --- linux-2.6.23.12-armeb.orig/include/asm-arm/arch-ixp4xx/dsmg600.h 2008-01-11 16:20:26.000000000 +1030
91 +++ linux-2.6.23.12-armeb/include/asm-arm/arch-ixp4xx/dsmg600.h 2008-01-11 16:20:30.000000000 +1030
92 @@ -40,18 +40,13 @@
93 /* Buttons */
94
95 #define DSMG600_PB_GPIO 15 /* power button */
96 -#define DSMG600_PB_BM (1L << DSMG600_PB_GPIO)
97 -
98 #define DSMG600_RB_GPIO 3 /* reset button */
99
100 -#define DSMG600_RB_IRQ IRQ_IXP4XX_GPIO3
101 +/* Power control */
102
103 #define DSMG600_PO_GPIO 2 /* power off */
104
105 /* LEDs */
106
107 #define DSMG600_LED_PWR_GPIO 0
108 -#define DSMG600_LED_PWR_BM (1L << DSMG600_LED_PWR_GPIO)
109 -
110 #define DSMG600_LED_WLAN_GPIO 14
111 -#define DSMG600_LED_WLAN_BM (1L << DSMG600_LED_WLAN_GPIO)
This page took 0.047761 seconds and 5 git commands to generate.