Module Name:    src
Committed By:   lloyd
Date:           Tue Oct  8 20:40:10 UTC 2024

Modified Files:
        src/sys/dev/usb: uftdi.c usbdevices.config

Log Message:
Add a match quirk matching interface 0 on an iCEBreaker FPGA board

This board has an FTDI 2232C with port A (USB interface 0) connected
to the SPI Flash memory for programming and port B (USB interface 1)
connected to the FPGA's serial lines.

The quirk matching was adjusted to use pmatch(9) because the
iCEBreaker product string contains a version number which changes from
time to time.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/dev/usb/uftdi.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/usb/usbdevices.config

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/uftdi.c
diff -u src/sys/dev/usb/uftdi.c:1.79 src/sys/dev/usb/uftdi.c:1.80
--- src/sys/dev/usb/uftdi.c:1.79	Thu Apr 25 01:33:03 2024
+++ src/sys/dev/usb/uftdi.c	Tue Oct  8 20:40:10 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: uftdi.c,v 1.79 2024/04/25 01:33:03 thorpej Exp $	*/
+/*	$NetBSD: uftdi.c,v 1.80 2024/10/08 20:40:10 lloyd Exp $	*/
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.79 2024/04/25 01:33:03 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.80 2024/10/08 20:40:10 lloyd Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -242,6 +242,20 @@ static const struct uftdi_match_quirk_en
 	  .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 @@ uftdi_quirk_match(struct usbif_attach_ar
 		}
 		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: src/sys/dev/usb/usbdevices.config
diff -u src/sys/dev/usb/usbdevices.config:1.43 src/sys/dev/usb/usbdevices.config:1.44
--- src/sys/dev/usb/usbdevices.config:1.43	Tue Mar 26 03:38:02 2024
+++ src/sys/dev/usb/usbdevices.config	Tue Oct  8 20:40:10 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: usbdevices.config,v 1.43 2024/03/26 03:38:02 thorpej Exp $
+#	$NetBSD: usbdevices.config,v 1.44 2024/10/08 20:40:10 lloyd Exp $
 #
 # This file contains all USB related configuration.
 # It is suitable for inclusion in a kernel config(5) file.
@@ -260,9 +260,9 @@ ugenif* at uhub? vendor 0x1050 product 0
 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

Reply via email to