]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/linux/nslu2-kernel/2.6/nslu2-io_rpbutton.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / linux / nslu2-kernel / 2.6 / nslu2-io_rpbutton.patch
1 --- nslu2-io.c.old      2da1d3f5c0aa0804c5769588337077ddcb35c5e9
2 +++ linux-2.6.12.2/arch/arm/mach-ixp4xx/nslu2-io.c      e895da638b4aae16a11fafe52ae0b063645a9a12
3 @@ -158,6 +158,8 @@
4  #define LED_DISK2      3
5  #define LED_ALL                4
6  
7 +static int nslu2_shutdown_in_progress = 0;
8 +
9  static unsigned long init_jiffy = 0;                   //jiffies at init time
10  static unsigned long rb_presses = 0;                   //number of reset button presses
11  static unsigned long ontime = 50;
12 @@ -503,40 +505,20 @@
13  static irqreturn_t n2pb_handler (int irq, void *dev_id, struct pt_regs *regs)
14  {
15         void *ret;
16 -       
17 -       wake_up(&n2pb_waitq);   
18 -       remove_proc_entry(PWR_OFF_STR, NULL);           //no parent     
19 -       n2_buzz(N2_BEEP_PITCH_MED, N2_BEEP_DUR_MED);
20 -       ret = create_proc_entry(PWR_OFF_STR, 0, NULL);
21 -       nslu2_io_debug((KERN_DEBUG "cpe ret = %p\n", ret));
22 -
23 -// WARNING: This is RUDE...it unconditionally pulls the power plug.
24 -// Your data will be at risk...since this is just a test system
25 -// I am leaving it enabled...eventually userland needs to get the
26 -// message, do an orderly shutdown and use an ioctl or something in
27 -// /proc/powerdowm to actually have us pull the plug.
28 -
29 -       machine_power_off();
30 -
31 +       if (!nslu2_shutdown_in_progress++) {                    
32 +               wake_up(&n2pb_waitq);   
33 +               remove_proc_entry(PWR_OFF_STR, NULL);           //no parent     
34 +               n2_buzz(N2_BEEP_PITCH_HIGH, N2_BEEP_DUR_SHORT); // Short, high-pitched "OK"
35 +               ret = create_proc_entry(PWR_OFF_STR, 0, NULL);
36 +               nslu2_io_debug((KERN_DEBUG "Powerbutton pressed. Shutting down. cpe ret = %p\n", ret));
37 +               kill_proc(1,SIGINT,1);                          // Signal init to shut down
38 +       } else {
39 +               n2_buzz(N2_BEEP_PITCH_LOW, N2_BEEP_DUR_MED);    // Make a scary noise!
40 +               nslu2_io_debug((KERN_DEBUG "Powerbutton pressed while already in shutdown")); // Whine!
41 +       }                                
42         return IRQ_HANDLED;
43  }
44  
45 -//==================================================================================================
46 -//
47 -//static void do_rb_timeout(unsigned long data)
48 -//{
49 -//     int i;
50 -//
51 -//     for (i = 0; i < rb_presses; i++)
52 -//             n2_buzz(N2_BEEP_PITCH_MED,N2_BEEP_DUR_SHORT);
53 -//     return;
54 -//}
55 -//
56 -//==================================================================================================
57 -// does nothing -- waiting for userland to define
58 -// This thing is sorta braindead...edge triggered IRQs aren't available in the drivers yet...so
59 -// we hang in a loop until the button is no longer pressed
60 -
61  struct testr {
62         int     ctl;
63         long    param;
64 @@ -544,72 +526,11 @@
65  
66  static irqreturn_t n2rb_handler (int irq, void *dev_id, struct pt_regs *regs)
67  {
68 +//     This doesn't reset the NSLU2. It powers it off. Close enough, since reset is unreliable
69  
70 -       static struct testr test[] = {
71 -                                { N2LM_ALL_OFF,0 },
72 -                                { N2LM_ON,0 },
73 -                                { N2LM_OFF,0 },
74 -                                { N2LM_ON,1 },
75 -                                { N2LM_ALL_OFF,1 },
76 -                                { N2LM_ON,2 },
77 -                                { N2LM_OFF,2 },
78 -                                { N2LM_ON,3 },
79 -                                { N2LM_OFF,3 },
80 -                                { N2LM_BLINK,0 },
81 -                                { N2LM_OFF,0 },
82 -                                { N2LM_BLINK,1 },
83 -                                { N2LM_OFF,1 },
84 -                                { N2LM_BLINK,2 },
85 -                                { N2LM_OFF,2 },
86 -                                { N2LM_BLINK,3 },
87 -                                { N2LM_OFF,3 },
88 -                                { N2LM_ALL_OFF,0 },
89 -                                { N2LM_ALT,1 },
90 -                                { N2LM_OFF,1 },
91 -                                { N2LM_ALL_ON,0 }
92 -       };
93 -
94 -       nslu2_io_debug(("Reset Entry IRQ =%d Presses = %d Jiffies = %08lx\tIO = %x\tIOW = %x\n", irq, rb_presses, jiffies, (int)_IO('M',rb_presses), (int)_IOW('M',rb_presses,long)));
95 -
96         wake_up(&n2rb_waitq);   
97 -       while ((*IXP4XX_GPIO_GPINR & GPIO_RB_BM) == 0)
98 -               ;                                       //wait for button release
99 -
100 -       if (rb_presses > 20) 
101 -               rb_presses = 0;
102 -       tone = (rb_presses * 50) + 200;
103 -       ontime = (rb_presses*10) + 100;
104 -       offtime = 500 - (rb_presses*20);
105 -       nslu2_io_debug(("Ontime = %d\tOfftime = %d\tTone = %d\n",ontime,offtime,tone));
106 -       rb_presses++;
107 -
108 -       n2bz_ioctl(NULL,NULL, N2BZ_BEEPS, rb_presses);  
109 -       n2lm_ioctl(NULL,NULL, test[rb_presses].ctl, test[rb_presses].param);
110 -//     if (rb_presses == 0) {
111 -//             init_jiffy = jiffies;
112 -//             init_timer (&n2rb_timer);
113 -//             n2rb_timer.function = do_rb_timeout;
114 -//     };
115 -//
116 -//     if (rb_presses == 8)
117 -//             rb_presses = 0;
118 -//     if (rb_presses & 1)
119 -//             n2lm_ledon(test[rb_presses]);
120 -//     else
121 -//             n2lm_ledoff(test[rb_presses]);
122 -//     
123 -//     n2rb_timer.expires = (jiffies + RB_DELAY);
124 -//     add_timer (&n2rb_timer);
125 -//     if (rb_presses < 5) {
126 -//             if (rb_presses > 0)
127 -//                     n2lm_ledoff(rb_presses);
128 -//             n2lm_ledon(++rb_presses);
129 -//             n2lm_timer_start(rb_presses);
130 -//     };
131 -
132 -       nslu2_io_debug((KERN_DEBUG "Reset Exit IRQ=%d Presses= %d Jiffies= %08lx\n", irq, rb_presses, jiffies));
133 -       return IRQ_HANDLED;
134 -
135 +       machine_power_off();
136 +       return IRQ_HANDLED;             // So we don't get a nobody cared error :-P
137  }
138  
139  //==================================================================================================