| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: uftdi.c,v 1.78 2024/04/17 02:34:45 maya Exp $ */ | | 1 | /* $NetBSD: uftdi.c,v 1.79 2024/04/25 01:33:03 thorpej Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2000 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Lennart Augustsson (lennart@augustsson.net). | | 8 | * by Lennart Augustsson (lennart@augustsson.net). |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.78 2024/04/17 02:34:45 maya Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: uftdi.c,v 1.79 2024/04/25 01:33:03 thorpej Exp $"); |
34 | | | 34 | |
35 | #ifdef _KERNEL_OPT | | 35 | #ifdef _KERNEL_OPT |
36 | #include "opt_usb.h" | | 36 | #include "opt_usb.h" |
37 | #endif | | 37 | #endif |
38 | | | 38 | |
39 | #include <sys/param.h> | | 39 | #include <sys/param.h> |
40 | #include <sys/systm.h> | | 40 | #include <sys/systm.h> |
41 | #include <sys/kernel.h> | | 41 | #include <sys/kernel.h> |
42 | #include <sys/device.h> | | 42 | #include <sys/device.h> |
43 | #include <sys/conf.h> | | 43 | #include <sys/conf.h> |
44 | #include <sys/tty.h> | | 44 | #include <sys/tty.h> |
45 | | | 45 | |
46 | #include <dev/usb/usb.h> | | 46 | #include <dev/usb/usb.h> |
| @@ -219,41 +219,53 @@ static const struct uftdi_match_quirk_en | | | @@ -219,41 +219,53 @@ static const struct uftdi_match_quirk_en |
219 | * has two interfaces, one of which is meant to act as a | | 219 | * has two interfaces, one of which is meant to act as a |
220 | * regular USB serial port (interface 0), the other of which | | 220 | * regular USB serial port (interface 0), the other of which |
221 | * is meant for other protocols (SWD, JTAG, etc.). We must | | 221 | * is meant for other protocols (SWD, JTAG, etc.). We must |
222 | * reject interface 1 so that ugenif matches, thus allowing | | 222 | * reject interface 1 so that ugenif matches, thus allowing |
223 | * full user-space control of that port. | | 223 | * full user-space control of that port. |
224 | */ | | 224 | */ |
225 | { | | 225 | { |
226 | .vendor_id = USB_VENDOR_FTDI, | | 226 | .vendor_id = USB_VENDOR_FTDI, |
227 | .product_id = USB_PRODUCT_FTDI_SERIAL_2232C, | | 227 | .product_id = USB_PRODUCT_FTDI_SERIAL_2232C, |
228 | .iface_no = 1, | | 228 | .iface_no = 1, |
229 | .vendor_str = "SecuringHardware.com", | | 229 | .vendor_str = "SecuringHardware.com", |
230 | .product_str = "Tigard V1.1", | | 230 | .product_str = "Tigard V1.1", |
231 | .match_ret = UMATCH_NONE, | | 231 | .match_ret = UMATCH_NONE, |
232 | } | | 232 | }, |
| | | 233 | /* |
| | | 234 | * The SiPEED Tang Nano 9K (and other SiPEED Tang FPGA development |
| | | 235 | * boards) have an FT2232 on-board, wired up only for JTAG. |
| | | 236 | */ |
| | | 237 | { |
| | | 238 | .vendor_id = USB_VENDOR_FTDI, |
| | | 239 | .product_id = USB_PRODUCT_FTDI_SERIAL_2232C, |
| | | 240 | .iface_no = -1, |
| | | 241 | .vendor_str = "SIPEED", |
| | | 242 | .product_str = "JTAG Debugger", |
| | | 243 | .match_ret = UMATCH_NONE, |
| | | 244 | }, |
233 | }; | | 245 | }; |
234 | | | 246 | |
235 | static int | | 247 | static int |
236 | uftdi_quirk_match(struct usbif_attach_arg *uiaa, int rv) | | 248 | uftdi_quirk_match(struct usbif_attach_arg *uiaa, int rv) |
237 | { | | 249 | { |
238 | struct usbd_device *dev = uiaa->uiaa_device; | | 250 | struct usbd_device *dev = uiaa->uiaa_device; |
239 | const struct uftdi_match_quirk_entry *q; | | 251 | const struct uftdi_match_quirk_entry *q; |
240 | int i; | | 252 | int i; |
241 | | | 253 | |
242 | for (i = 0; i < __arraycount(uftdi_match_quirks); i++) { | | 254 | for (i = 0; i < __arraycount(uftdi_match_quirks); i++) { |
243 | q = &uftdi_match_quirks[i]; | | 255 | q = &uftdi_match_quirks[i]; |
244 | if (uiaa->uiaa_vendor != q->vendor_id || | | 256 | if (uiaa->uiaa_vendor != q->vendor_id || |
245 | uiaa->uiaa_product != q->product_id || | | 257 | uiaa->uiaa_product != q->product_id || |
246 | uiaa->uiaa_ifaceno != q->iface_no) { | | 258 | (q->iface_no != -1 && uiaa->uiaa_ifaceno != q->iface_no)) { |
247 | continue; | | 259 | continue; |
248 | } | | 260 | } |
249 | if (q->vendor_str != NULL && | | 261 | if (q->vendor_str != NULL && |
250 | (dev->ud_vendor == NULL || | | 262 | (dev->ud_vendor == NULL || |
251 | strcmp(dev->ud_vendor, q->vendor_str) != 0)) { | | 263 | strcmp(dev->ud_vendor, q->vendor_str) != 0)) { |
252 | continue; | | 264 | continue; |
253 | } | | 265 | } |
254 | if (q->product_str != NULL && | | 266 | if (q->product_str != NULL && |
255 | (dev->ud_product == NULL || | | 267 | (dev->ud_product == NULL || |
256 | strcmp(dev->ud_product, q->product_str) != 0)) { | | 268 | strcmp(dev->ud_product, q->product_str) != 0)) { |
257 | continue; | | 269 | continue; |
258 | } | | 270 | } |
259 | /* | | 271 | /* |