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
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
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
14 +//=============================================================================
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
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
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.
28 +//=============================================================================
29 +// GPIO Function State
31 +// 1 Green LED Ready = 1
32 +// 2 Disk 2 LED On = 0
33 +// 3 Disk 1 LED On = 0
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.
44 +//=============================================================================
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>
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>
72 +/* Set this to 1 to output lots of debug messages. */
74 +#define nslu2_io_debug(args) printk args
76 +#define nslu2_io_debug(args) ((void)0)
79 +#define VERSION "0.1.7"
81 +#define N2RB_MAJOR 60 //rbuttons
82 +#define N2PB_MAJOR 61 //pbuttons
83 +#define N2BZ_MAJOR 62 //buzzer
84 +#define N2LM_MAJOR 126
86 +#define N2PB_IRQ 22 //gpio5
87 +#define N2RB_IRQ 29 //gpio12
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
99 +#define N2_PO_GPIO 8 //power off
100 +#define N2_RB_GPIO 12
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
112 +#define PWR_OFF_STR "poweroff"
115 +// ioctls -- 'M" is used for sound cards...we don't got one so it seems safe
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
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)
134 +#define BLINK_DELAY 25
136 +// OR Masks to turn these LEDs ON
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
142 +// AND Masks to turn these LEDs OFF
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
148 +// AND Masks to turn these LEDs ON
150 +#define DISK1_ON 0xfffffff7 //0b1111 1111 1111 0111
151 +#define DISK2_ON 0xfffffffb //0b1111 1111 1111 1011
153 +// Or Masks to turn these LEDs OFF
155 +#define DISK1_OFF 0x00000008 //0b0000 0000 0000 1000
156 +#define DISK2_OFF 0x00000004 //0b0000 0000 0000 0100
158 +// EOR masks for toggling LEDs on/off
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
166 +// The LED names for switches
168 +#define LED_RS_RED 0
169 +#define LED_RS_GRN 1
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;
181 +DECLARE_WAIT_QUEUE_HEAD(n2rb_waitq);
182 +DECLARE_WAIT_QUEUE_HEAD(n2pb_waitq);
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
193 +static struct class *n2lm_class;
195 +//==================================================================================================
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.
201 +//==================================================================================================
202 +// this blinks rs green or green/yellow if rs red is on
203 +static void n2lm_rsg_handler(unsigned long data)
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
211 +// this blinks or alternates rs red green... inited wit green on/red off
212 +static void n2lm_rsr_handler(unsigned long data)
214 + *IXP4XX_GPIO_GPOUTR ^= n2lm_rsr_timer.data;
215 + n2lm_rsr_timer.expires = jiffies + BLINK_DELAY;
216 + add_timer(&n2lm_rsr_timer);
220 +static void n2lm_d1_handler(unsigned long data)
222 + *IXP4XX_GPIO_GPOUTR ^= DISK1_TGL;
223 + n2lm_d1_timer.expires = jiffies + BLINK_DELAY;
224 + add_timer(&n2lm_d1_timer);
228 +static void n2lm_d2_handler(unsigned long data)
230 + *IXP4XX_GPIO_GPOUTR ^= DISK2_TGL;
231 + n2lm_d2_timer.expires = jiffies + BLINK_DELAY;
232 + add_timer(&n2lm_d2_timer);
236 +//==================================================================================================
238 +static void n2lm_timer_start(unsigned long led)
241 + nslu2_io_debug((KERN_DEBUG "timer: %ld\n",led));
245 + n2lm_rsr_timer.expires = jiffies + BLINK_DELAY;
246 + add_timer(&n2lm_rsr_timer);
250 + n2lm_rsg_timer.expires = jiffies + BLINK_DELAY;
251 + add_timer(&n2lm_rsg_timer);
255 + n2lm_d1_timer.expires = jiffies + BLINK_DELAY;
256 + add_timer(&n2lm_d1_timer);
260 + n2lm_d2_timer.expires = jiffies + BLINK_DELAY;
261 + add_timer(&n2lm_d2_timer);
270 +//==================================================================================================
272 +static void n2lm_timer_stop(unsigned long led)
276 + del_timer(&n2lm_rsr_timer);
279 + del_timer(&n2lm_rsg_timer);
282 + del_timer(&n2lm_d1_timer);
285 + del_timer(&n2lm_d2_timer);
293 +//--------------------------------------------------------------------------------------------------
295 +static void n2lm_timer_stop_all(void)
297 + del_timer(&n2lm_rsg_timer);
298 + del_timer(&n2lm_rsr_timer);
299 + del_timer(&n2lm_d1_timer);
300 + del_timer(&n2lm_d2_timer);
303 +//--------------------------------------------------------------------------------------------------
305 +static void n2lm_ledon(unsigned long led)
308 + nslu2_io_debug((KERN_DEBUG "ledon: %ld\n", led));
312 + *IXP4XX_GPIO_GPOUTR |= RS_RED_ON; //1
315 + *IXP4XX_GPIO_GPOUTR |= RS_GRN_ON; //2
318 + *IXP4XX_GPIO_GPOUTR &= DISK1_ON; //0xfffffff7
321 + *IXP4XX_GPIO_GPOUTR &= DISK2_ON; //0xfffffffb
323 + case LED_ALL: //all green
324 + *IXP4XX_GPIO_GPOUTR |= RS_GRN_ON;
325 + *IXP4XX_GPIO_GPOUTR &= (DISK1_ON & DISK2_ON);
330 +//--------------------------------------------------------------------------------------------------
332 +static void n2lm_ledoff(unsigned long led)
337 + *IXP4XX_GPIO_GPOUTR &= RS_RED_OFF; //0xffffffffe
340 + *IXP4XX_GPIO_GPOUTR &= RS_GRN_OFF; //0xfffffffd
343 + *IXP4XX_GPIO_GPOUTR |= DISK1_OFF; //0x00000008
346 + *IXP4XX_GPIO_GPOUTR |= DISK2_OFF; //0x00000004
349 + *IXP4XX_GPIO_GPOUTR &= (RS_GRN_OFF & RS_RED_OFF);
350 + *IXP4XX_GPIO_GPOUTR |= (DISK1_OFF | DISK2_OFF);
354 +//==================================================================================================
356 +static int n2lm_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long led)
359 + nslu2_io_debug((KERN_DEBUG "cmd=%d, led=%ld\n", cmd, led));
361 + if (led < 0 || led >= PHYS_LEDS)
366 + n2lm_timer_stop(led);
371 + n2lm_timer_stop(led);
377 + if (led == LED_RS_RED)
378 + n2lm_rsr_timer.data = RS_RED_TGL;
379 + n2lm_timer_start(led);
383 + if (led == LED_RS_RED)
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);
394 + n2lm_timer_stop_all();
395 + n2lm_ledon(LED_ALL);
399 + n2lm_timer_stop_all();
400 + n2lm_ledoff(LED_ALL);
410 +static struct file_operations n2lm_fops = {
411 + .owner = THIS_MODULE,
412 + .ioctl = n2lm_ioctl,
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 +//==================================================================================================
421 +static void n2_buzz(int tone_delay, int duration)
425 + *IXP4XX_GPIO_GPOER &= ~GPIO_BZ_BM;
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);
433 + *IXP4XX_GPIO_GPOER |= GPIO_BZ_BM;
437 +//=================================================================================================
439 +// this handles the buzzer duty cycle
440 +static void n2bz_handler(unsigned long data)
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
446 + n2_buzz(tone/2, ontime);
447 + nslu2_io_debug((KERN_DEBUG "Count = %d\tOntime = %d\n", bz_repeatcnt, ontime));
451 +//==================================================================================================
453 +static int n2bz_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long param)
457 + n2_buzz(tone/2, ontime);
460 + case N2BZ_BEEP_STOP:
461 + del_timer(&n2bz_timer);
466 + bz_repeatcnt = 0xffffffff;
468 + bz_repeatcnt = param;
473 + if (param >= 250 && param <= 2000)
478 + if (param > 4 && param < 201)
482 + case N2BZ_SILENTTIME:
483 + if (param > ontime) //enforce a reasonable duty cycle
489 + case N2BZ_REPEATCNT:
491 + bz_repeatcnt = 0xffffffff;
493 + bz_repeatcnt = param;
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
509 +static struct file_operations n2bz_fops = {
510 + .owner = THIS_MODULE,
511 + .ioctl = n2bz_ioctl,
514 +//==================================================================================================
516 +static irqreturn_t n2pb_handler (int irq, void *dev_id, struct pt_regs *regs)
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));
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.
532 + machine_power_off();
534 + return IRQ_HANDLED;
537 +//==================================================================================================
539 +//static void do_rb_timeout(unsigned long data)
543 +// for (i = 0; i < rb_presses; i++)
544 +// n2_buzz(N2_BEEP_PITCH_MED,N2_BEEP_DUR_SHORT);
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
558 +static irqreturn_t n2rb_handler (int irq, void *dev_id, struct pt_regs *regs)
561 + static struct testr test[] = {
562 + { N2LM_ALL_OFF,0 },
566 + { N2LM_ALL_OFF,1 },
579 + { N2LM_ALL_OFF,0 },
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)));
587 + wake_up(&n2rb_waitq);
588 + while ((*IXP4XX_GPIO_GPINR & GPIO_RB_BM) == 0)
589 + ; //wait for button release
591 + if (rb_presses > 20)
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));
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;
607 +// if (rb_presses == 8)
609 +// if (rb_presses & 1)
610 +// n2lm_ledon(test[rb_presses]);
612 +// n2lm_ledoff(test[rb_presses]);
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);
623 + nslu2_io_debug((KERN_DEBUG "Reset Exit IRQ=%d Presses= %d Jiffies= %08lx\n", irq, rb_presses, jiffies));
624 + return IRQ_HANDLED;
628 +//==================================================================================================
629 +// What to do here is majorly undetermined...
631 +static int n2rb_read (struct file *filp, char __user *buffer, size_t count, loff_t *ppos)
633 + printk(KERN_DEBUG "Reset Button Wait\n");
634 + interruptible_sleep_on(&n2rb_waitq);
635 + return copy_to_user(buffer, "reset", 5) ? -EFAULT : 5;
639 +//==================================================================================================
640 +// What to do here is majorly undetermined...
642 +static int n2pb_read (struct file *filp, char __user *buffer, size_t count, loff_t *ppos)
644 + printk(KERN_DEBUG "Power Button Wait\n");
645 + interruptible_sleep_on(&n2pb_waitq);
646 + return copy_to_user(buffer, "poweroff", 8) ? -EFAULT : 8;
650 +//--------------------------------------------------------------------------------------------------
652 +static struct file_operations n2rb_fops = {
653 + .owner = THIS_MODULE,
657 +//--------------------------------------------------------------------------------------------------
659 +static struct file_operations n2pb_fops = {
660 + .owner = THIS_MODULE,
664 +//==================================================================================================
666 +static void n2iom_initarch(void)
668 + printk(KERN_DEBUG "setup_interrupts - jiffies=%ld init_jiffy=%ld\n", jiffies, init_jiffy);
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);
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;
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);
702 +//==================================================================================================
704 +static int __init n2iom_init(void)
706 + printk(KERN_INFO "OpenN2 Misc I/O Driver Version %s\n", VERSION);
708 + init_jiffy = jiffies;
709 + printk(KERN_DEBUG "init_jiffy=%ld\n",init_jiffy);
712 + n2lm_class = class_create(THIS_MODULE, "nslu2");
714 + if (register_chrdev(N2RB_MAJOR, "n2_rbm", &n2pb_fops) < NOERR) {
715 + printk(KERN_DEBUG "Reset Button Major %d not available\n", N2RB_MAJOR);
719 + class_device_create(n2lm_class, MKDEV(N2RB_MAJOR, 0), NULL, "rbuttons");
721 + if (register_chrdev(N2PB_MAJOR, "n2_pbm", &n2rb_fops) < NOERR) {
722 + printk(KERN_DEBUG "Power Button Major %d not available\n", N2PB_MAJOR);
726 + class_device_create(n2lm_class, MKDEV(N2PB_MAJOR, 0), NULL, "pbuttons");
728 + if (register_chrdev(N2LM_MAJOR, "n2_ledm", &n2lm_fops) < NOERR) {
729 + printk(KERN_DEBUG "Led Manager Major %d not available\n", N2LM_MAJOR);
733 + class_device_create(n2lm_class, MKDEV(N2LM_MAJOR, 0), NULL, "leds");
735 + if (register_chrdev(N2BZ_MAJOR, "n2_bzm", &n2bz_fops) < NOERR) {
736 + printk(KERN_DEBUG "Buzzer Major %d not available\n", N2BZ_MAJOR);
740 + class_device_create(n2lm_class, MKDEV(N2BZ_MAJOR, 0), NULL, "buzzer");
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);
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);
752 + enable_irq(N2PB_IRQ);
753 + enable_irq(N2RB_IRQ);
757 +//==================================================================================================
759 +static void __exit n2iom_exit(void)
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);
781 +module_init (n2iom_init);
782 +module_exit (n2iom_exit);
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");
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
798 + * Maintainers: http://www.nslu2-linux.org/
799 + * Initial port: Mark Rakes <mrakes AT mac.com>
801 + * "Parse" the fixed partition table of the Linksys NSLU2 and
802 + * produce a Linux partition array to match.
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>
812 +/* info we know about the NSLU2's flash setup:
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
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
835 +static int parse_nslu2_partitions(struct mtd_info *master,
836 + struct mtd_partition **pparts,
837 + unsigned long flash_start)
839 + struct mtd_partition *parts;
840 + int ret = 0, namelen = 0;
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 */
849 + parts = kmalloc(sizeof(*parts)*NSLU2_NUM_FLASH_PARTITIONS + namelen, GFP_KERNEL);
855 + memset(parts, 0, sizeof(*parts)*NSLU2_NUM_FLASH_PARTITIONS + namelen);
856 + names = (char *)&parts[NSLU2_NUM_FLASH_PARTITIONS];
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;
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;
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;
887 + ret = NSLU2_NUM_FLASH_PARTITIONS;
893 +static struct mtd_part_parser nslu2_parser = {
894 + .owner = THIS_MODULE,
895 + .parse_fn = parse_nslu2_partitions,
899 +static int __init nslu2_parser_init(void)
901 + return register_mtd_parser(&nslu2_parser);
904 +static void __exit nslu2_parser_exit(void)
906 + deregister_mtd_parser(&nslu2_parser);
909 +module_init(nslu2_parser_init);
910 +module_exit(nslu2_parser_exit);
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
920 + * arch/arm/mach-ixp4xx/nslu2-pci.c
922 + * NSLU2 board-level PCI initialization
924 + * based on ixdp425-pci.c:
925 + * Copyright (C) 2002 Intel Corporation.
926 + * Copyright (C) 2003-2004 MontaVista Software, Inc.
928 + * Maintainer: http://www.nslu2-linux.org/
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.
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
940 +#include <linux/config.h>
941 +#include <linux/pci.h>
942 +#include <linux/init.h>
943 +#include <linux/delay.h>
945 +#include <asm/mach/pci.h>
946 +#include <asm/irq.h>
947 +#include <asm/hardware.h>
948 +#include <asm/mach-types.h>
950 +void __init nslu2_pci_preinit(void)
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);
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);
966 + ixp4xx_pci_preinit();
969 +static int __init nslu2_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
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
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
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,
997 +int __init nslu2_pci_init(void) //monkey see, monkey do
999 + if (machine_is_nslu2())
1000 + pci_common_init(&nslu2_pci);
1004 +subsys_initcall(nslu2_pci_init);
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
1011 + * arch/arm/mach-ixp4xx/nslu2-setup.c
1013 + * NSLU2 board-setup
1015 + * based ixdp425-setup.c:
1016 + * Copyright (C) 2003-2004 MontaVista Software, Inc.
1018 + * Author: Mark Rakes <mrakes at mac.com>
1019 + * Maintainers: http://www.nslu2-linux.org/
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
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>
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>
1041 +void __init nslu2_map_io(void)
1046 +static struct flash_platform_data nslu2_flash_data = {
1047 + .map_name = "cfi_probe",
1051 +static struct resource nslu2_flash_resource = {
1052 + .start = NSLU2_FLASH_BASE,
1053 + .end = NSLU2_FLASH_BASE + NSLU2_FLASH_SIZE,
1054 + .flags = IORESOURCE_MEM,
1057 +static struct platform_device nslu2_flash = {
1058 + .name = "IXP4XX-Flash",
1061 + .platform_data = &nslu2_flash_data,
1063 + .num_resources = 1,
1064 + .resource = &nslu2_flash_resource,
1067 +static struct ixp4xx_i2c_pins nslu2_i2c_gpio_pins = {
1068 + .sda_pin = NSLU2_SDA_PIN,
1069 + .scl_pin = NSLU2_SCL_PIN,
1072 +static struct platform_device nslu2_i2c_controller = {
1073 + .name = "IXP4XX-I2C",
1076 + .platform_data = &nslu2_i2c_gpio_pins,
1078 + .num_resources = 0
1081 +static struct resource nslu2_uart_resources[] = {
1083 + .start = IXP4XX_UART1_BASE_PHYS,
1084 + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff,
1085 + .flags = IORESOURCE_MEM
1088 + .start = IXP4XX_UART2_BASE_PHYS,
1089 + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff,
1090 + .flags = IORESOURCE_MEM
1094 +static struct plat_serial8250_port nslu2_uart_data[] = {
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,
1102 + .uartclk = IXP4XX_UART_XTAL,
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,
1111 + .uartclk = IXP4XX_UART_XTAL,
1115 +static struct platform_device nslu2_uart = {
1116 + .name = "serial8250",
1118 + .dev.platform_data = nslu2_uart_data,
1119 + .num_resources = 2,
1120 + .resource = nslu2_uart_resources
1123 +static struct platform_device *nslu2_devices[] __initdata = {
1124 + &nslu2_i2c_controller,
1129 +static void n2_power_off(void)
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
1137 +static void __init nslu2_init(void)
1139 + ixp4xx_sys_init();
1141 + pm_power_off = n2_power_off;
1142 + platform_add_devices(nslu2_devices, ARRAY_SIZE(nslu2_devices));
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?