From: visa Date: Mon, 13 Dec 2021 13:57:48 +0000 (+0000) Subject: Handle multi-port controllers in uslcom(4) X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9f9a31e0581656c5141187e579c27be5e04cf08d;p=openbsd Handle multi-port controllers in uslcom(4) A multi-port CP210x device presents each COM port as a separate USB virtual COM port interface. When attaching uslcom(4), take the USB interface from the attach arguments instead of using interface 0. This lets the driver access the different ports of a quad-port CP2108. Tested with a single-port CP2102 by jsg@ OK jsg@ deraadt@ --- diff --git a/share/man/man4/uslcom.4 b/share/man/man4/uslcom.4 index 696b1fc31d8..349768665da 100644 --- a/share/man/man4/uslcom.4 +++ b/share/man/man4/uslcom.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: uslcom.4,v 1.15 2019/04/26 06:02:10 remi Exp $ +.\" $OpenBSD: uslcom.4,v 1.16 2021/12/13 13:57:48 visa Exp $ .\" .\" Copyright (c) 2006 Jonathan Gray .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: April 26 2019 $ +.Dd $Mdocdate: December 13 2021 $ .Dt USLCOM 4 .Os .Sh NAME @@ -26,12 +26,12 @@ .Sh DESCRIPTION The .Nm -driver supports Silicon Laboratories CP2101/CP2102/CP2103/CP2104/CP2105 +driver supports Silicon Laboratories CP2101/CP2102/CP2103/CP2104/CP2105/CP2108 based serial adapters. .Pp The CP2101/CP2102/CP2103 devices only support a variety of baud rates up to 921600. -CP2104 and CP2105 devices support any baud rate up to 2 Mbps. +CP2104, CP2105 and CP2108 devices support any baud rate up to 2 Mbps. .Pp The following devices should work with the .Nm diff --git a/sys/dev/usb/uslcom.c b/sys/dev/usb/uslcom.c index 6f41cf539a9..bafd5479adf 100644 --- a/sys/dev/usb/uslcom.c +++ b/sys/dev/usb/uslcom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uslcom.c,v 1.42 2020/01/05 00:54:13 jsg Exp $ */ +/* $OpenBSD: uslcom.c,v 1.43 2021/12/13 13:57:48 visa Exp $ */ /* * Copyright (c) 2006 Jonathan Gray @@ -38,7 +38,6 @@ int uslcomdebug = 0; #define DPRINTF(x) DPRINTFN(0, x) #define USLCOMBUFSZ 256 -#define USLCOM_IFACE_NO 0 #define USLCOM_SET_DATA_BITS(x) (x << 8) @@ -292,21 +291,11 @@ uslcom_attach(struct device *parent, struct device *self, void *aux) struct ucom_attach_args uca; usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; - usbd_status error; int i; bzero(&uca, sizeof(uca)); sc->sc_udev = uaa->device; - - /* get the first interface handle */ - error = usbd_device2interface_handle(sc->sc_udev, USLCOM_IFACE_NO, - &sc->sc_iface); - if (error != 0) { - printf("%s: could not get interface handle\n", - sc->sc_dev.dv_xname); - usbd_deactivate(sc->sc_udev); - return; - } + sc->sc_iface = uaa->iface; id = usbd_get_interface_descriptor(sc->sc_iface); @@ -334,6 +323,7 @@ uslcom_attach(struct device *parent, struct device *self, void *aux) return; } + uca.portno = id->bInterfaceNumber; uca.ibufsize = USLCOMBUFSZ; uca.obufsize = USLCOMBUFSZ; uca.ibufsizepad = USLCOMBUFSZ;