]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/linux/nslu2-kernel/2.6.13/50-nslu2-setup.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.13 / 50-nslu2-setup.patch
1 diff -urN linux-2.6.13.1/arch/arm/mach-ixp4xx/Makefile nslu2-2.6.13.1/arch/arm/mach-ixp4xx/Makefile
2 --- linux-2.6.13.1/arch/arm/mach-ixp4xx/Makefile        2005-09-17 12:42:02.000000000 +0200
3 +++ nslu2-2.6.13.1/arch/arm/mach-ixp4xx/Makefile        2005-09-17 12:44:11.000000000 +0200
4 @@ -8,4 +8,5 @@
5  obj-$(CONFIG_MACH_IXDPG425)    += ixdpg425-pci.o coyote-setup.o
6  obj-$(CONFIG_ARCH_ADI_COYOTE)  += coyote-pci.o coyote-setup.o
7  obj-$(CONFIG_MACH_GTWX5715)    += gtwx5715-pci.o gtwx5715-setup.o
8 +obj-$(CONFIG_ARCH_NSLU2)       += nslu2-pci.o nslu2-setup.o nslu2-part.o nslu2-io.o
9  
10 diff -urN linux-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-io.c nslu2-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-io.c
11 --- linux-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-io.c      1970-01-01 01:00:00.000000000 +0100
12 +++ nslu2-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-io.c      2005-09-17 00:12:18.000000000 +0200
13 @@ -0,0 +1,777 @@
14 +//=============================================================================
15 +//
16 +// n2-io.c version 0.1.7
17 +// Author: Karen Spearel <kas11 at tampabay.rr.com>
18 +// please report problems/bugs directly to the address above
19 +//
20 +// Boilerplate to be added "real soon now"...it is and has always been GPL'ed per
21 +// MODULE_LICENSE but is offered without warrantee of any sort..use at your own risk
22 +//
23 +// NOTE: THIS IS INCOMPLETE.  INCLUDED ONLY TO KEEP FROM BREAKING THE BUILD,
24 +// IT BEEPS AND SENDS A MESSAGE TO /proc/poweroff.  EVENTUALLY IT
25 +// WILL TALK TO THE n2_pbd DAEMON.  EVENTUALLY THE LED DRIVER
26 +// WILL TALK TO SOME USERLAND APP BUT ***NOT*** SET_LEDS.
27 +// 
28 +//=============================================================================
29 +//     GPIO            Function        State
30 +//     0               Red LED         Status          
31 +//     1               Green LED       Ready = 1
32 +//     2               Disk 2 LED      On = 0
33 +//     3               Disk 1 LED      On = 0
34 +//     4               Buzzer
35 +//     5               Power Button    Pressed = 1
36 +//     8               Power Down      Output = 1 powers down N2
37 +//     12              Reset           Pressed = 0
38 +//=============================================================================
39 +// this driver is N2 specific and is purposely designed to do the minimum 
40 +// necessary to provide the necessary services given the limited memory resources
41 +// of the N2.  As OpenN2 develops, addition features will be added as
42 +// suggested by the community.
43 +//
44 +//=============================================================================
45 +
46 +#include <linux/config.h>
47 +#include <linux/version.h>
48 +#include <linux/module.h>
49 +#include <linux/utsname.h>
50 +#include <linux/kernel.h>
51 +#include <linux/major.h>
52 +#include <linux/string.h>
53 +#include <linux/proc_fs.h>
54 +#include <linux/slab.h>
55 +#include <linux/init.h>
56 +#include <linux/errno.h>
57 +#include <linux/fs.h>
58 +#include <linux/miscdevice.h>
59 +#include <linux/device.h>
60 +#include <linux/interrupt.h>
61 +#include <linux/moduleparam.h>
62 +#include <linux/timer.h>
63 +#include <linux/reboot.h>
64 +
65 +#include <asm/system.h>
66 +#include <asm/uaccess.h>
67 +#include <asm/hardware.h>
68 +#include <asm-arm/irq.h>
69 +#include <asm-arm/delay.h>
70 +#include <asm-arm/signal.h>
71 +
72 +/* Set this to 1 to output lots of debug messages. */
73 +#if NSLU2_IO_DEBUG
74 +#define nslu2_io_debug(args) printk args
75 +#else
76 +#define nslu2_io_debug(args) ((void)0)
77 +#endif
78 +
79 +#define VERSION                        "0.1.7"
80 +
81 +#define N2RB_MAJOR             60              //rbuttons
82 +#define N2PB_MAJOR             61              //pbuttons
83 +#define        N2BZ_MAJOR              62              //buzzer
84 +#define N2LM_MAJOR             126
85 +
86 +#define N2PB_IRQ               22              //gpio5
87 +#define        N2RB_IRQ                29              //gpio12
88 +
89 +#define N2_BEEP_DUR_LONG       2000
90 +#define N2_BEEP_DUR_MED                400
91 +#define N2_BEEP_DUR_SHORT      100
92 +#define N2_BEEP_PITCH_HIGH     250
93 +#define N2_BEEP_PITCH_MED      500
94 +#define N2_BEEP_PITCH_LOW      1000
95 +#define N2_LONG_DELAY          30000
96 +
97 +#define N2_BZ_GPIO             4
98 +#define N2_PB_GPIO             5
99 +#define N2_PO_GPIO             8               //power off
100 +#define N2_RB_GPIO             12
101 +
102 +#define GPIO_BZ_BM             0x0010  //b0000 0000 0001 0000
103 +#define GPIO_PB_BM             0x0020  //b0000 0000 0010 0000
104 +#define GPIO_PO_BM             0x0100  //b0000 0001 0000 0000
105 +#define GPIO_RB_BM             0x1000  //b0001 0000 0000 0000
106 +
107 +#define NOERR                  0
108 +
109 +#define RB_DELAY               50
110 +#define PB_DELAY               20
111 +
112 +#define PWR_OFF_STR            "poweroff"
113 +
114 +
115 +// ioctls -- 'M" is used for sound cards...we don't got one so it seems safe
116 +
117 +#define N2BZ_BEEP_STOP         _IO('M',0)       //stop multi-beep at end of audible
118 +#define N2BZ_BEEP              _IO('M',1)       //one beep at current defaults
119 +#define N2BZ_BEEPS             _IOW('M',3,long) //param beeps at current defaults
120 +#define N2BZ_TONESET           _IOW('M',4,long) //set tone: range is high=250 to low=2000
121 +#define N2BZ_ONTIME            _IOW('M',5,long) //ontime for multi-beeps in jiffies
122 +#define        N2BZ_SILENTTIME         _IOW('M',6,long) //offtime for multi-beeps in jiffies
123 +#define N2BZ_REPEATCNT         _IOW('M',7,long) //number of repeats for multi-beeps 0 = forever
124 +#define N2BZ_COMBINED          _IOW('M',8,long) //combine all params in a long
125 +
126 +#define N2LM_OFF               _IOW('M',32,long)
127 +#define N2LM_ON                        _IOW('M',33,long)
128 +#define N2LM_BLINK             _IOW('M',34,long)
129 +#define N2LM_ALT               _IOW('M',35,long)
130 +#define N2LM_ALL_ON            _IO('M',36)
131 +#define N2LM_ALL_OFF           _IO('M',37)
132 +
133 +#define PHYS_LEDS              4
134 +#define BLINK_DELAY            25
135 +
136 +//  OR Masks to turn these LEDs ON
137 +
138 +#define        RS_RED_ON       0x00000001      //0b0000 0000 0000 0010
139 +#define        RS_GRN_ON       0x00000002      //0b0000 0000 0000 0001
140 +#define RS_YEL_ON      0x00000003      //0b0000 0000 0000 0011
141 +
142 +// AND Masks to turn these LEDs OFF
143 +
144 +#define        RS_RED_OFF      0xfffffffe      //0b1111 1111 1111 1101
145 +#define        RS_GRN_OFF      0xfffffffd      //0b1111 1111 1111 1110
146 +#define RS_YEL_OFF     0xfffffffc      //0b1111 1111 1111 1100
147 +
148 +// AND Masks to turn these LEDs ON
149 +
150 +#define DISK1_ON       0xfffffff7      //0b1111 1111 1111 0111
151 +#define        DISK2_ON        0xfffffffb      //0b1111 1111 1111 1011
152 +
153 +// Or Masks to turn these LEDs OFF
154 +
155 +#define DISK1_OFF      0x00000008      //0b0000 0000 0000 1000
156 +#define        DISK2_OFF       0x00000004      //0b0000 0000 0000 0100 
157 +
158 +// EOR masks for toggling LEDs on/off
159 +
160 +#define RS_RG_ALT      0x00000003      //eor mask to toggle rs rg bits
161 +#define RS_GRN_TGL     0x00000002
162 +#define RS_RED_TGL     0x00000001
163 +#define DISK1_TGL      0x00000008
164 +#define DISK2_TGL      0x00000004
165 +
166 +// The LED names for switches
167 +
168 +#define LED_RS_RED     0
169 +#define LED_RS_GRN     1
170 +#define        LED_DISK1       2
171 +#define LED_DISK2      3
172 +#define LED_ALL                4
173 +
174 +static unsigned long init_jiffy = 0;                   //jiffies at init time
175 +static unsigned long rb_presses = 0;                   //number of reset button presses
176 +static unsigned long ontime = 50;
177 +static unsigned long offtime = 450;
178 +static unsigned long bz_repeatcnt = 10;
179 +static unsigned long tone = 1000;
180 +
181 +DECLARE_WAIT_QUEUE_HEAD(n2rb_waitq);
182 +DECLARE_WAIT_QUEUE_HEAD(n2pb_waitq);
183 +
184 +static struct timer_list n2lm_rsg_timer;       //rs green 
185 +static struct timer_list n2lm_rsr_timer;       //rs red
186 +static struct timer_list n2lm_d1_timer;                //drive 1
187 +static struct timer_list n2lm_d2_timer;                //drive 2
188 +static struct timer_list n2rb_timer;
189 +static struct timer_list n2pb_timer;
190 +static struct timer_list n2bz_timer;           //beeper
191 +
192 +// sysfs class
193 +static struct class *n2lm_class;
194 +
195 +//==================================================================================================
196 +//
197 +// Blinking is handled entirely by the 4 timer handlers.  On timeout, the bit in the
198 +// GPIO output register is xor'd with a mask corresponding to the selected led which simply
199 +// flips that bit.  No record of what any of the other leds is doing is needed.
200 +//
201 +//==================================================================================================
202 +// this blinks rs green or green/yellow if rs red is on
203 +static void n2lm_rsg_handler(unsigned long data)
204 +{
205 +       *IXP4XX_GPIO_GPOUTR ^= RS_GRN_TGL;                      //flip the led
206 +       n2lm_rsg_timer.expires = jiffies + BLINK_DELAY;         //next timeout
207 +       add_timer(&n2lm_rsg_timer);                             //reinit timer
208 +       return;
209 +}
210 +
211 +// this blinks or alternates rs red green... inited wit green on/red off
212 +static void n2lm_rsr_handler(unsigned long data)
213 +{
214 +       *IXP4XX_GPIO_GPOUTR ^= n2lm_rsr_timer.data;
215 +       n2lm_rsr_timer.expires = jiffies + BLINK_DELAY;
216 +       add_timer(&n2lm_rsr_timer);
217 +       return; 
218 +}
219 +// blinks disk 1
220 +static void n2lm_d1_handler(unsigned long data)
221 +{
222 +       *IXP4XX_GPIO_GPOUTR ^= DISK1_TGL;
223 +       n2lm_d1_timer.expires = jiffies + BLINK_DELAY;
224 +       add_timer(&n2lm_d1_timer);
225 +       return;
226 +}
227 +// blinks disk 2
228 +static void n2lm_d2_handler(unsigned long data)
229 +{
230 +       *IXP4XX_GPIO_GPOUTR ^= DISK2_TGL;
231 +       n2lm_d2_timer.expires = jiffies + BLINK_DELAY;
232 +       add_timer(&n2lm_d2_timer);
233 +       return;
234 +}
235 +
236 +//==================================================================================================
237 +
238 +static void n2lm_timer_start(unsigned long led)
239 +{
240 +
241 +       nslu2_io_debug((KERN_DEBUG "timer: %ld\n",led));
242 +
243 +       switch(led) {
244 +               case LED_RS_RED:
245 +                       n2lm_rsr_timer.expires = jiffies + BLINK_DELAY;
246 +                       add_timer(&n2lm_rsr_timer);
247 +                       break;
248 +
249 +               case LED_RS_GRN:
250 +                       n2lm_rsg_timer.expires = jiffies + BLINK_DELAY;
251 +                       add_timer(&n2lm_rsg_timer);
252 +                       break;
253 +
254 +               case LED_DISK1:
255 +                       n2lm_d1_timer.expires = jiffies + BLINK_DELAY;
256 +                       add_timer(&n2lm_d1_timer);
257 +                       break;
258 +
259 +               case LED_DISK2:
260 +                       n2lm_d2_timer.expires = jiffies + BLINK_DELAY; 
261 +                       add_timer(&n2lm_d2_timer);
262 +                       break;
263 +
264 +               default:
265 +                       break;
266 +       }
267 +       return;
268 +}
269 +
270 +//==================================================================================================
271 +
272 +static void n2lm_timer_stop(unsigned long led)
273 +{
274 +       switch (led) {
275 +               case LED_RS_RED:
276 +                       del_timer(&n2lm_rsr_timer);
277 +                       break;
278 +               case LED_RS_GRN:
279 +                       del_timer(&n2lm_rsg_timer);
280 +                       break;
281 +               case LED_DISK1:
282 +                       del_timer(&n2lm_d1_timer);
283 +                       break;
284 +               case LED_DISK2: 
285 +                       del_timer(&n2lm_d2_timer);
286 +                       break;
287 +               default:
288 +                       break;
289 +       }
290 +       return;
291 +}
292 +
293 +//--------------------------------------------------------------------------------------------------
294 +
295 +static void n2lm_timer_stop_all(void)
296 +{
297 +       del_timer(&n2lm_rsg_timer);
298 +       del_timer(&n2lm_rsr_timer);
299 +       del_timer(&n2lm_d1_timer); 
300 +       del_timer(&n2lm_d2_timer);
301 +       return;
302 +}
303 +//--------------------------------------------------------------------------------------------------
304 +
305 +static void n2lm_ledon(unsigned long led)
306 +{
307 +
308 +       nslu2_io_debug((KERN_DEBUG "ledon: %ld\n", led));
309 +
310 +       switch (led) {
311 +               case LED_RS_RED:        
312 +                       *IXP4XX_GPIO_GPOUTR |= RS_RED_ON;       //1
313 +                       return;
314 +               case LED_RS_GRN:
315 +                       *IXP4XX_GPIO_GPOUTR |= RS_GRN_ON;       //2
316 +                       return;
317 +               case LED_DISK1:
318 +                       *IXP4XX_GPIO_GPOUTR &= DISK1_ON;        //0xfffffff7
319 +                       return;
320 +               case LED_DISK2: 
321 +                       *IXP4XX_GPIO_GPOUTR &= DISK2_ON;        //0xfffffffb
322 +                       return;
323 +               case LED_ALL:                                   //all green
324 +                       *IXP4XX_GPIO_GPOUTR |= RS_GRN_ON;
325 +                       *IXP4XX_GPIO_GPOUTR &= (DISK1_ON & DISK2_ON);
326 +                       return; 
327 +       }
328 +}
329 +
330 +//--------------------------------------------------------------------------------------------------
331 +
332 +static void n2lm_ledoff(unsigned long led)
333 +{
334 +
335 +       switch (led) {
336 +               case LED_RS_RED:        
337 +                       *IXP4XX_GPIO_GPOUTR &= RS_RED_OFF;      //0xffffffffe
338 +                       return;
339 +               case LED_RS_GRN:
340 +                       *IXP4XX_GPIO_GPOUTR &= RS_GRN_OFF;      //0xfffffffd
341 +                       return;
342 +               case LED_DISK1:
343 +                       *IXP4XX_GPIO_GPOUTR |= DISK1_OFF;       //0x00000008
344 +                       return;
345 +               case LED_DISK2: 
346 +                       *IXP4XX_GPIO_GPOUTR |= DISK2_OFF;       //0x00000004
347 +                       return;
348 +               case LED_ALL:
349 +                       *IXP4XX_GPIO_GPOUTR &= (RS_GRN_OFF & RS_RED_OFF);
350 +                       *IXP4XX_GPIO_GPOUTR |= (DISK1_OFF | DISK2_OFF);
351 +       }
352 +}
353 +
354 +//==================================================================================================
355 +
356 +static int n2lm_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long led)
357 +{
358 +
359 +       nslu2_io_debug((KERN_DEBUG "cmd=%d, led=%ld\n", cmd, led));
360 +       
361 +       if (led < 0 || led >= PHYS_LEDS)
362 +               return -EINVAL;
363 +
364 +       switch (cmd ) {
365 +               case N2LM_ON:
366 +                       n2lm_timer_stop(led);
367 +                       n2lm_ledon(led);
368 +                       break;
369 +                       
370 +               case N2LM_OFF:
371 +                       n2lm_timer_stop(led);
372 +                       n2lm_ledoff(led);
373 +                       break;
374 +                       
375 +               case N2LM_BLINK:
376 +                       n2lm_ledon(led);
377 +                       if (led == LED_RS_RED)
378 +                               n2lm_rsr_timer.data = RS_RED_TGL;
379 +                       n2lm_timer_start(led);
380 +                       break;
381 +
382 +               case N2LM_ALT:
383 +                       if (led == LED_RS_RED)
384 +                       {
385 +                               n2lm_ledon(LED_RS_GRN);
386 +                               n2lm_ledoff(LED_RS_RED);
387 +                               n2lm_rsr_timer.data = RS_RG_ALT;
388 +                               n2lm_timer_start(LED_RS_RED);
389 +                               break;
390 +                       } else
391 +                               return -EINVAL;
392 +               
393 +               case N2LM_ALL_ON:
394 +                       n2lm_timer_stop_all();
395 +                       n2lm_ledon(LED_ALL);
396 +                       break;
397 +               
398 +               case N2LM_ALL_OFF:
399 +                       n2lm_timer_stop_all();
400 +                       n2lm_ledoff(LED_ALL);
401 +                       break;
402 +               
403 +               default:
404 +                       return -EINVAL;
405 +       }
406 +
407 +       return NOERR;
408 +}
409 +
410 +static struct file_operations n2lm_fops = {
411 +       .owner          = THIS_MODULE,
412 +       .ioctl          = n2lm_ioctl,
413 +};
414 +//==================================================================================================
415 +// We can't do anything fancy here since the system tick rate is far below that required to
416 +// generate a desirable tone.  Therefore we haven't much choice but to use a busy loop until
417 +// I get up to speed on the timers.  The saving grace is that for the normal uses, nothing 
418 +// important should be haprepening. 
419 +//==================================================================================================
420 +
421 +static void n2_buzz(int tone_delay, int duration)
422 +{
423 +       int i;
424 +
425 +       *IXP4XX_GPIO_GPOER &= ~GPIO_BZ_BM;
426 +               
427 +       for (i = 1; i < duration; i++) {
428 +               *IXP4XX_GPIO_GPOUTR &= ~GPIO_BZ_BM;
429 +               udelay(tone_delay);
430 +               *IXP4XX_GPIO_GPOUTR |= GPIO_BZ_BM;
431 +               udelay(tone_delay);
432 +       }
433 +       *IXP4XX_GPIO_GPOER |= GPIO_BZ_BM;
434 +
435 +       return;
436 +}
437 +//=================================================================================================
438 +
439 +// this handles the buzzer duty cycle
440 +static void n2bz_handler(unsigned long data)
441 +{
442 +       if (--bz_repeatcnt > 0) {                       //if just one beep left to do
443 +               n2bz_timer.expires = jiffies + ontime + offtime;        //next timeout
444 +               add_timer(&n2bz_timer);                                 //reinit timer
445 +       }
446 +       n2_buzz(tone/2, ontime);
447 +       nslu2_io_debug((KERN_DEBUG "Count = %d\tOntime = %d\n", bz_repeatcnt, ontime));
448 +       return;
449 +}
450 +
451 +//==================================================================================================
452 +
453 +static int n2bz_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long param)
454 +{
455 +       switch (cmd) {
456 +               case N2BZ_BEEP:
457 +                       n2_buzz(tone/2, ontime);
458 +                       break;
459 +       
460 +               case N2BZ_BEEP_STOP:
461 +                       del_timer(&n2bz_timer);
462 +                       break;
463 +
464 +               case N2BZ_BEEPS:
465 +                       if (param == 0)
466 +                               bz_repeatcnt = 0xffffffff;
467 +                       else
468 +                               bz_repeatcnt = param;
469 +                       n2bz_handler(0);
470 +                       break;
471 +       
472 +               case N2BZ_TONESET:
473 +                       if (param >= 250 && param <= 2000)
474 +                               tone = param;
475 +                       break;
476 +
477 +               case N2BZ_ONTIME:
478 +                       if (param > 4 && param < 201)
479 +                               ontime = param;
480 +                       break;
481 +
482 +               case N2BZ_SILENTTIME:
483 +                       if (param > ontime)                     //enforce a reasonable duty cycle
484 +                               offtime = param;
485 +                       else
486 +                               offtime = ontime;
487 +                       break;
488 +
489 +               case N2BZ_REPEATCNT:
490 +                       if (param == 0)
491 +                               bz_repeatcnt = 0xffffffff;
492 +                       else
493 +                               bz_repeatcnt = param;
494 +                       break;
495 +
496 +               case N2BZ_COMBINED:
497 +                       bz_repeatcnt =  (param & 0xF0000000) >> 28;     //repeat 1 - 16
498 +                       ontime =        (param & 0x0FF00000) >> 20;     //ontime 1 - 256 jiffies
499 +                       offtime =       (param & 0x000FFF00) >> 8;      //offtime 1 - 4095 jiffies
500 +                       tone =          (param & 0x000000FF) << 4;      //tone (1 - 255) * 16
501 +                       break;
502 +
503 +               default:
504 +                       break;
505 +       }
506 +       return NOERR;
507 +}
508 +
509 +static struct file_operations n2bz_fops = {
510 +       .owner          = THIS_MODULE,
511 +       .ioctl          = n2bz_ioctl,
512 +};
513 +
514 +//==================================================================================================
515 +               
516 +static irqreturn_t n2pb_handler (int irq, void *dev_id, struct pt_regs *regs)
517 +{
518 +       void *ret;
519 +       
520 +       wake_up(&n2pb_waitq);   
521 +       remove_proc_entry(PWR_OFF_STR, NULL);           //no parent     
522 +       n2_buzz(N2_BEEP_PITCH_MED, N2_BEEP_DUR_MED);
523 +       ret = create_proc_entry(PWR_OFF_STR, 0, NULL);
524 +       nslu2_io_debug((KERN_DEBUG "cpe ret = %p\n", ret));
525 +
526 +// WARNING: This is RUDE...it unconditionally pulls the power plug.
527 +// Your data will be at risk...since this is just a test system
528 +// I am leaving it enabled...eventually userland needs to get the
529 +// message, do an orderly shutdown and use an ioctl or something in
530 +// /proc/powerdowm to actually have us pull the plug.
531 +
532 +       machine_power_off();
533 +
534 +       return IRQ_HANDLED;
535 +}
536 +
537 +//==================================================================================================
538 +//
539 +//static void do_rb_timeout(unsigned long data)
540 +//{
541 +//     int i;
542 +//
543 +//     for (i = 0; i < rb_presses; i++)
544 +//             n2_buzz(N2_BEEP_PITCH_MED,N2_BEEP_DUR_SHORT);
545 +//     return;
546 +//}
547 +//
548 +//==================================================================================================
549 +// does nothing -- waiting for userland to define
550 +// This thing is sorta braindead...edge triggered IRQs aren't available in the drivers yet...so
551 +// we hang in a loop until the button is no longer pressed
552 +
553 +struct testr {
554 +       int     ctl;
555 +       long    param;
556 +};
557 +
558 +static irqreturn_t n2rb_handler (int irq, void *dev_id, struct pt_regs *regs)
559 +{
560 +
561 +       static struct testr test[] = {
562 +                                { N2LM_ALL_OFF,0 },
563 +                                { N2LM_ON,0 },
564 +                                { N2LM_OFF,0 },
565 +                                { N2LM_ON,1 },
566 +                                { N2LM_ALL_OFF,1 },
567 +                                { N2LM_ON,2 },
568 +                                { N2LM_OFF,2 },
569 +                                { N2LM_ON,3 },
570 +                                { N2LM_OFF,3 },
571 +                                { N2LM_BLINK,0 },
572 +                                { N2LM_OFF,0 },
573 +                                { N2LM_BLINK,1 },
574 +                                { N2LM_OFF,1 },
575 +                                { N2LM_BLINK,2 },
576 +                                { N2LM_OFF,2 },
577 +                                { N2LM_BLINK,3 },
578 +                                { N2LM_OFF,3 },
579 +                                { N2LM_ALL_OFF,0 },
580 +                                { N2LM_ALT,1 },
581 +                                { N2LM_OFF,1 },
582 +                                { N2LM_ALL_ON,0 }
583 +       };
584 +
585 +       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)));
586 +
587 +       wake_up(&n2rb_waitq);   
588 +       while ((*IXP4XX_GPIO_GPINR & GPIO_RB_BM) == 0)
589 +               ;                                       //wait for button release
590 +
591 +       if (rb_presses > 20) 
592 +               rb_presses = 0;
593 +       tone = (rb_presses * 50) + 200;
594 +       ontime = (rb_presses*10) + 100;
595 +       offtime = 500 - (rb_presses*20);
596 +       nslu2_io_debug(("Ontime = %d\tOfftime = %d\tTone = %d\n",ontime,offtime,tone));
597 +       rb_presses++;
598 +
599 +       n2bz_ioctl(NULL,NULL, N2BZ_BEEPS, rb_presses);  
600 +       n2lm_ioctl(NULL,NULL, test[rb_presses].ctl, test[rb_presses].param);
601 +//     if (rb_presses == 0) {
602 +//             init_jiffy = jiffies;
603 +//             init_timer (&n2rb_timer);
604 +//             n2rb_timer.function = do_rb_timeout;
605 +//     };
606 +//
607 +//     if (rb_presses == 8)
608 +//             rb_presses = 0;
609 +//     if (rb_presses & 1)
610 +//             n2lm_ledon(test[rb_presses]);
611 +//     else
612 +//             n2lm_ledoff(test[rb_presses]);
613 +//     
614 +//     n2rb_timer.expires = (jiffies + RB_DELAY);
615 +//     add_timer (&n2rb_timer);
616 +//     if (rb_presses < 5) {
617 +//             if (rb_presses > 0)
618 +//                     n2lm_ledoff(rb_presses);
619 +//             n2lm_ledon(++rb_presses);
620 +//             n2lm_timer_start(rb_presses);
621 +//     };
622 +
623 +       nslu2_io_debug((KERN_DEBUG "Reset Exit IRQ=%d Presses= %d Jiffies= %08lx\n", irq, rb_presses, jiffies));
624 +       return IRQ_HANDLED;
625 +
626 +}
627 +
628 +//==================================================================================================
629 +//  What to do here is majorly undetermined...
630 +
631 +static int n2rb_read (struct file *filp, char __user *buffer, size_t count, loff_t *ppos)
632 +{
633 +       printk(KERN_DEBUG "Reset Button Wait\n");
634 +       interruptible_sleep_on(&n2rb_waitq);
635 +       return copy_to_user(buffer, "reset", 5) ? -EFAULT : 5;
636 +
637 +}
638 +
639 +//==================================================================================================
640 +//  What to do here is majorly undetermined...
641 +
642 +static int n2pb_read (struct file *filp, char __user *buffer, size_t count, loff_t *ppos)
643 +{
644 +       printk(KERN_DEBUG "Power Button Wait\n");
645 +       interruptible_sleep_on(&n2pb_waitq);
646 +       return copy_to_user(buffer, "poweroff", 8) ? -EFAULT : 8;
647 +
648 +}
649 +
650 +//--------------------------------------------------------------------------------------------------
651 +
652 +static struct file_operations n2rb_fops = {
653 +       .owner          = THIS_MODULE,
654 +       .read           = n2rb_read,
655 +};
656 +
657 +//--------------------------------------------------------------------------------------------------
658 +
659 +static struct file_operations n2pb_fops = {
660 +       .owner          = THIS_MODULE,
661 +       .read           = n2pb_read,
662 +};
663 +
664 +//==================================================================================================
665 +
666 +static void n2iom_initarch(void)
667 +{
668 +       printk(KERN_DEBUG "setup_interrupts - jiffies=%ld init_jiffy=%ld\n", jiffies, init_jiffy);
669 +
670 +       *IXP4XX_GPIO_GPISR = 0x20400000;        // read the 2 irqs to clr
671 +       gpio_line_config(N2_RB_GPIO, IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
672 +       gpio_line_isr_clear(N2_RB_GPIO);
673 +       gpio_line_config(N2_PB_GPIO, IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_HIGH);
674 +       gpio_line_isr_clear(N2_PB_GPIO);
675 +
676 +       init_timer(&n2lm_rsg_timer);
677 +       init_timer(&n2lm_rsr_timer);
678 +       init_timer(&n2lm_d1_timer);
679 +       init_timer(&n2lm_d2_timer);
680 +//     init_timer(&n2rb_timer);
681 +//     init_timer(&n2pb_timer);
682 +       init_timer(&n2bz_timer);
683 +       n2lm_rsr_timer.function = n2lm_rsr_handler;
684 +       n2lm_rsg_timer.function = n2lm_rsg_handler;
685 +       n2lm_d2_timer.function = n2lm_d2_handler;
686 +       n2lm_d1_timer.function = n2lm_d1_handler;
687 +       n2bz_timer.function = n2bz_handler;
688 +       n2lm_rsr_timer.data = n2lm_rsg_timer.data = n2lm_d1_timer.data = n2lm_d2_timer.data = n2bz_timer.data = 0;
689 +
690 +       *IXP4XX_GPIO_GPOER &= 0xfffffff0;       //enable gpio 0-3
691 +       *IXP4XX_GPIO_GPOUTR |= 0x00000003;      //turn off the leds
692 +       *IXP4XX_GPIO_GPOUTR &= 0xfffffffc;
693 +       n2lm_ledon(LED_ALL);
694 +       n2_buzz(N2_BEEP_PITCH_MED, N2_BEEP_DUR_SHORT);
695 +       n2lm_ledoff(LED_ALL);
696 +// Default the Ready/Status to Red during kernel boot, Turn Green at the end of sysvinit
697 +       n2lm_ledon(LED_RS_RED);
698 +
699 +       return;
700 +}
701 +
702 +//==================================================================================================
703 +
704 +static int __init n2iom_init(void)
705 +{
706 +       printk(KERN_INFO "OpenN2 Misc I/O Driver Version %s\n", VERSION);
707 +       
708 +       init_jiffy = jiffies;
709 +       printk(KERN_DEBUG "init_jiffy=%ld\n",init_jiffy);
710 +       n2iom_initarch();
711 +
712 +       n2lm_class = class_create(THIS_MODULE, "nslu2");
713 +
714 +       if (register_chrdev(N2RB_MAJOR, "n2_rbm", &n2pb_fops) < NOERR) {
715 +               printk(KERN_DEBUG "Reset Button Major %d not available\n", N2RB_MAJOR);
716 +               return -EBUSY;
717 +       }
718 +       else {
719 +               class_device_create(n2lm_class, MKDEV(N2RB_MAJOR, 0), NULL, "rbuttons");
720 +       }
721 +       if (register_chrdev(N2PB_MAJOR, "n2_pbm", &n2rb_fops) < NOERR) {
722 +               printk(KERN_DEBUG "Power Button Major %d not available\n", N2PB_MAJOR);
723 +               return -EBUSY;
724 +       }
725 +       else {
726 +               class_device_create(n2lm_class, MKDEV(N2PB_MAJOR, 0), NULL, "pbuttons");
727 +       }
728 +       if (register_chrdev(N2LM_MAJOR, "n2_ledm", &n2lm_fops) < NOERR) {
729 +               printk(KERN_DEBUG "Led Manager Major %d not available\n", N2LM_MAJOR);
730 +               return -EBUSY;
731 +       }
732 +       else {
733 +               class_device_create(n2lm_class, MKDEV(N2LM_MAJOR, 0), NULL, "leds");
734 +       }
735 +       if (register_chrdev(N2BZ_MAJOR, "n2_bzm", &n2bz_fops) < NOERR) {
736 +               printk(KERN_DEBUG "Buzzer Major %d not available\n", N2BZ_MAJOR);
737 +               return -EBUSY;
738 +       }
739 +       else {
740 +               class_device_create(n2lm_class, MKDEV(N2BZ_MAJOR, 0), NULL, "buzzer");
741 +       }
742 +
743 +       if (request_irq(N2RB_IRQ, &n2rb_handler, SA_INTERRUPT, "n2_rb", NULL) < NOERR) {
744 +               printk(KERN_DEBUG "Reset Button IRQ %d not available\n", N2RB_IRQ);
745 +               return -EIO;
746 +       }
747 +       if (request_irq(N2PB_IRQ, &n2pb_handler, SA_INTERRUPT, "n2_pb", NULL) < NOERR) {
748 +               printk(KERN_DEBUG "Power Button IRQ %d not available\n", N2PB_IRQ);
749 +               return -EIO;    
750 +       }
751 +       
752 +       enable_irq(N2PB_IRQ);
753 +       enable_irq(N2RB_IRQ);
754 +       return (NOERR);
755 +}
756 +
757 +//==================================================================================================
758 +
759 +static void __exit n2iom_exit(void)
760 +{
761 +       remove_proc_entry(PWR_OFF_STR, NULL);
762 +       del_timer(&n2rb_timer);
763 +       free_irq(N2RB_IRQ,NULL);
764 +       unregister_chrdev(N2PB_MAJOR, "n2pb");
765 +       class_device_destroy(n2lm_class, MKDEV(N2PB_MAJOR, 0));
766 +       del_timer(&n2pb_timer); 
767 +       free_irq(N2PB_IRQ, NULL);
768 +       unregister_chrdev(N2RB_MAJOR, "n2rb" );
769 +       class_device_destroy(n2lm_class, MKDEV(N2RB_MAJOR, 0));
770 +       del_timer(&n2lm_rsg_timer);
771 +       del_timer(&n2lm_rsr_timer);
772 +       del_timer(&n2lm_d1_timer);
773 +       del_timer(&n2lm_d2_timer);      
774 +       unregister_chrdev(N2LM_MAJOR, "n2lm" );
775 +       class_device_destroy(n2lm_class, MKDEV(N2LM_MAJOR, 0));
776 +       unregister_chrdev(N2BZ_MAJOR, "n2bz");
777 +       class_device_destroy(n2lm_class, MKDEV(N2BZ_MAJOR, 0));
778 +       class_destroy(n2lm_class);
779 +}
780 +
781 +module_init (n2iom_init);
782 +module_exit (n2iom_exit);
783 +
784 +MODULE_AUTHOR("Karen Spearel <kas11@tampabay.rr.com>");
785 +MODULE_DESCRIPTION("OpenN2 Buttons/LEDs IO Driver");
786 +MODULE_LICENSE("GPL");
787 +static int debug = 7;
788 +module_param(debug, int, 0644);
789 +MODULE_PARM_DESC(debug, "Debugging enabled = 8");
790 +
791 diff -urN linux-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-part.c nslu2-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-part.c
792 --- linux-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-part.c    1970-01-01 01:00:00.000000000 +0100
793 +++ nslu2-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-part.c    2005-09-16 22:44:38.000000000 +0200
794 @@ -0,0 +1,120 @@
795 +/*
796 + * nslu2-part.c
797 + *
798 + * Maintainers: http://www.nslu2-linux.org/
799 + * Initial port: Mark Rakes <mrakes AT mac.com>
800 + *
801 + * "Parse" the fixed partition table of the Linksys NSLU2 and
802 + * produce a Linux partition array to match.
803 + */
804 +
805 +#include <linux/kernel.h>
806 +#include <linux/slab.h>
807 +#include <linux/init.h>
808 +#include <linux/vmalloc.h>
809 +#include <linux/mtd/mtd.h>
810 +#include <linux/mtd/partitions.h>
811 +
812 +/* info we know about the NSLU2's flash setup:
813 + *
814 + * Num Partition               offset          size
815 + * --- ---------               ----------      -----------
816 + * 0   RedBoot                 0x00000000      0x00040000
817 + * 1   System Configuration    0x00040000      0x00020000
818 + * 2   Kernel                  0x00060000      0x00100000
819 + * 3   Ramdisk                 0x00160000      0x006a0000
820 + */
821 + #define NSLU2_NUM_FLASH_PARTITIONS    4
822 + #define NSLU2_FLASH_PART0_NAME                "RedBoot"
823 + #define NSLU2_FLASH_PART0_OFFSET      0x00000000
824 + #define NSLU2_FLASH_PART0_SIZE                0x00040000
825 + #define NSLU2_FLASH_PART1_NAME                "System Configuration"
826 + #define NSLU2_FLASH_PART1_OFFSET      (NSLU2_FLASH_PART0_OFFSET + NSLU2_FLASH_PART0_SIZE)
827 + #define NSLU2_FLASH_PART1_SIZE                0x00020000
828 + #define NSLU2_FLASH_PART2_NAME                "Kernel"
829 + #define NSLU2_FLASH_PART2_OFFSET      (NSLU2_FLASH_PART1_OFFSET + NSLU2_FLASH_PART1_SIZE)
830 + #define NSLU2_FLASH_PART2_SIZE                0x00100000
831 + #define NSLU2_FLASH_PART3_NAME                "Ramdisk"
832 + #define NSLU2_FLASH_PART3_OFFSET      (NSLU2_FLASH_PART2_OFFSET + NSLU2_FLASH_PART2_SIZE)
833 + #define NSLU2_FLASH_PART3_SIZE                0x006a0000
834 +
835 +static int parse_nslu2_partitions(struct mtd_info *master,
836 +                             struct mtd_partition **pparts,
837 +                             unsigned long flash_start)
838 +{
839 +       struct mtd_partition *parts;
840 +       int ret = 0, namelen = 0;
841 +       char *names;
842 +
843 +       namelen = strlen(NSLU2_FLASH_PART0_NAME) +
844 +                 strlen(NSLU2_FLASH_PART1_NAME) +
845 +                 strlen(NSLU2_FLASH_PART2_NAME) +
846 +                 strlen(NSLU2_FLASH_PART3_NAME) +
847 +                 NSLU2_NUM_FLASH_PARTITIONS; /*4 strings + each terminator */
848 +
849 +       parts = kmalloc(sizeof(*parts)*NSLU2_NUM_FLASH_PARTITIONS + namelen, GFP_KERNEL);
850 +       if (!parts) {
851 +               ret = -ENOMEM;
852 +               goto out;
853 +       }
854 +
855 +       memset(parts, 0, sizeof(*parts)*NSLU2_NUM_FLASH_PARTITIONS + namelen);
856 +       names = (char *)&parts[NSLU2_NUM_FLASH_PARTITIONS];
857 +
858 +       /* RedBoot partition */
859 +       parts[0].size   = NSLU2_FLASH_PART0_SIZE;
860 +       parts[0].offset = NSLU2_FLASH_PART0_OFFSET;
861 +       parts[0].name   = NSLU2_FLASH_PART0_NAME;
862 +       parts[0].mask_flags = MTD_WRITEABLE; /* readonly */
863 +       strcpy(names, NSLU2_FLASH_PART0_NAME);
864 +       names += strlen(names)+1;
865 +       /* System Configuration */
866 +       parts[1].size   = NSLU2_FLASH_PART1_SIZE;
867 +       parts[1].offset = NSLU2_FLASH_PART1_OFFSET;
868 +       parts[1].name   = NSLU2_FLASH_PART1_NAME;
869 +       parts[1].mask_flags = MTD_WRITEABLE; /* readonly */
870 +       strcpy(names, NSLU2_FLASH_PART1_NAME);
871 +       names += strlen(names)+1;
872 +       /* Kernel */
873 +       parts[2].size   = NSLU2_FLASH_PART2_SIZE;
874 +       parts[2].offset = NSLU2_FLASH_PART2_OFFSET;
875 +       parts[2].name   = NSLU2_FLASH_PART2_NAME;
876 +       parts[2].mask_flags = MTD_WRITEABLE; /* readonly */
877 +       strcpy(names, NSLU2_FLASH_PART2_NAME);
878 +       names += strlen(names)+1;
879 +       /* Ramdisk */
880 +       parts[3].size   = NSLU2_FLASH_PART3_SIZE;
881 +       parts[3].offset = NSLU2_FLASH_PART3_OFFSET;
882 +       parts[3].name   = NSLU2_FLASH_PART3_NAME;
883 +       parts[3].mask_flags = MTD_WRITEABLE; /* readonly */
884 +       strcpy(names, NSLU2_FLASH_PART3_NAME);
885 +       names += strlen(names)+1;
886 +
887 +       ret = NSLU2_NUM_FLASH_PARTITIONS;
888 +       *pparts = parts;
889 + out:
890 +       return ret;
891 +}
892 +
893 +static struct mtd_part_parser nslu2_parser = {
894 +       .owner = THIS_MODULE,
895 +       .parse_fn = parse_nslu2_partitions,
896 +       .name = "NSLU2",
897 +};
898 +
899 +static int __init nslu2_parser_init(void)
900 +{
901 +       return register_mtd_parser(&nslu2_parser);
902 +}
903 +
904 +static void __exit nslu2_parser_exit(void)
905 +{
906 +       deregister_mtd_parser(&nslu2_parser);
907 +}
908 +
909 +module_init(nslu2_parser_init);
910 +module_exit(nslu2_parser_exit);
911 +
912 +MODULE_LICENSE("GPL");
913 +MODULE_AUTHOR("Mark Rakes");
914 +MODULE_DESCRIPTION("Parsing code for NSLU2 flash tables");
915 diff -urN linux-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-pci.c nslu2-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-pci.c
916 --- linux-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-pci.c     1970-01-01 01:00:00.000000000 +0100
917 +++ nslu2-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-pci.c     2005-09-16 22:43:54.000000000 +0200
918 @@ -0,0 +1,87 @@
919 +/*
920 + * arch/arm/mach-ixp4xx/nslu2-pci.c
921 + *
922 + * NSLU2 board-level PCI initialization
923 + *
924 + * based on ixdp425-pci.c:
925 + *     Copyright (C) 2002 Intel Corporation.
926 + *     Copyright (C) 2003-2004 MontaVista Software, Inc.
927 + *
928 + * Maintainer: http://www.nslu2-linux.org/
929 + *
930 + * This program is free software; you can redistribute it and/or modify
931 + * it under the terms of the GNU General Public License version 2 as
932 + * published by the Free Software Foundation.
933 + *
934 + */
935 +// GPIO 8 is used as the power input so is not free for use as a PCI IRQ
936 +// However, all the common PCI setup code presumes the standard 4 PCI
937 +// interrupts are available.  So we compromise...we don't enable the
938 +// IRQ on Pin 8 but we let
939 +
940 +#include <linux/config.h>
941 +#include <linux/pci.h>
942 +#include <linux/init.h>
943 +#include <linux/delay.h>
944 +
945 +#include <asm/mach/pci.h>
946 +#include <asm/irq.h>
947 +#include <asm/hardware.h>
948 +#include <asm/mach-types.h>
949 +
950 +void __init nslu2_pci_preinit(void)
951 +{
952 +       gpio_line_config(NSLU2_PCI_INTA_PIN,
953 +                               IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
954 +       gpio_line_config(NSLU2_PCI_INTB_PIN,
955 +                               IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
956 +       gpio_line_config(NSLU2_PCI_INTC_PIN,
957 +                               IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
958 +//     gpio_line_config(NSLU2_PCI_INTD_PIN,
959 +//                             IXP4XX_GPIO_IN | IXP4XX_GPIO_ACTIVE_LOW);
960 +
961 +       gpio_line_isr_clear(NSLU2_PCI_INTA_PIN);
962 +       gpio_line_isr_clear(NSLU2_PCI_INTB_PIN);
963 +       gpio_line_isr_clear(NSLU2_PCI_INTC_PIN);
964 +//     gpio_line_isr_clear(NSLU2_PCI_INTD_PIN);
965 +
966 +       ixp4xx_pci_preinit();
967 +}
968 +
969 +static int __init nslu2_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
970 +{
971 +       static int pci_irq_table[NSLU2_PCI_IRQ_LINES] = {
972 +               IRQ_NSLU2_PCI_INTA,
973 +               IRQ_NSLU2_PCI_INTB,
974 +               IRQ_NSLU2_PCI_INTC,
975 +//             IRQ_NSLU2_PCI_INTD
976 +       };
977 +
978 +       int irq = -1;
979 +
980 +       if (slot >= 1 && slot <= NSLU2_PCI_MAX_DEV &&
981 +               pin >= 1 && pin <= NSLU2_PCI_IRQ_LINES) {
982 +               irq = pci_irq_table[(slot + pin - 2) % 3]; // ! % 4 kas11
983 +       }
984 +
985 +       return irq;
986 +}
987 +
988 +struct hw_pci __initdata nslu2_pci = {
989 +       .nr_controllers = 1,
990 +       .preinit        = nslu2_pci_preinit,
991 +       .swizzle        = pci_std_swizzle,
992 +       .setup          = ixp4xx_setup,
993 +       .scan           = ixp4xx_scan_bus,
994 +       .map_irq        = nslu2_map_irq,
995 +};
996 +
997 +int __init nslu2_pci_init(void)                //monkey see, monkey do
998 +{
999 +       if (machine_is_nslu2())
1000 +               pci_common_init(&nslu2_pci);
1001 +       return 0;
1002 +}
1003 +
1004 +subsys_initcall(nslu2_pci_init);
1005 +
1006 diff -urN linux-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-setup.c nslu2-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-setup.c
1007 --- linux-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-setup.c   1970-01-01 01:00:00.000000000 +0100
1008 +++ nslu2-2.6.13.1/arch/arm/mach-ixp4xx/nslu2-setup.c   2005-09-17 00:02:40.000000000 +0200
1009 @@ -0,0 +1,147 @@
1010 +/*
1011 + * arch/arm/mach-ixp4xx/nslu2-setup.c
1012 + *
1013 + * NSLU2 board-setup
1014 + *
1015 + * based ixdp425-setup.c:
1016 + *      Copyright (C) 2003-2004 MontaVista Software, Inc.
1017 + *
1018 + * Author: Mark Rakes <mrakes at mac.com>
1019 + * Maintainers: http://www.nslu2-linux.org/
1020 + *
1021 + * Fixed missing init_time in MACHINE_START kas11 10/22/04
1022 + * Changed to conform to new style __init ixdp425 kas11 10/22/04 
1023 + */
1024 +
1025 +#include <linux/kernel.h>
1026 +#include <linux/init.h>
1027 +#include <linux/device.h>
1028 +#include <linux/serial.h>
1029 +#include <linux/tty.h>
1030 +#include <linux/serial_8250.h>
1031 +
1032 +#include <asm/types.h>
1033 +#include <asm/setup.h>
1034 +#include <asm/memory.h>
1035 +#include <asm/hardware.h>
1036 +#include <asm/mach-types.h>
1037 +#include <asm/irq.h>
1038 +#include <asm/mach/arch.h>
1039 +#include <asm/mach/flash.h>
1040 +
1041 +void __init nslu2_map_io(void) 
1042 +{
1043 +       ixp4xx_map_io();
1044 +}
1045 +
1046 +static struct flash_platform_data nslu2_flash_data = {
1047 +       .map_name       = "cfi_probe",
1048 +       .width          = 2,
1049 +};
1050 +
1051 +static struct resource nslu2_flash_resource = {
1052 +       .start          = NSLU2_FLASH_BASE,
1053 +       .end            = NSLU2_FLASH_BASE + NSLU2_FLASH_SIZE,
1054 +       .flags          = IORESOURCE_MEM,
1055 +};
1056 +
1057 +static struct platform_device nslu2_flash = {
1058 +       .name           = "IXP4XX-Flash",
1059 +       .id             = 0,
1060 +       .dev            = {
1061 +               .platform_data = &nslu2_flash_data,
1062 +       },
1063 +       .num_resources  = 1,
1064 +       .resource       = &nslu2_flash_resource,
1065 +};
1066 +
1067 +static struct ixp4xx_i2c_pins nslu2_i2c_gpio_pins = {
1068 +       .sda_pin        = NSLU2_SDA_PIN,
1069 +       .scl_pin        = NSLU2_SCL_PIN,
1070 +};
1071 +
1072 +static struct platform_device nslu2_i2c_controller = {
1073 +       .name           = "IXP4XX-I2C",
1074 +       .id             = 0,
1075 +       .dev            = {
1076 +               .platform_data = &nslu2_i2c_gpio_pins,
1077 +       },
1078 +       .num_resources  = 0
1079 +};
1080 +
1081 +static struct resource nslu2_uart_resources[] = {
1082 +       {
1083 +               .start          = IXP4XX_UART1_BASE_PHYS,
1084 +               .end            = IXP4XX_UART1_BASE_PHYS + 0x0fff,
1085 +               .flags          = IORESOURCE_MEM
1086 +       },
1087 +       {
1088 +               .start          = IXP4XX_UART2_BASE_PHYS,
1089 +               .end            = IXP4XX_UART2_BASE_PHYS + 0x0fff,
1090 +               .flags          = IORESOURCE_MEM
1091 +       }
1092 +};
1093 +
1094 +static struct plat_serial8250_port nslu2_uart_data[] = {
1095 +       {
1096 +               .mapbase        = IXP4XX_UART1_BASE_PHYS,
1097 +               .membase        = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET,
1098 +               .irq            = IRQ_IXP4XX_UART1,
1099 +               .flags          = UPF_BOOT_AUTOCONF,
1100 +               .iotype         = UPIO_MEM,
1101 +               .regshift       = 2,
1102 +               .uartclk        = IXP4XX_UART_XTAL,
1103 +       },
1104 +       {
1105 +               .mapbase        = IXP4XX_UART2_BASE_PHYS,
1106 +               .membase        = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET,
1107 +               .irq            = IRQ_IXP4XX_UART2,
1108 +               .flags          = UPF_BOOT_AUTOCONF,
1109 +               .iotype         = UPIO_MEM,
1110 +               .regshift       = 2,
1111 +               .uartclk        = IXP4XX_UART_XTAL,
1112 +       }
1113 +};
1114 +
1115 +static struct platform_device nslu2_uart = {
1116 +       .name                   = "serial8250",
1117 +       .id                     = 0,
1118 +       .dev.platform_data      = nslu2_uart_data,
1119 +       .num_resources          = 2,
1120 +       .resource               = nslu2_uart_resources
1121 +};
1122 +
1123 +static struct platform_device *nslu2_devices[] __initdata = {
1124 +       &nslu2_i2c_controller,
1125 +       &nslu2_flash,
1126 +       &nslu2_uart
1127 +};
1128 +
1129 +static void n2_power_off(void)
1130 +{
1131 +        /* This causes the box to drop the power and go dead. */
1132 +#define GPIO_PO_BM              0x0100  //b0000 0001 0000 0000
1133 +        *IXP4XX_GPIO_GPOER &= ~GPIO_PO_BM;      // enable the pwr cntl gpio
1134 +        *IXP4XX_GPIO_GPOUTR |= GPIO_PO_BM;      // do the deed
1135 +}
1136 +
1137 +static void __init nslu2_init(void)
1138 +{
1139 +       ixp4xx_sys_init();
1140 +
1141 +       pm_power_off = n2_power_off;
1142 +       platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
1143 +}
1144 +
1145 +MACHINE_START(NSLU2, "Linksys NSLU2")
1146 +       /* Maintainer: www.nslu2-linux.org */
1147 +       .phys_ram       = PHYS_OFFSET,
1148 +       .phys_io        = IXP4XX_PERIPHERAL_BASE_PHYS,
1149 +       .io_pg_offst    = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC,
1150 +       .boot_params    = 0x00000100,
1151 +       .map_io         = nslu2_map_io,
1152 +       .init_irq       = ixp4xx_init_irq,      //FIXME: all irq are off here
1153 +        .timer          = &ixp4xx_timer,
1154 +       .init_machine   = nslu2_init,
1155 +        // INITTIME(ixp4xx_init_time)   //this was missing in 2.6.7 code ...soft reboot needed?
1156 +MACHINE_END