Subject: Re: USB card with NetBSD 4.0beta
To: None <fox@tcnet.ch, tsutsui@ceres.dti.ne.jp>
From: KIYOHARA Takashi <kiyohara@kk.iij4u.or.jp>
List: port-cobalt
Date: 09/08/2007 03:43:33
----Next_Part(Sat_Sep__8_03_43_33_2007_453)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi!


From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Date: Fri, 7 Sep 2007 21:17:41 +0900

> [well, your mail seems caught by a filter due to html attachment]
> 
> In article <46D9B6C1.1060400@tcnet.ch>
> fox@tcnet.ch wrote:
> 
> > When i enable ehci in der kernel by:
> > 
> > ehci*  at pci? dev ? function ?        # Enhanced Host Controller
> > 
> > i get a panic on kernel load
> > 
> > Cobalt Qube 2

... snip ...

> > uhci0 at pci0 dev 9 function 2: VIA Technologies VT83C572 USB Controller 
> > (rev. 0x02)
> > uhci0: can't map i/o space
> > ohci0 at pci0 dev 10 function 0: NEC USB Host Controller (rev. 0x41)
> > ohci0: interrupting at irq 9
> > ohci0: OHCI version 1.0
> > usb0 at ohci0: USB revision 1.0
> > uhub0 at usb0
> > uhub0: NEC OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
> > uhub0: 3 ports with 3 removable, self powered
> > ohci1 at pci0 dev 10 function 1: NEC USB Host Controller (rev. 0x41)
> > ohci1: interrupting at irq 0
> > ohci1: OHCI version 1.0
> > usb1 at ohci1: USB revision 1.0
> > uhub1 at usb1
> > uhub1: NEC OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
> > uhub1: 2 ports with 2 removable, self powered
> > ehci0 at pci0 dev 10 function 2: NEC USB Host Controller (rev. 0x02)
> > panic: icu_intr_establish(): irq 0 is already in use
> > Stopped in pid 0.1 (swapper) at netbsd:cpu_Debugger+0x4:        jr      ra
> >                 bdslot: nop
> > db>
> > 
> > 
> > What i do not really understand is, that this usb card was working with 
> > NetBSD 3.0 and the instruction i wrote here: 
> > http://www.aironaut.ch/content/view/19/53/
> > 
> > And now with 4.0 it doesn't, so i think i missed something important in 
> > my description :-(
> > 
> > I'll just comile a kernel with pci and and without ehci, but my poor 
> > little qube is working a while on this :-)
> > 
> > Andreas

I had seen it before.

  http://mail-index.netbsd.org/port-cobalt/2006/10/09/0001.html

I am working USB and IEEE1394 with this patch now.

Thanks,
--
kiyohara


----Next_Part(Sat_Sep__8_03_43_33_2007_453)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="pci-mulltifunction.diff"

Index: sys/arch/cobalt/cobalt/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/cobalt/cobalt/machdep.c,v
retrieving revision 1.87
diff -u -r1.87 machdep.c
--- sys/arch/cobalt/cobalt/machdep.c	10 Aug 2007 17:44:18 -0000	1.87
+++ sys/arch/cobalt/cobalt/machdep.c	6 Sep 2007 15:38:44 -0000
@@ -66,6 +66,7 @@
 #include <sys/reboot.h>
 #include <sys/user.h>
 #include <sys/mount.h>
+#include <sys/malloc.h>
 #include <sys/kcore.h>
 #include <sys/boot_flag.h>
 #include <sys/ksyms.h>
@@ -538,8 +539,10 @@
 	struct cobalt_intrhand *ih;
 
 	ih = &icu_intrtab[irq];
-	if (ih->ih_func != NULL)
-		panic("icu_intr_establish(): irq %d is already in use", irq);
+	if (ih->ih_func != NULL) {
+		ih = malloc(sizeof(*ih), M_DEVBUF, M_NOWAIT);
+		LIST_INSERT_AFTER(&icu_intrtab[irq], ih, ih_q);
+	}
 
 	ih->ih_cookie_type = COBALT_COOKIE_TYPE_ICU;
 	ih->ih_func = func;
@@ -617,11 +620,12 @@
 
 	handled = 0;
 
+poll:
 	/* check requested irq */
 	ICU1_WRITE(PIC_OCW3, OCW3_SELECT | OCW3_POLL);
 	irq = ICU1_READ(PIC_OCW3);
 	if ((irq & OCW3_POLL_PENDING) == 0)
-		goto out;
+		return handled;
 
 	irq = OCW3_POLL_IRQ(irq);
 	if (irq == IRQ_SLAVE) {
@@ -629,12 +633,14 @@
 		irq = OCW3_POLL_IRQ(ICU2_READ(PIC_OCW3)) + 8;
 	}
 
-	ih = &icu_intrtab[irq];
-	if (__predict_false(ih->ih_func == NULL)) {
-		printf("icu_intr(): spurious interrupt (irq = %d)\n", irq);
-	} else if (__predict_true((*ih->ih_func)(ih->ih_arg))) {
-		ih->ih_evcnt.ev_count++;
-		handled = 1;
+	for (ih = &icu_intrtab[irq]; ih != NULL; ih = LIST_NEXT(ih, ih_q)) {
+		if (__predict_false(ih->ih_func == NULL))
+			printf("icu_intr(): spurious interrupt (irq = %d)\n",
+			    irq);
+		else if (__predict_true((*ih->ih_func)(ih->ih_arg))) {
+			ih->ih_evcnt.ev_count++;
+			handled = 1;
+		}
 	}
 
 	/* issue EOI to ack */
@@ -645,8 +651,8 @@
 	}
 	ICU1_WRITE(PIC_OCW2, OCW2_SELECT | OCW2_SL | OCW2_EOI | OCW2_ILS(irq));
 
- out:
-	return handled;
+	goto poll;
+	/* NOTREACHED */
 }
 
 void *
Index: sys/arch/cobalt/conf/majors.cobalt
===================================================================
RCS file: /cvsroot/src/sys/arch/cobalt/conf/majors.cobalt,v
retrieving revision 1.19
diff -u -r1.19 majors.cobalt
--- sys/arch/cobalt/conf/majors.cobalt	4 Mar 2007 10:35:19 -0000	1.19
+++ sys/arch/cobalt/conf/majors.cobalt	6 Sep 2007 15:38:44 -0000
@@ -42,6 +42,13 @@
 device-major	panel		char 36			panel
 device-major	ksyms		char 37			ksyms
 device-major	pci		char 38			pci
+device-major	usb		char 55			usb
+device-major	uhid		char 56			uhid
+device-major	ulpt		char 57			ulpt
+device-major	ugen		char 64			ugen
+device-major	ucom		char 66			ucom
+device-major	urio		char 70			urio
+device-major	uscanner	char 75			uscanner
 device-major	altq		char 77			altq
 
 device-major	nsmb		char 98			nsmb
Index: sys/arch/cobalt/pci/pci_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/cobalt/pci/pci_machdep.c,v
retrieving revision 1.25
diff -u -r1.25 pci_machdep.c
--- sys/arch/cobalt/pci/pci_machdep.c	18 Feb 2007 12:22:16 -0000	1.25
+++ sys/arch/cobalt/pci/pci_machdep.c	6 Sep 2007 15:38:44 -0000
@@ -166,6 +166,8 @@
 			*ihp = 16 + 1;
 		else if (bus == 0 && dev == 12 && pin == PCI_INTERRUPT_PIN_A)
 			*ihp = 16 + 2;
+		else if (bus == 0 && dev == 10 && line == 0)
+			*ihp = 9;
 		else
 			*ihp = line;
 	}

----Next_Part(Sat_Sep__8_03_43_33_2007_453)----