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