On Fri, Jul 5, 2013 at 11:45 AM, Mike Brady <[email protected]> wrote: > 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 <[email protected]>
I like the approach. It would be nice if you could also add scripts for those buttons to keep the reset/shutdown behaviour of the buttons by default (I just want to avoid tickets that these buttons suddenly don't work anymore ;). Some additional comments below ... > 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 <[email protected]>. > + * > + * Author: Mark Rakes <mrakes at mac.com> > + * Author: Rod Whitby <[email protected]> > +@@ -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, It's a power button, so KEY_POWER would be more appropriate. > ++ .gpio = NSLU2_PB_GPIO, > ++ .desc = "nslu2-power-button", > ++ .type = EV_KEY, > ++ }, { > ++ .code = BTN_1, And here KEY_RESTART. > ++ .gpio = NSLU2_RB_GPIO, > ++ .desc = "nslu2-reset-button", > ++ .type = EV_KEY, > ++ .active_low = 1, > ++ }, > ++}; > ++ Regards, Jonas _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
