tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: uftdi quirks for iCEBreaker FPGA



On Mon, 2024-10-07 at 04:49 -0700, Jason Thorpe wrote:
> That sounds reasonable.  Alternatively, perhaps the quirk match
> function could be made to use pmatch().

pmatch? That makes the code much simpler. 

So something like the following patch? The iCEBreaker FPGA uses a
different interface number from the extant quirks which is why the
appropriate ugenif* line in usbdevices.config matches against interface
? now.

Ngā mihi,
Lloyd

cvs diff: Diffing .
Index: uftdi.c
===================================================================
RCS file: /home/lloyd/NetBSD/cvs/mirror/src/sys/dev/usb/uftdi.c,v
retrieving revision 1.79
diff -u -r1.79 uftdi.c
--- uftdi.c     25 Apr 2024 01:33:03 -0000      1.79
+++ uftdi.c     7 Oct 2024 20:14:58 -0000
@@ -242,6 +242,20 @@
          .product_str  = "JTAG Debugger",
          .match_ret    = UMATCH_NONE,
        },
+       /*
+        * The iCEBreaker board (
https://1bitsquared.com/products/icebreaker)
+         * has two interfaces, one of which is meant to act as a
+         * regular USB serial port (interface 1), the other of which
+         * is meant for other protocols.
+        */
+       {
+         .vendor_id    = USB_VENDOR_FTDI,
+         .product_id   = USB_PRODUCT_FTDI_SERIAL_2232C,
+         .iface_no     = 0,
+         .vendor_str   = "1BitSquared",
+         .product_str  = "iCEBreaker *",
+         .match_ret    = UMATCH_NONE,
+       },
 };
 
 static int
@@ -265,7 +279,7 @@
                }
                if (q->product_str != NULL &&
                    (dev->ud_product == NULL ||
-                    strcmp(dev->ud_product, q->product_str) != 0)) {
+                    pmatch(dev->ud_product, q->product_str, NULL) !=
2)) {
                        continue;
                }
                /*
Index: usbdevices.config
===================================================================
RCS file:
/home/lloyd/NetBSD/cvs/mirror/src/sys/dev/usb/usbdevices.config,v
retrieving revision 1.43
diff -u -r1.43 usbdevices.config
--- usbdevices.config   26 Mar 2024 03:38:02 -0000      1.43
+++ usbdevices.config   7 Oct 2024 03:51:38 -0000
@@ -260,9 +260,9 @@
 ugenif* at uhub? vendor 0x1050 product 0x0406 configuration 1
interface 1
 ugenif* at uhub? vendor 0x1050 product 0x0407 configuration 1
interface 2
 
-# Tigard debug board (FT2232C-based).  This line is used in
conjunction
-# with a match quirk in uftdi.c.  The "flags 1" is important; normally
-# ugenif matches with higest priority, but we don't want that for all
-# FT2232C interfaces, only interfaces that go unclaimed by uftdi
(which
-# is what the match quirk ensures).
-ugenif* at uhub? vendor 0x0403 product 0x6010 configuration 1
interface 1 flags 1
+# This line is used in conjunction with a match quirk in uftdi.c.  The
+# "flags 1" is important; normally ugenif matches with higest
+# priority, but we don't want that for all FT2232C interfaces, only
+# interfaces that go unclaimed by uftdi (which is what the match quirk
+# ensures).
+ugenif* at uhub? vendor 0x0403 product 0x6010 configuration 1
interface ? flags 1


Home | Main Index | Thread Index | Old Index