[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>

authored by

Rod Whitby and committed by
Russell King
2bea8018 14645eba

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