Re: tested ehci driver with 5-current/IBM ThinkPad240

From: Bob Bishop <rb_at_gid.co.uk>
Date: Tue, 15 Apr 2003 16:11:23 +0100
Hi,

At 16:04 15/4/03, MIHIRA Sanpei Yoshiro wrote:
>Hi.
>Bernd Walter
>
>   I tested USB to CardBus Card with 5-current. But I couldn't use
>it.  This CardBus Card could be used with NetBSD-current.  Do you
>have any idea?
>
>USB 2.0 2 Port CardBus Host Adapter
>http://www.avlab.com.tw/u_0046_001.htm
>
>dmesg with 5-current
>cardbus0: Resource not specified in CIS: id=10, size=1000
>ohci0: <NEC uPD 9210 USB controller> mem 0x88001000-0x88001fff irq 11 at 
>device 0.0 on cardbus0
>usb1: OHCI version 15.15, legacy support
>                    ~~~~~ wrong number, why??

I had the same problem, the card memory isn't enabled. This may be related 
to the thread "Workaround for some broken BIOSes that forgot to enable...". 
The following patch works around it (for the OHCI part at least), but it's 
a nasty hack:

Index: ohci.c
===================================================================
RCS file: /CVSROOT/src/sys/dev/usb/ohci.c,v
retrieving revision 1.118
diff -u -r1.118 ohci.c
--- ohci.c      5 Mar 2003 13:17:15 -0000       1.118
+++ ohci.c      26 Mar 2003 10:27:57 -0000
_at__at_ -690,12 +690,16 _at__at_
         u_int32_t s, ctl, ival, hcr, fm, per, rev, desca;

         DPRINTF(("ohci_init: start\n"));
+       rev = OREAD4(sc, OHCI_REVISION);
+       if (!OHCI_REV_HI(rev) || OHCI_REV_HI(rev) == 15)
+               /* looks like memory access isn't enabled */
+               return USBD_NOT_CONFIGURED;
+
  #if defined(__OpenBSD__)
         printf(",");
  #else
         printf("%s:", USBDEVNAME(sc->sc_bus.bdev));
  #endif
-       rev = OREAD4(sc, OHCI_REVISION);
         printf(" OHCI version %d.%d%s\n", OHCI_REV_HI(rev), OHCI_REV_LO(rev),
                OHCI_REV_LEGACY(rev) ? ", legacy support" : "");

Index: ohci_pci.c
===================================================================
RCS file: /CVSROOT/src/sys/dev/usb/ohci_pci.c,v
retrieving revision 1.30
diff -u -r1.30 ohci_pci.c
--- ohci_pci.c  28 Feb 2003 13:21:17 -0000      1.30
+++ ohci_pci.c  28 Mar 2003 11:06:47 -0000
_at__at_ -239,6 +239,20 _at__at_
                 return ENXIO;
         }
         err = ohci_init(sc);
+       if (err == USBD_NOT_CONFIGURED) {
+               /* XXXX nasty hack */
+               /* memory access probably disabled - uPD720101 companion
+                * controllers on cardbus have been seen doing this.
+                * Try enabling it here...
+                */
+               u_int32_t device_id = pci_get_devid(self);
+               if (device_id == PCI_OHCI_DEVICEID_NEC) {
+                       int cmd = pci_read_config(self, PCIR_COMMAND, 4);
+                       pci_write_config(self, PCIR_COMMAND, 
cmd|PCIM_CMD_MEMEN, 4);
+               }
+               /* ... and retry the init */
+               err = ohci_init(sc);
+       }
         if (!err)
                 err = device_probe_and_attach(sc->sc_bus.bdev);


>usb1: unsupported OHCI revision
>ohci0: USB init failed
>device_probe_and_attach: ohci0 attach returned 5
>cardbus0: Resource not specified in CIS: id=10, size=1000
>ohci0: <NEC uPD 9210 USB controller> mem 0x88001000-0x88001fff irq 11 at 
>device 0.1 on cardbus0
>usb1: OHCI version 15.15, legacy support
>usb1: unsupported OHCI revision
>ohci0: USB init failed
>device_probe_and_attach: ohci0 attach returned5
>cardbus0: Resource not specified in CIS: id=10, size=100
>ehci0: <NEC uPD 720100 USB 2.0 controller> mem 0x88001000-0x880010ff irq 
>11 at device 0.2 on cardbus0
>usb1: EHCI version ff.ff
>                    ~~~~~ wrong number, why??
>usb1: wrong number of companions (15 != 0)
>ehci0: USB init failed err=13
>device_probe_and_attach: ehci0 attach returned5
>cardbus0: release_all_resource: Resource still
>owned by child, oops. (type=1, rid=0, addr=b)
>cardbus0: release_all_resource: Resource still
>owned by child, oops. (type=3, rid=16, addr=88001000)
>cbb0: CardBus card activation failed
>
>----------
>dmesg with NetBSD-current
>cbb0: bad Vcc request. sock_ctrl 0x0, sock_status 0x30000326
>cbb0: bad Vcc request. sock_ctrl 0x30, sock_status 0x30000b20
>ohci0 at cardbus0 dev 0 function 0: NEC USB Host Controller (rev. 0x41)
>ohci0: interrupting at 11
>ohci0: OHCI version 1.0
>usb1 at ohci0: USB revision 1.0
>uhub1 at usb1
>uhub1: NEC OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
>uhub1: 3 ports with 3 removable, self powered
>ohci1 at cardbus0 dev 0 function 1: NEC USB Host Controller (rev. 0x41)
>ohci1: interrupting at 11
>ohci1: OHCI version 1.0
>usb2 at ohci1: USB revision 1.0
>uhub2 at usb2
>uhub2: NEC OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
>uhub2: 2 ports with 2 removable, self powered
>ehci0 at cardbus0 dev 0 function 2: NEC USB Host Controller (rev. 0x02)
>ehci0: interrupting at 11
>ehci0: EHCI version 0.95
>ehci0: companion controllers, 3 ports each: ohci0 ohci1
>usb3 at ehci0: USB revision 2.0
>uhub3 at usb3
>uhub3: NEC EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
>uhub3: 5 ports with 5 removable, self powered
>---
>MIHIRA, Sanpei Yoshiro
>Tokyo, Japan.
>_______________________________________________
>freebsd-current_at_freebsd.org mailing list
>http://lists.freebsd.org/mailman/listinfo/freebsd-current
>To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"


--
Bob Bishop		    +44 (0)118 977 4017
rb_at_gid.co.uk		fax +44 (0)118 989 4254
Received on Tue Apr 15 2003 - 06:11:56 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:03 UTC