root/trunk/patches/2.6.22/17-nas100d-auto-power-on.patch

Revision 873, 4.0 kB (checked in by rwhitby, 3 years ago)

Added power patch for nas100d auto-power-on

  • linux-2.6.22-rc5-armeb/arch/arm/mach-ixp4xx/nas100d-power.c

    old new  
    2121#include <linux/irq.h> 
    2222#include <linux/module.h> 
    2323#include <linux/reboot.h> 
     24#include <linux/jiffies.h> 
     25#include <linux/timer.h> 
    2426 
    2527#include <asm/mach-types.h> 
    2628 
    27 static irqreturn_t nas100d_reset_handler(int irq, void *dev_id) 
     29extern 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 */ 
     34static 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 
     39static void nas100d_power_handler(unsigned long data); 
     40static DEFINE_TIMER(nas100d_power_timer, nas100d_power_handler, 0, 0); 
     41 
     42static void nas100d_power_handler(unsigned long data) 
    2843{ 
    29         /* Signal init to do the ctrlaltdel action, this will bypass init if 
    30          * 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
    3146         */ 
    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 
     74static 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(); 
    3378 
    3479        return IRQ_HANDLED; 
    3580} 
     
    5095                return -EIO; 
    5196        } 
    5297 
     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 
    53111        return 0; 
    54112} 
    55113 
     
    58116        if (!(machine_is_nas100d())) 
    59117                return; 
    60118 
     119        del_timer_sync(&nas100d_power_timer); 
     120 
    61121        free_irq(NAS100D_RB_IRQ, NULL); 
    62122} 
    63123 
  • linux-2.6.22-rc5-armeb/include/asm-arm/arch-ixp4xx/nas100d.h

    old new  
    3939/* Buttons */ 
    4040 
    4141#define NAS100D_PB_GPIO         14 
     42#define NAS100D_PB_BM           (1L << NAS100D_PB_GPIO) 
     43 
    4244#define NAS100D_RB_GPIO         4 
    43 #define NAS100D_PO_GPIO         12   /* power off */ 
    4445 
    45 #define NAS100D_PB_IRQ          IRQ_IXP4XX_GPIO14 
    4646#define NAS100D_RB_IRQ          IRQ_IXP4XX_GPIO4 
    4747 
    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.