2 arch/arm/mach-ixp4xx/nas100d-power.c | 68 ++++++++++++++++++++++++++++++++--
3 include/asm-arm/arch-ixp4xx/nas100d.h | 18 +++++----
4 2 files changed, 75 insertions(+), 11 deletions(-)
6 Index: linux-2.6.22-rc5-armeb/arch/arm/mach-ixp4xx/nas100d-power.c
7 ===================================================================
8 --- linux-2.6.22-rc5-armeb.orig/arch/arm/mach-ixp4xx/nas100d-power.c
9 +++ linux-2.6.22-rc5-armeb/arch/arm/mach-ixp4xx/nas100d-power.c
11 #include <linux/irq.h>
12 #include <linux/module.h>
13 #include <linux/reboot.h>
14 +#include <linux/jiffies.h>
15 +#include <linux/timer.h>
17 #include <asm/mach-types.h>
19 -static irqreturn_t nas100d_reset_handler(int irq, void *dev_id)
20 +extern void ctrl_alt_del(void);
22 +/* This is used to make sure the power-button pusher is serious. The button
23 + * must be held until the value of this counter reaches zero.
25 +static volatile int power_button_countdown;
27 +/* Must hold the button down for at least this many counts to be processed */
28 +#define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */
30 +static void nas100d_power_handler(unsigned long data);
31 +static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0);
33 +static void nas100d_power_handler(unsigned long data)
35 - /* Signal init to do the ctrlaltdel action, this will bypass init if
36 - * it hasn't started and do a kernel_restart.
37 + /* This routine is called twice per second to check the
38 + * state of the power button.
42 + if (*IXP4XX_GPIO_GPINR & NAS100D_PB_BM) {
44 + /* IO Pin is 1 (button pushed) */
45 + if (power_button_countdown > 0) {
46 + power_button_countdown--;
51 + /* Done on button release, to allow for auto-power-on mods. */
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.
58 + /* Change the state of the power LED to "blink" */
59 + gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW);
61 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
65 + mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
68 +static irqreturn_t nas100d_reset_handler(int irq, void *dev_id)
70 + /* This is the paper-clip reset, it shuts the machine down directly. */
71 + machine_power_off();
79 + /* The power button on the Iomega NAS100d is on GPIO 14, but
80 + * it cannot handle interrupts on that GPIO line. So we'll
81 + * have to poll it with a kernel timer.
84 + /* Make sure that the power button GPIO is set up as an input */
85 + gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN);
87 + /* Set the initial value for the power button IRQ handler */
88 + power_button_countdown = PBUTTON_HOLDDOWN_COUNT;
90 + mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500));
96 if (!(machine_is_nas100d()))
99 + del_timer_sync(&nas100d_power_timer);
101 free_irq(NAS100D_RB_IRQ, NULL);
104 Index: linux-2.6.22-rc5-armeb/include/asm-arm/arch-ixp4xx/nas100d.h
105 ===================================================================
106 --- linux-2.6.22-rc5-armeb.orig/include/asm-arm/arch-ixp4xx/nas100d.h
107 +++ linux-2.6.22-rc5-armeb/include/asm-arm/arch-ixp4xx/nas100d.h
111 #define NAS100D_PB_GPIO 14
112 +#define NAS100D_PB_BM (1L << NAS100D_PB_GPIO)
114 #define NAS100D_RB_GPIO 4
115 -#define NAS100D_PO_GPIO 12 /* power off */
117 -#define NAS100D_PB_IRQ IRQ_IXP4XX_GPIO14
118 #define NAS100D_RB_IRQ IRQ_IXP4XX_GPIO4
121 -#define NAS100D_PB_BM (1L << NAS100D_PB_GPIO)
122 -#define NAS100D_PO_BM (1L << NAS100D_PO_GPIO)
123 -#define NAS100D_RB_BM (1L << NAS100D_RB_GPIO)
125 +#define NAS100D_PO_GPIO 12 /* power off */
129 +#define NAS100D_LED_PWR_GPIO 15
130 +#define NAS100D_LED_PWR_BM (1L << NAS100D_LED_PWR_GPIO)
132 +#define NAS100D_LED_WLAN_GPIO 0
133 +#define NAS100D_LED_WLAN_BM (1L << NAS100D_LED_WLAN_GPIO)