diff options
| author | Aurelien Jarno <aurelien@aurel32.net> | 2008-10-14 05:44:43 -0400 |
|---|---|---|
| committer | Ralf Baechle <ralf@linux-mips.org> | 2008-10-15 07:46:51 -0400 |
| commit | 89f8c04a49019eeb3998f9f0990256aec146fe9d (patch) | |
| tree | 9c998c69575b01007f1463d1ba20295e36723adf | |
| parent | b06f3e19a673e44ff56ce265600c5c6eb99aa914 (diff) | |
MIPS: WGT634U: Add reset button support
This patch adds support for the reset button of WGT634U machine, using
GPIO interrupts. Based on a patch from Michel Lespinasse.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
| -rw-r--r-- | arch/mips/bcm47xx/wgt634u.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/arch/mips/bcm47xx/wgt634u.c b/arch/mips/bcm47xx/wgt634u.c index f9e309a96576..ef00e7f58c24 100644 --- a/arch/mips/bcm47xx/wgt634u.c +++ b/arch/mips/bcm47xx/wgt634u.c | |||
| @@ -11,6 +11,9 @@ | |||
| 11 | #include <linux/leds.h> | 11 | #include <linux/leds.h> |
| 12 | #include <linux/mtd/physmap.h> | 12 | #include <linux/mtd/physmap.h> |
| 13 | #include <linux/ssb/ssb.h> | 13 | #include <linux/ssb/ssb.h> |
| 14 | #include <linux/interrupt.h> | ||
| 15 | #include <linux/reboot.h> | ||
| 16 | #include <linux/gpio.h> | ||
| 14 | #include <asm/mach-bcm47xx/bcm47xx.h> | 17 | #include <asm/mach-bcm47xx/bcm47xx.h> |
| 15 | 18 | ||
| 16 | /* GPIO definitions for the WGT634U */ | 19 | /* GPIO definitions for the WGT634U */ |
| @@ -99,6 +102,30 @@ static struct platform_device *wgt634u_devices[] __initdata = { | |||
| 99 | &wgt634u_gpio_leds, | 102 | &wgt634u_gpio_leds, |
| 100 | }; | 103 | }; |
| 101 | 104 | ||
| 105 | static irqreturn_t gpio_interrupt(int irq, void *ignored) | ||
| 106 | { | ||
| 107 | int state; | ||
| 108 | |||
| 109 | /* Interrupts are shared, check if the current one is | ||
| 110 | a GPIO interrupt. */ | ||
| 111 | if (!ssb_chipco_irq_status(&ssb_bcm47xx.chipco, | ||
| 112 | SSB_CHIPCO_IRQ_GPIO)) | ||
| 113 | return IRQ_NONE; | ||
| 114 | |||
| 115 | state = gpio_get_value(WGT634U_GPIO_RESET); | ||
| 116 | |||
| 117 | /* Interrupt are level triggered, revert the interrupt polarity | ||
| 118 | to clear the interrupt. */ | ||
| 119 | gpio_polarity(WGT634U_GPIO_RESET, state); | ||
| 120 | |||
| 121 | if (!state) { | ||
| 122 | printk(KERN_INFO "Reset button pressed"); | ||
| 123 | ctrl_alt_del(); | ||
| 124 | } | ||
| 125 | |||
| 126 | return IRQ_HANDLED; | ||
| 127 | } | ||
| 128 | |||
| 102 | static int __init wgt634u_init(void) | 129 | static int __init wgt634u_init(void) |
| 103 | { | 130 | { |
| 104 | /* There is no easy way to detect that we are running on a WGT634U | 131 | /* There is no easy way to detect that we are running on a WGT634U |
| @@ -115,6 +142,16 @@ static int __init wgt634u_init(void) | |||
| 115 | 142 | ||
| 116 | printk(KERN_INFO "WGT634U machine detected.\n"); | 143 | printk(KERN_INFO "WGT634U machine detected.\n"); |
| 117 | 144 | ||
| 145 | if (!request_irq(gpio_to_irq(WGT634U_GPIO_RESET), | ||
| 146 | gpio_interrupt, IRQF_SHARED, | ||
| 147 | "WGT634U GPIO", &ssb_bcm47xx.chipco)) { | ||
| 148 | gpio_direction_input(WGT634U_GPIO_RESET); | ||
| 149 | gpio_intmask(WGT634U_GPIO_RESET, 1); | ||
| 150 | ssb_chipco_irq_mask(&ssb_bcm47xx.chipco, | ||
| 151 | SSB_CHIPCO_IRQ_GPIO, | ||
| 152 | SSB_CHIPCO_IRQ_GPIO); | ||
| 153 | } | ||
| 154 | |||
| 118 | wgt634u_flash_data.width = mcore->flash_buswidth; | 155 | wgt634u_flash_data.width = mcore->flash_buswidth; |
| 119 | wgt634u_flash_resource.start = mcore->flash_window; | 156 | wgt634u_flash_resource.start = mcore->flash_window; |
| 120 | wgt634u_flash_resource.end = mcore->flash_window | 157 | wgt634u_flash_resource.end = mcore->flash_window |
