On 27/01/13(Sun) 16:13, Raphael Graf wrote:
> The diff below makes the jtag and serial interfaces of the beaglebone 
> (FT2232H)
> work simultaneously.
> This is how the beaglebone shows up:
> 
> uhub8 at uhub0 port 1 "Standard Microsystems product 0x2412" rev 2.00/b.b2 
> addr 3
> uftdi0 at uhub8 port 1 configuration 1 interface 1 "FTDI BeagleBone/XDS100V2" 
> rev 2.00/7.00 addr 4
> ucom0 at uftdi0 portno 2
> ugen0 at uhub8 port 1 configuration 1 "FTDI BeagleBone/XDS100V2" rev 
> 2.00/7.00 addr 4
> 
> Like this, openocd (using ugen) and cu both work.
> 
> It is just assumed that interface 0 is used for jtag, not sure if this is
> always true. I'm also unsure if the diff would break other devices.
> Can someone comment on this?

Your diff looks correct and after looking at how the USB drivers are
matched it seems obvious to me that changing the configuration in this
function is not the right thing to do. 

I just rewrote your diff to keep only one (iface == NULL) check, I think
it is clearer like that. Are you ok with this version?

Tested with:
uftdi0 at uhub3 port 1 configuration 1 interface 0 "FTDI USB Serial Converter" 
rev 2.00/6.00 addr 2

M.

Index: uftdi.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/usb/uftdi.c,v
retrieving revision 1.63
diff -u -p -r1.63 uftdi.c
--- uftdi.c     11 Sep 2012 16:04:44 -0000      1.63
+++ uftdi.c     30 Jan 2013 09:28:59 -0000
@@ -748,39 +748,29 @@ int
 uftdi_match(struct device *parent, void *match, void *aux)
 {
        struct usb_attach_arg *uaa = aux;
-       usbd_status err;
-       u_int8_t nifaces;
 
-       if (usb_lookup(uftdi_devs, uaa->vendor, uaa->product) == NULL)
+       /*
+        * Only attach when looping against interfaces to allow ugen(4)
+        * to take over the interface 0, JTAG on USB on some models.
+        */
+       if (uaa->iface == NULL)
                return (UMATCH_NONE);
 
-       /* Get the number of interfaces. */
-       if (uaa->iface != NULL) {
-               nifaces = uaa->nifaces;
-       } else {
-               err = usbd_set_config_index(uaa->device, UFTDI_CONFIG_INDEX, 1);
-               if (err)
-                       return (UMATCH_NONE);
-               err = usbd_interface_count(uaa->device, &nifaces);
-               if (err)
-                       return (UMATCH_NONE);
-               usbd_set_config_index(uaa->device, USB_UNCONFIG_INDEX, 1);
-       }
+       if (usb_lookup(uftdi_devs, uaa->vendor, uaa->product) == NULL)
+               return (UMATCH_NONE);
 
        /* JTAG on USB interface 0 */
        if (uaa->vendor == USB_VENDOR_FTDI &&
-           uaa->product == USB_PRODUCT_FTDI_OPENRD &&
+           (uaa->product == USB_PRODUCT_FTDI_OPENRD ||
+           uaa->product == USB_PRODUCT_FTDI_SERIAL_2232C) &&
            uaa->ifaceno == 0)
                return (UMATCH_NONE);
 
-       if (nifaces <= 1)
+       if (uaa->nifaces <= 1)
                return (UMATCH_VENDOR_PRODUCT);
 
        /* Dual UART chip */
-       if (uaa->iface != NULL)
-               return (UMATCH_VENDOR_IFACESUBCLASS);
-       else
-               return (UMATCH_NONE);
+       return (UMATCH_VENDOR_IFACESUBCLASS);
 }
 
 void

Reply via email to