aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-ixp4xx/dsmg600-power.c30
-rw-r--r--include/asm-arm/arch-ixp4xx/dsmg600.h7
2 files changed, 18 insertions, 19 deletions
diff --git a/arch/arm/mach-ixp4xx/dsmg600-power.c b/arch/arm/mach-ixp4xx/dsmg600-power.c
index 34717872d076..db6398777124 100644
--- a/arch/arm/mach-ixp4xx/dsmg600-power.c
+++ b/arch/arm/mach-ixp4xx/dsmg600-power.c
@@ -26,14 +26,13 @@
26#include <linux/jiffies.h> 26#include <linux/jiffies.h>
27#include <linux/timer.h> 27#include <linux/timer.h>
28 28
29#include <asm/gpio.h>
29#include <asm/mach-types.h> 30#include <asm/mach-types.h>
30 31
31extern void ctrl_alt_del(void);
32
33/* This is used to make sure the power-button pusher is serious. The button 32/* This is used to make sure the power-button pusher is serious. The button
34 * must be held until the value of this counter reaches zero. 33 * must be held until the value of this counter reaches zero.
35 */ 34 */
36static volatile int power_button_countdown; 35static int power_button_countdown;
37 36
38/* Must hold the button down for at least this many counts to be processed */ 37/* Must hold the button down for at least this many counts to be processed */
39#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */ 38#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
@@ -47,22 +46,27 @@ static void dsmg600_power_handler(unsigned long data)
47 * state of the power button. 46 * state of the power button.
48 */ 47 */
49 48
50 if (*IXP4XX_GPIO_GPINR & DSMG600_PB_BM) { 49 if (gpio_get_value(DSMG600_PB_GPIO)) {
51 50
52 /* IO Pin is 1 (button pushed) */ 51 /* IO Pin is 1 (button pushed) */
52 if (power_button_countdown > 0)
53 power_button_countdown--;
54
55 } else {
56
57 /* Done on button release, to allow for auto-power-on mods. */
53 if (power_button_countdown == 0) { 58 if (power_button_countdown == 0) {
54 /* Signal init to do the ctrlaltdel action, this will bypass 59 /* Signal init to do the ctrlaltdel action,
55 * init if it hasn't started and do a kernel_restart. 60 * this will bypass init if it hasn't started
61 * and do a kernel_restart.
56 */ 62 */
57 ctrl_alt_del(); 63 ctrl_alt_del();
58 64
59 /* Change the state of the power LED to "blink" */ 65 /* Change the state of the power LED to "blink" */
60 gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW); 66 gpio_line_set(DSMG600_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
67 } else {
68 power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
61 } 69 }
62 power_button_countdown--;
63
64 } else {
65 power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
66 } 70 }
67 71
68 mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500)); 72 mod_timer(&dsmg600_power_timer, jiffies + msecs_to_jiffies(500));
@@ -81,12 +85,12 @@ static int __init dsmg600_power_init(void)
81 if (!(machine_is_dsmg600())) 85 if (!(machine_is_dsmg600()))
82 return 0; 86 return 0;
83 87
84 if (request_irq(DSMG600_RB_IRQ, &dsmg600_reset_handler, 88 if (request_irq(gpio_to_irq(DSMG600_RB_GPIO), &dsmg600_reset_handler,
85 IRQF_DISABLED | IRQF_TRIGGER_LOW, "DSM-G600 reset button", 89 IRQF_DISABLED | IRQF_TRIGGER_LOW, "DSM-G600 reset button",
86 NULL) < 0) { 90 NULL) < 0) {
87 91
88 printk(KERN_DEBUG "Reset Button IRQ %d not available\n", 92 printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
89 DSMG600_RB_IRQ); 93 gpio_to_irq(DSMG600_RB_GPIO));
90 94
91 return -EIO; 95 return -EIO;
92 } 96 }
@@ -114,7 +118,7 @@ static void __exit dsmg600_power_exit(void)
114 118
115 del_timer_sync(&dsmg600_power_timer); 119 del_timer_sync(&dsmg600_power_timer);
116 120
117 free_irq(DSMG600_RB_IRQ, NULL); 121 free_irq(gpio_to_irq(DSMG600_RB_GPIO), NULL);
118} 122}
119 123
120module_init(dsmg600_power_init); 124module_init(dsmg600_power_init);
diff --git a/include/asm-arm/arch-ixp4xx/dsmg600.h b/include/asm-arm/arch-ixp4xx/dsmg600.h
index a19605ad240d..b7673e171abe 100644
--- a/include/asm-arm/arch-ixp4xx/dsmg600.h
+++ b/include/asm-arm/arch-ixp4xx/dsmg600.h
@@ -40,18 +40,13 @@
40/* Buttons */ 40/* Buttons */
41 41
42#define DSMG600_PB_GPIO 15 /* power button */ 42#define DSMG600_PB_GPIO 15 /* power button */
43#define DSMG600_PB_BM (1L << DSMG600_PB_GPIO)
44
45#define DSMG600_RB_GPIO 3 /* reset button */ 43#define DSMG600_RB_GPIO 3 /* reset button */
46 44
47#define DSMG600_RB_IRQ IRQ_IXP4XX_GPIO3 45/* Power control */
48 46
49#define DSMG600_PO_GPIO 2 /* power off */ 47#define DSMG600_PO_GPIO 2 /* power off */
50 48
51/* LEDs */ 49/* LEDs */
52 50
53#define DSMG600_LED_PWR_GPIO 0 51#define DSMG600_LED_PWR_GPIO 0
54#define DSMG600_LED_PWR_BM (1L << DSMG600_LED_PWR_GPIO)
55
56#define DSMG600_LED_WLAN_GPIO 14 52#define DSMG600_LED_WLAN_GPIO 14
57#define DSMG600_LED_WLAN_BM (1L << DSMG600_LED_WLAN_GPIO)