diff options
author | Rod Whitby <rod@whitby.id.au> | 2008-01-28 18:30:54 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-02-04 08:15:24 -0500 |
commit | 2bea80187f6218ed8b5c1e1280220b1c53d8dd05 (patch) | |
tree | 854b0b4c9a7357e2079d83baf7f563dad2766434 /arch/arm | |
parent | 14645ebabd96d29f3050ea78a6417b6653bc48cf (diff) |
[ARM] 4769/2: ixp4xx: Button updates for the dsmg600 board
* Remove the superfluous declaration of ctrl_alt_del().
* Convert GPIO and IRQ handling to use the <asm/gpio.h> api.
* Perform the reset on the release of the power button, so that
NAS devices which have been set to auto-power-on (by solder
bridging the power button) do not continuously power cycle.
* Remove all superflous constants from dsmg600.h
Signed-off-by: Rod Whitby <rod@whitby.id.au>
Acked-by: Lennert Buytenhek <buytenh@wantstofly.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-ixp4xx/dsmg600-power.c | 30 |
1 files changed, 17 insertions, 13 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 | ||
31 | extern 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 | */ |
36 | static volatile int power_button_countdown; | 35 | static 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 | ||
120 | module_init(dsmg600_power_init); | 124 | module_init(dsmg600_power_init); |