root/trunk/patches/2.6.22/17-nas100d-auto-power-on.patch
| Revision 873, 4.0 KB (checked in by rwhitby, 3 years ago) |
|---|
-
arch/arm/mach-ixp4xx/nas100d-power.c
--- arch/arm/mach-ixp4xx/nas100d-power.c | 68 ++++++++++++++++++++++++++++++++-- include/asm-arm/arch-ixp4xx/nas100d.h | 18 +++++---- 2 files changed, 75 insertions(+), 11 deletions(-)
old new 21 21 #include <linux/irq.h> 22 22 #include <linux/module.h> 23 23 #include <linux/reboot.h> 24 #include <linux/jiffies.h> 25 #include <linux/timer.h> 24 26 25 27 #include <asm/mach-types.h> 26 28 27 static irqreturn_t nas100d_reset_handler(int irq, void *dev_id) 29 extern void ctrl_alt_del(void); 30 31 /* This is used to make sure the power-button pusher is serious. The button 32 * must be held until the value of this counter reaches zero. 33 */ 34 static volatile int power_button_countdown; 35 36 /* Must hold the button down for at least this many counts to be processed */ 37 #define PBUTTON_HOLDDOWN_COUNT 4 /* 2 secs */ 38 39 static void nas100d_power_handler(unsigned long data); 40 static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0); 41 42 static void nas100d_power_handler(unsigned long data) 28 43 { 29 /* Signal init to do the ctrlaltdel action, this will bypass init if30 * it hasn't started and do a kernel_restart.44 /* This routine is called twice per second to check the 45 * state of the power button. 31 46 */ 32 ctrl_alt_del(); 47 48 if (*IXP4XX_GPIO_GPINR & NAS100D_PB_BM) { 49 50 /* IO Pin is 1 (button pushed) */ 51 if (power_button_countdown > 0) { 52 power_button_countdown--; 53 } 54 55 } else { 56 57 /* Done on button release, to allow for auto-power-on mods. */ 58 if (power_button_countdown == 0) { 59 /* Signal init to do the ctrlaltdel action, this will bypass 60 * init if it hasn't started and do a kernel_restart. 61 */ 62 ctrl_alt_del(); 63 64 /* Change the state of the power LED to "blink" */ 65 gpio_line_set(NAS100D_LED_PWR_GPIO, IXP4XX_GPIO_LOW); 66 } else { 67 power_button_countdown = PBUTTON_HOLDDOWN_COUNT; 68 } 69 } 70 71 mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500)); 72 } 73 74 static irqreturn_t nas100d_reset_handler(int irq, void *dev_id) 75 { 76 /* This is the paper-clip reset, it shuts the machine down directly. */ 77 machine_power_off(); 33 78 34 79 return IRQ_HANDLED; 35 80 } … … 50 95 return -EIO; 51 96 } 52 97 98 /* The power button on the Iomega NAS100d is on GPIO 14, but 99 * it cannot handle interrupts on that GPIO line. So we'll 100 * have to poll it with a kernel timer. 101 */ 102 103 /* Make sure that the power button GPIO is set up as an input */ 104 gpio_line_config(NAS100D_PB_GPIO, IXP4XX_GPIO_IN); 105 106 /* Set the initial value for the power button IRQ handler */ 107 power_button_countdown = PBUTTON_HOLDDOWN_COUNT; 108 109 mod_timer(&nas100d_power_timer, jiffies + msecs_to_jiffies(500)); 110 53 111 return 0; 54 112 } 55 113 … … 58 116 if (!(machine_is_nas100d())) 59 117 return; 60 118 119 del_timer_sync(&nas100d_power_timer); 120 61 121 free_irq(NAS100D_RB_IRQ, NULL); 62 122 } 63 123 -
include/asm-arm/arch-ixp4xx/nas100d.h
old new 39 39 /* Buttons */ 40 40 41 41 #define NAS100D_PB_GPIO 14 42 #define NAS100D_PB_BM (1L << NAS100D_PB_GPIO) 43 42 44 #define NAS100D_RB_GPIO 4 43 #define NAS100D_PO_GPIO 12 /* power off */44 45 45 #define NAS100D_PB_IRQ IRQ_IXP4XX_GPIO1446 46 #define NAS100D_RB_IRQ IRQ_IXP4XX_GPIO4 47 47 48 /* 49 #define NAS100D_PB_BM (1L << NAS100D_PB_GPIO) 50 #define NAS100D_PO_BM (1L << NAS100D_PO_GPIO) 51 #define NAS100D_RB_BM (1L << NAS100D_RB_GPIO) 52 */ 48 #define NAS100D_PO_GPIO 12 /* power off */ 49 50 /* LEDs */ 51 52 #define NAS100D_LED_PWR_GPIO 15 53 #define NAS100D_LED_PWR_BM (1L << NAS100D_LED_PWR_GPIO) 54 55 #define NAS100D_LED_WLAN_GPIO 0 56 #define NAS100D_LED_WLAN_BM (1L << NAS100D_LED_WLAN_GPIO)
Note: See TracBrowser
for help on using the browser.
