This match modifies the setup file for the Linksys NSLU2 ("slug") to
allow the power button on the front and the reset button on the back,
behind a pinhole, to be seen by gpio-keys.

The present situation is that neither button can be used effectively
and this patch is designed to fix that. At present, both buttons are
hard-coded as follows: The power button sends a "ctrlaltdel" signal
which can be intercepted via /etc/inittab
(see http://wiki.openwrt.org/toh/linksys/nslu2/nslu2.hardware.button).
Unfortunately, the button isn't debounced, so the signal is sent many times,
and in addition (I think) it runs as an interrupt handler. It interferes
with other processes, e.g. pppd. The reset button powers the machine
off directly.

This patch fixes the situation by making the buttons accessible
in the normal way via gpio-keys so that they can be used in the normal way.

Signed-off-by Mike Brady <mikebr...@eircom.net>

Index: target/linux/ixp4xx/patches-3.10/920-nslu2-add-gpio-keys.patch
===================================================================
--- target/linux/ixp4xx/patches-3.10/920-nslu2-add-gpio-keys.patch      
(revision 0)
+++ target/linux/ixp4xx/patches-3.10/920-nslu2-add-gpio-keys.patch      
(revision 0)
@@ -0,0 +1,116 @@
+--- a/arch/arm/mach-ixp4xx/nslu2-setup.c
++++ b/arch/arm/mach-ixp4xx/nslu2-setup.c
+@@ -9,6 +9,8 @@
+  *      Copyright (C) 2003-2004 MontaVista Software, Inc.
+  * based on nslu2-power.c:
+  *    Copyright (C) 2005 Tower Technologies
++ * modified to allow the use of gpio-keys to sense the power and reset 
buttons,
++ *    July 5, 2013 by Mike Brady <mikebr...@eircom.net>.
+  *
+  * Author: Mark Rakes <mrakes at mac.com>
+  * Author: Rod Whitby <r...@whitby.id.au>
+@@ -26,6 +28,8 @@
+ #include <linux/i2c.h>
+ #include <linux/i2c-gpio.h>
+ #include <linux/io.h>
++#include <linux/gpio_keys.h>
++#include <linux/input.h>
+ #include <asm/mach-types.h>
+ #include <asm/mach/arch.h>
+ #include <asm/mach/flash.h>
+@@ -186,11 +190,46 @@ static struct platform_device nslu2_eth[
+       }
+ };
+ 
++/*
++ * Buttons attached to GPIO. Used to permit gpio-keys to see them
++ * The Power Button is towards the bottom on the front. 
++ * The Reset Button is behind a pinhole at the back.
++ */
++static struct gpio_keys_button nslu2_buttons[] = {
++      {
++              .code           = BTN_0,
++              .gpio           = NSLU2_PB_GPIO,
++              .desc           = "nslu2-power-button",
++              .type       = EV_KEY,
++      }, {
++              .code           = BTN_1,
++              .gpio           = NSLU2_RB_GPIO,
++              .desc           = "nslu2-reset-button",
++              .type       = EV_KEY,
++              .active_low     = 1,
++      },
++};
++
++static struct gpio_keys_platform_data nslu2_button_data = {
++      .buttons        = nslu2_buttons,
++      .nbuttons       = ARRAY_SIZE(nslu2_buttons),
++};
++
++static struct platform_device nslu2_button_device = {
++      .name           = "gpio-keys",
++      .id             = -1,
++      .num_resources  = 0,
++      .dev            = {
++              .platform_data  = &nslu2_button_data,
++      },
++};
++
+ static struct platform_device *nslu2_devices[] __initdata = {
+       &nslu2_i2c_gpio,
+       &nslu2_flash,
+       &nslu2_beeper,
+       &nslu2_leds,
++      &nslu2_button_device,
+       &nslu2_eth[0],
+ };
+ 
+@@ -205,25 +244,6 @@ static void nslu2_power_off(void)
+       gpio_line_set(NSLU2_PO_GPIO, IXP4XX_GPIO_HIGH);
+ }
+ 
+-static irqreturn_t nslu2_power_handler(int irq, void *dev_id)
+-{
+-      /* Signal init to do the ctrlaltdel action, this will bypass init if
+-       * it hasn't started and do a kernel_restart.
+-       */
+-      ctrl_alt_del();
+-
+-      return IRQ_HANDLED;
+-}
+-
+-static irqreturn_t nslu2_reset_handler(int irq, void *dev_id)
+-{
+-      /* This is the paper-clip reset, it shuts the machine down directly.
+-       */
+-      machine_power_off();
+-
+-      return IRQ_HANDLED;
+-}
+-
+ static void __init nslu2_timer_init(void)
+ {
+     /* The xtal on this machine is non-standard. */
+@@ -258,22 +278,6 @@ static void __init nslu2_init(void)
+ 
+       pm_power_off = nslu2_power_off;
+ 
+-      if (request_irq(gpio_to_irq(NSLU2_RB_GPIO), &nslu2_reset_handler,
+-              IRQF_DISABLED | IRQF_TRIGGER_LOW,
+-              "NSLU2 reset button", NULL) < 0) {
+-
+-              printk(KERN_DEBUG "Reset Button IRQ %d not available\n",
+-                      gpio_to_irq(NSLU2_RB_GPIO));
+-      }
+-
+-      if (request_irq(gpio_to_irq(NSLU2_PB_GPIO), &nslu2_power_handler,
+-              IRQF_DISABLED | IRQF_TRIGGER_HIGH,
+-              "NSLU2 power button", NULL) < 0) {
+-
+-              printk(KERN_DEBUG "Power Button IRQ %d not available\n",
+-                      gpio_to_irq(NSLU2_PB_GPIO));
+-      }
+-
+       /*
+        * Map in a portion of the flash and read the MAC address.
+        * Since it is stored in BE in the flash itself, we need to

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to