[Midnightbsd-cvs] src [10048] trunk/sys/dev/usb/serial: sync with freebsd 10 stable

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun May 27 18:42:01 EDT 2018


Revision: 10048
          http://svnweb.midnightbsd.org/src/?rev=10048
Author:   laffer1
Date:     2018-05-27 18:42:00 -0400 (Sun, 27 May 2018)
Log Message:
-----------
sync with freebsd 10 stable

Modified Paths:
--------------
    trunk/sys/dev/usb/serial/u3g.c
    trunk/sys/dev/usb/serial/uark.c
    trunk/sys/dev/usb/serial/ubsa.c
    trunk/sys/dev/usb/serial/ubser.c
    trunk/sys/dev/usb/serial/uchcom.c
    trunk/sys/dev/usb/serial/ucycom.c
    trunk/sys/dev/usb/serial/ufoma.c
    trunk/sys/dev/usb/serial/uftdi.c
    trunk/sys/dev/usb/serial/uftdi_reg.h
    trunk/sys/dev/usb/serial/ugensa.c
    trunk/sys/dev/usb/serial/uipaq.c
    trunk/sys/dev/usb/serial/ulpt.c
    trunk/sys/dev/usb/serial/umcs.c
    trunk/sys/dev/usb/serial/umcs.h
    trunk/sys/dev/usb/serial/umct.c
    trunk/sys/dev/usb/serial/umodem.c
    trunk/sys/dev/usb/serial/umoscom.c
    trunk/sys/dev/usb/serial/uplcom.c
    trunk/sys/dev/usb/serial/usb_serial.c
    trunk/sys/dev/usb/serial/usb_serial.h
    trunk/sys/dev/usb/serial/uslcom.c
    trunk/sys/dev/usb/serial/uvisor.c
    trunk/sys/dev/usb/serial/uvscom.c

Modified: trunk/sys/dev/usb/serial/u3g.c
===================================================================
--- trunk/sys/dev/usb/serial/u3g.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/u3g.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2008 AnyWi Technologies
  * Author: Andrea Guzzo <aguzzo at anywi.com>
@@ -16,7 +17,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $FreeBSD: stable/9/sys/dev/usb/serial/u3g.c 306958 2016-10-10 11:48:23Z hselasky $
+ * $FreeBSD: stable/10/sys/dev/usb/serial/u3g.c 329304 2018-02-15 08:57:14Z hselasky $
  */
 
 /*
@@ -205,6 +206,7 @@
 
 static const STRUCT_USB_HOST_ID u3g_devs[] = {
 #define	U3G_DEV(v,p,i) { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }
+	U3G_DEV(ABIT, AK_020, 0),
 	U3G_DEV(ACERP, H10, 0),
 	U3G_DEV(AIRPLUS, MCD650, 0),
 	U3G_DEV(AIRPRIME, PC5220, 0),
@@ -317,6 +319,7 @@
 	U3G_DEV(HUAWEI, E220BIS, U3GINIT_HUAWEI),
 	U3G_DEV(HUAWEI, E392, U3GINIT_HUAWEISCSI),
 	U3G_DEV(HUAWEI, ME909U, U3GINIT_HUAWEISCSI2),
+	U3G_DEV(HUAWEI, ME909S, U3GINIT_HUAWEISCSI2),
 	U3G_DEV(HUAWEI, MOBILE, U3GINIT_HUAWEI),
 	U3G_DEV(HUAWEI, E1752, U3GINIT_HUAWEISCSI),
 	U3G_DEV(HUAWEI, E1820, U3GINIT_HUAWEISCSI),
@@ -391,7 +394,6 @@
 	U3G_DEV(OPTION, GTMAXHSUPA, 0),
 	U3G_DEV(OPTION, GTMAXHSUPAE, 0),
 	U3G_DEV(OPTION, VODAFONEMC3G, 0),
-	U3G_DEV(OPTION, GTM661W, 0),
 	U3G_DEV(QISDA, H20_1, 0),
 	U3G_DEV(QISDA, H20_2, 0),
 	U3G_DEV(QISDA, H21_1, 0),
@@ -523,6 +525,8 @@
 	U3G_DEV(SIERRA, MC5727, 0),
 	U3G_DEV(SIERRA, MC5727_2, 0),
 	U3G_DEV(SIERRA, MC5728, 0),
+	U3G_DEV(SIERRA, MC7354, 0),
+	U3G_DEV(SIERRA, MC7355, 0),
 	U3G_DEV(SIERRA, MC7430, 0),
 	U3G_DEV(SIERRA, MC8700, 0),
 	U3G_DEV(SIERRA, MC8755, 0),

Modified: trunk/sys/dev/usb/serial/uark.c
===================================================================
--- trunk/sys/dev/usb/serial/uark.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/uark.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$OpenBSD: uark.c,v 1.1 2006/08/14 08:30:22 jsg Exp $	*/
 
 /*
@@ -15,7 +16,7 @@
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  *
- * $FreeBSD: stable/9/sys/dev/usb/serial/uark.c 240659 2012-09-18 16:28:49Z hselasky $
+ * $FreeBSD: stable/10/sys/dev/usb/serial/uark.c 253750 2013-07-28 18:44:17Z avg $
  */
 
 /*

Modified: trunk/sys/dev/usb/serial/ubsa.c
===================================================================
--- trunk/sys/dev/usb/serial/ubsa.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/ubsa.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2002, Alexander Kabaev <kan.FreeBSD.org>.
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/ubsa.c 263688 2014-03-24 13:50:11Z emaste $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/ubsa.c 263687 2014-03-24 13:48:04Z emaste $");
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.

Modified: trunk/sys/dev/usb/serial/ubser.c
===================================================================
--- trunk/sys/dev/usb/serial/ubser.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/ubser.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004 Bernd Walter <ticso at FreeBSD.org>
  *
@@ -63,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/ubser.c 263688 2014-03-24 13:50:11Z emaste $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/ubser.c 263687 2014-03-24 13:48:04Z emaste $");
 
 /*
  * BWCT serial adapter driver

Modified: trunk/sys/dev/usb/serial/uchcom.c
===================================================================
--- trunk/sys/dev/usb/serial/uchcom.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/uchcom.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: uchcom.c,v 1.1 2007/09/03 17:57:37 tshiozak Exp $	*/
 
 /*-
@@ -56,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/uchcom.c 263688 2014-03-24 13:50:11Z emaste $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/uchcom.c 263687 2014-03-24 13:48:04Z emaste $");
 
 /*
  * Driver for WinChipHead CH341/340, the worst USB-serial chip in the

Modified: trunk/sys/dev/usb/serial/ucycom.c
===================================================================
--- trunk/sys/dev/usb/serial/ucycom.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/ucycom.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,8 +1,9 @@
+/* $MidnightBSD$ */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/ucycom.c 240659 2012-09-18 16:28:49Z hselasky $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/ucycom.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 /*-
- * Copyright (c) 2004 Dag-Erling Co\xEFdan Sm\xF8rgrav
+ * Copyright (c) 2004 Dag-Erling Coïdan Smørgrav
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: trunk/sys/dev/usb/serial/ufoma.c
===================================================================
--- trunk/sys/dev/usb/serial/ufoma.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/ufoma.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,7 +1,8 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: umodem.c,v 1.45 2002/09/23 05:51:23 simonb Exp $	*/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/ufoma.c 263688 2014-03-24 13:50:11Z emaste $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/ufoma.c 263687 2014-03-24 13:48:04Z emaste $");
 #define UFOMA_HANDSFREE
 /*-
  * Copyright (c) 2005, Takanori Watanabe

Modified: trunk/sys/dev/usb/serial/uftdi.c
===================================================================
--- trunk/sys/dev/usb/serial/uftdi.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/uftdi.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: uftdi.c,v 1.13 2002/09/23 05:51:23 simonb Exp $	*/
 
 /*-
@@ -30,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/uftdi.c 283194 2015-05-21 07:50:56Z hselasky $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/uftdi.c 293209 2016-01-05 17:12:33Z ian $");
 
 /*
  * NOTE: all function names beginning like "uftdi_cfg_" can only
@@ -161,6 +162,7 @@
 	uint8_t	sc_hdrlen;
 	uint8_t	sc_msr;
 	uint8_t	sc_lsr;
+	uint8_t sc_bitmode;
 };
 
 struct uftdi_param_config {
@@ -196,7 +198,7 @@
 		    uint8_t *);
 static int	uftdi_reset(struct ucom_softc *, int);
 static int	uftdi_set_bitmode(struct ucom_softc *, uint8_t, uint8_t);
-static int	uftdi_get_bitmode(struct ucom_softc *, uint8_t *);
+static int	uftdi_get_bitmode(struct ucom_softc *, uint8_t *, uint8_t *);
 static int	uftdi_set_latency(struct ucom_softc *, int);
 static int	uftdi_get_latency(struct ucom_softc *, int *);
 static int	uftdi_set_event_char(struct ucom_softc *, int);
@@ -567,7 +569,7 @@
 	UFTDI_DEV(KOBIL, CONV_B1, 0),
 	UFTDI_DEV(KOBIL, CONV_KAAN, 0),
 	UFTDI_DEV(LARSENBRUSGAARD, ALTITRACK, 0),
-	UFTDI_DEV(MARVELL, SHEEVAPLUG, 0),
+	UFTDI_DEV(MARVELL, SHEEVAPLUG, UFTDI_JTAG_IFACE(0)),
 	UFTDI_DEV(MATRIXORBITAL, FTDI_RANGE_0100, 0),
 	UFTDI_DEV(MATRIXORBITAL, FTDI_RANGE_0101, 0),
 	UFTDI_DEV(MATRIXORBITAL, FTDI_RANGE_0102, 0),
@@ -1091,6 +1093,7 @@
 	sc->sc_udev = uaa->device;
 	sc->sc_dev = dev;
 	sc->sc_unit = device_get_unit(dev);
+	sc->sc_bitmode = UFTDI_BITMODE_NONE;
 
 	device_set_usb_desc(dev);
 	mtx_init(&sc->sc_mtx, "uftdi", NULL, MTX_DEF);
@@ -1682,6 +1685,7 @@
 {
 	struct uftdi_softc *sc = ucom->sc_parent;
 	usb_device_request_t req;
+	int rv;
 
 	req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
 	req.bRequest = FTDI_SIO_SET_BITMODE;
@@ -1694,16 +1698,20 @@
 	else
 	    USETW2(req.wValue, (1 << bitmode), iomask);
 
-	return (usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL));
+	rv = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL);
+	if (rv == USB_ERR_NORMAL_COMPLETION)
+		sc->sc_bitmode = bitmode;
+
+	return (rv);
 }
 
 static int
-uftdi_get_bitmode(struct ucom_softc *ucom, uint8_t *iomask)
+uftdi_get_bitmode(struct ucom_softc *ucom, uint8_t *bitmode, uint8_t *iomask)
 {
 	struct uftdi_softc *sc = ucom->sc_parent;
 	usb_device_request_t req;
 
-	req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
+	req.bmRequestType = UT_READ_VENDOR_DEVICE;
 	req.bRequest = FTDI_SIO_GET_BITMODE;
 
 	USETW(req.wIndex, sc->sc_ucom.sc_portno);
@@ -1710,6 +1718,7 @@
 	USETW(req.wLength, 1);
 	USETW(req.wValue,  0);
 
+	*bitmode = sc->sc_bitmode;
 	return (usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, iomask));
 }
 
@@ -1740,7 +1749,7 @@
 	usb_error_t err;
 	uint8_t buf;
 
-	req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
+	req.bmRequestType = UT_READ_VENDOR_DEVICE;
 	req.bRequest = FTDI_SIO_GET_LATENCY;
 
 	USETW(req.wIndex, sc->sc_ucom.sc_portno);
@@ -1792,6 +1801,82 @@
 }
 
 static int
+uftdi_read_eeprom(struct ucom_softc *ucom, struct uftdi_eeio *eeio)
+{
+	struct uftdi_softc *sc = ucom->sc_parent;
+	usb_device_request_t req;
+	usb_error_t err;
+	uint16_t widx, wlength, woffset;
+
+	/* Offset and length must both be evenly divisible by two. */
+	if ((eeio->offset | eeio->length) & 0x01)
+		return (EINVAL);
+
+	woffset = eeio->offset / 2U;
+	wlength = eeio->length / 2U;
+	for (widx = 0; widx < wlength; widx++) {
+		req.bmRequestType = UT_READ_VENDOR_DEVICE;
+		req.bRequest = FTDI_SIO_READ_EEPROM;
+		USETW(req.wIndex, widx + woffset);
+		USETW(req.wLength, 2);
+		USETW(req.wValue, 0);
+		err = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req,
+		    &eeio->data[widx]);
+		if (err != USB_ERR_NORMAL_COMPLETION)
+			return (err);
+	}
+	return (USB_ERR_NORMAL_COMPLETION);
+}
+
+static int
+uftdi_write_eeprom(struct ucom_softc *ucom, struct uftdi_eeio *eeio)
+{
+	struct uftdi_softc *sc = ucom->sc_parent;
+	usb_device_request_t req;
+	usb_error_t err;
+	uint16_t widx, wlength, woffset;
+
+	/* Offset and length must both be evenly divisible by two. */
+	if ((eeio->offset | eeio->length) & 0x01)
+		return (EINVAL);
+
+	woffset = eeio->offset / 2U;
+	wlength = eeio->length / 2U;
+	for (widx = 0; widx < wlength; widx++) {
+		req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
+		req.bRequest = FTDI_SIO_WRITE_EEPROM;
+		USETW(req.wIndex, widx + woffset);
+		USETW(req.wLength, 0);
+		USETW(req.wValue, eeio->data[widx]);
+		err = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL);
+		if (err != USB_ERR_NORMAL_COMPLETION)
+			return (err);
+	}
+	return (USB_ERR_NORMAL_COMPLETION);
+}
+
+static int
+uftdi_erase_eeprom(struct ucom_softc *ucom, int confirmation)
+{
+	struct uftdi_softc *sc = ucom->sc_parent;
+	usb_device_request_t req;
+	usb_error_t err;
+
+	/* Small effort to prevent accidental erasure. */
+	if (confirmation != UFTDI_CONFIRM_ERASE)
+		return (EINVAL);
+
+	req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
+	req.bRequest = FTDI_SIO_ERASE_EEPROM;
+	USETW(req.wIndex, 0);
+	USETW(req.wLength, 0);
+	USETW(req.wValue, 0);
+	err = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL);
+
+	return (err);
+}
+
+static int
 uftdi_ioctl(struct ucom_softc *ucom, uint32_t cmd, caddr_t data,
     int flag, struct thread *td)
 {
@@ -1816,7 +1901,7 @@
 		break;
 	case UFTDIIOC_GET_BITMODE:
 		mode = (struct uftdi_bitmode *)data;
-		err = uftdi_get_bitmode(ucom, &mode->iomask);
+		err = uftdi_get_bitmode(ucom, &mode->mode, &mode->iomask);
 		break;
 	case UFTDIIOC_SET_LATENCY:
 		err = uftdi_set_latency(ucom, *((int *)data));
@@ -1834,6 +1919,15 @@
 		*(int *)data = sc->sc_bcdDevice;
 		err = 0;
 		break;
+	case UFTDIIOC_READ_EEPROM:
+		err = uftdi_read_eeprom(ucom, (struct uftdi_eeio *)data);
+		break;
+	case UFTDIIOC_WRITE_EEPROM:
+		err = uftdi_write_eeprom(ucom, (struct uftdi_eeio *)data);
+		break;
+	case UFTDIIOC_ERASE_EEPROM:
+		err = uftdi_erase_eeprom(ucom, *(int *)data);
+		break;
 	default:
 		return (ENOIOCTL);
 	}

Modified: trunk/sys/dev/usb/serial/uftdi_reg.h
===================================================================
--- trunk/sys/dev/usb/serial/uftdi_reg.h	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/uftdi_reg.h	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: uftdireg.h,v 1.6 2002/07/11 21:14:28 augustss Exp $ */
-/*	$FreeBSD: stable/9/sys/dev/usb/serial/uftdi_reg.h 273888 2014-10-31 08:00:22Z hselasky $	*/
+/*	$FreeBSD: stable/10/sys/dev/usb/serial/uftdi_reg.h 287035 2015-08-23 16:17:00Z ian $	*/
 
 /*
  * Definitions for the FTDI USB Single Port Serial Converter -
@@ -31,7 +32,10 @@
 #define	FTDI_SIO_SET_LATENCY	9	/* Set the latency timer */
 #define	FTDI_SIO_GET_LATENCY	10	/* Read the latency timer */
 #define	FTDI_SIO_SET_BITMODE	11	/* Set the bit bang I/O mode */
-#define	FTDI_SIO_GET_BITMODE	12	/* Read pin states in bit bang mode */
+#define	FTDI_SIO_GET_BITMODE	12	/* Read pin states from any mode */
+#define	FTDI_SIO_READ_EEPROM	144	/* Read eeprom word */
+#define	FTDI_SIO_WRITE_EEPROM	145	/* Write eeprom word */
+#define	FTDI_SIO_ERASE_EEPROM	146	/* Erase entire eeprom */
 
 /* Port Identifier Table */
 #define	FTDI_PIT_DEFAULT 	0	/* SIOA */

Modified: trunk/sys/dev/usb/serial/ugensa.c
===================================================================
--- trunk/sys/dev/usb/serial/ugensa.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/ugensa.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,4 +1,5 @@
-/* $FreeBSD: stable/9/sys/dev/usb/serial/ugensa.c 240659 2012-09-18 16:28:49Z hselasky $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/usb/serial/ugensa.c 239299 2012-08-15 15:42:57Z hselasky $ */
 /*	$NetBSD: ugensa.c,v 1.9.2.1 2007/03/24 14:55:50 yamt Exp $	*/
 
 /*

Modified: trunk/sys/dev/usb/serial/uipaq.c
===================================================================
--- trunk/sys/dev/usb/serial/uipaq.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/uipaq.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: uipaq.c,v 1.4 2006/11/16 01:33:27 christos Exp $	*/
 /*	$OpenBSD: uipaq.c,v 1.1 2005/06/17 23:50:33 deraadt Exp $	*/
 
@@ -42,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/uipaq.c 240659 2012-09-18 16:28:49Z hselasky $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/uipaq.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 #include <sys/stdint.h>
 #include <sys/stddef.h>

Modified: trunk/sys/dev/usb/serial/ulpt.c
===================================================================
--- trunk/sys/dev/usb/serial/ulpt.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/ulpt.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/ulpt.c 248085 2013-03-09 02:36:32Z marius $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/ulpt.c 239180 2012-08-10 15:29:41Z hselasky $");
 
 /*	$NetBSD: ulpt.c,v 1.60 2003/10/04 21:19:50 augustss Exp $	*/
 

Modified: trunk/sys/dev/usb/serial/umcs.c
===================================================================
--- trunk/sys/dev/usb/serial/umcs.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/umcs.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Lev Serebryakov <lev at FreeBSD.org>.
  * All rights reserved.
@@ -38,7 +39,7 @@
  *
  */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/umcs.c 269721 2014-08-08 14:56:04Z joerg $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/umcs.c 269718 2014-08-08 14:48:26Z joerg $");
 
 #include <sys/stdint.h>
 #include <sys/stddef.h>

Modified: trunk/sys/dev/usb/serial/umcs.h
===================================================================
--- trunk/sys/dev/usb/serial/umcs.h	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/umcs.h	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,4 +1,5 @@
-/* $FreeBSD: stable/9/sys/dev/usb/serial/umcs.h 222696 2011-06-04 20:40:24Z hselasky $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/usb/serial/umcs.h 252123 2013-06-23 20:19:51Z thomas $ */
 /*-
  * Copyright (c) 2010 Lev Serebryakov <lev at FreeBSD.org>.
  * All rights reserved.
@@ -596,7 +597,7 @@
 #define	MCS7840_UART_LSR_RHROVERRUN	0x02	/* Data FIFO/register overflow */
 #define	MCS7840_UART_LSR_PARITYERR	0x04	/* Parity error */
 #define	MCS7840_UART_LSR_FRAMEERR	0x10	/* Framing error */
-#define	MCS7840_UART_LSR_BREAKERR	0x20	/* BREAK sigmal received */
+#define	MCS7840_UART_LSR_BREAKERR	0x20	/* BREAK signal received */
 #define	MCS7840_UART_LSR_THREMPTY	0x40	/* THR register is empty,
 						 * ready for transmit */
 #define	MCS7840_UART_LSR_HASERR		0x80	/* Has error in receiver FIFO */

Modified: trunk/sys/dev/usb/serial/umct.c
===================================================================
--- trunk/sys/dev/usb/serial/umct.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/umct.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/umct.c 240659 2012-09-18 16:28:49Z hselasky $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/umct.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 /*-
  * Copyright (c) 2003 Scott Long

Modified: trunk/sys/dev/usb/serial/umodem.c
===================================================================
--- trunk/sys/dev/usb/serial/umodem.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/umodem.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,7 +1,8 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: umodem.c,v 1.45 2002/09/23 05:51:23 simonb Exp $	*/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/umodem.c 277410 2015-01-20 05:14:07Z hselasky $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/umodem.c 277409 2015-01-20 05:12:30Z hselasky $");
 
 /*-
  * Copyright (c) 2003, M. Warner Losh <imp at FreeBSD.org>.

Modified: trunk/sys/dev/usb/serial/umoscom.c
===================================================================
--- trunk/sys/dev/usb/serial/umoscom.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/umoscom.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,4 +1,5 @@
-/* $FreeBSD: stable/9/sys/dev/usb/serial/umoscom.c 248085 2013-03-09 02:36:32Z marius $ */
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/sys/dev/usb/serial/umoscom.c 239299 2012-08-15 15:42:57Z hselasky $ */
 /*	$OpenBSD: umoscom.c,v 1.2 2006/10/26 06:02:43 jsg Exp $	*/
 
 /*

Modified: trunk/sys/dev/usb/serial/uplcom.c
===================================================================
--- trunk/sys/dev/usb/serial/uplcom.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/uplcom.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,7 +1,8 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: uplcom.c,v 1.21 2001/11/13 06:24:56 lukem Exp $	*/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/uplcom.c 305557 2016-09-07 19:21:52Z dim $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/uplcom.c 305557 2016-09-07 19:21:52Z dim $");
 
 /*-
  * Copyright (c) 2001-2003, 2005 Shunsuke Akiyama <akiyama at jp.FreeBSD.org>.

Modified: trunk/sys/dev/usb/serial/usb_serial.c
===================================================================
--- trunk/sys/dev/usb/serial/usb_serial.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/usb_serial.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: ucom.c,v 1.40 2001/11/13 06:24:54 lukem Exp $	*/
 
 /*-
@@ -28,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/usb_serial.c 268208 2014-07-03 08:07:37Z hselasky $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/usb_serial.c 294637 2016-01-23 19:13:48Z ian $");
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -81,6 +82,8 @@
 #include <sys/cons.h>
 #include <sys/kdb.h>
 
+#include <dev/uart/uart_ppstypes.h>
+
 #include <dev/usb/usb.h>
 #include <dev/usb/usbdi.h>
 #include <dev/usb/usbdi_util.h>
@@ -96,6 +99,12 @@
 
 static SYSCTL_NODE(_hw_usb, OID_AUTO, ucom, CTLFLAG_RW, 0, "USB ucom");
 
+static int ucom_pps_mode;
+
+SYSCTL_INT(_hw_usb_ucom, OID_AUTO, pps_mode, CTLFLAG_RWTUN,
+    &ucom_pps_mode, 0, 
+    "pulse capture mode: 0/1/2=disabled/CTS/DCD; add 0x10 to invert");
+
 #ifdef USB_DEBUG
 static int ucom_debug = 0;
 
@@ -412,6 +421,11 @@
 
 	sc->sc_tty = tp;
 
+	sc->sc_pps.ppscap = PPS_CAPTUREBOTH;
+	sc->sc_pps.driver_abi = PPS_ABI_VERSION;
+	sc->sc_pps.driver_mtx = sc->sc_mtx;
+	pps_init_abi(&sc->sc_pps);
+
 	DPRINTF("ttycreate: %s\n", buf);
 
 	/* Check if this device should be a console */
@@ -861,6 +875,8 @@
 		} else {
 			error = ENOIOCTL;
 		}
+		if (error == ENOIOCTL)
+			error = pps_ioctl(cmd, data, &sc->sc_pps);
 		break;
 	}
 	return (error);
@@ -1062,10 +1078,12 @@
 	    (struct ucom_cfg_task *)_task;
 	struct ucom_softc *sc = task->sc;
 	struct tty *tp;
+	int onoff;
 	uint8_t new_msr;
 	uint8_t new_lsr;
-	uint8_t onoff;
+	uint8_t msr_delta;
 	uint8_t lsr_delta;
+	uint8_t pps_signal;
 
 	tp = sc->sc_tty;
 
@@ -1088,14 +1106,39 @@
 		/* TTY device closed */
 		return;
 	}
-	onoff = ((sc->sc_msr ^ new_msr) & SER_DCD);
+	msr_delta = (sc->sc_msr ^ new_msr);
 	lsr_delta = (sc->sc_lsr ^ new_lsr);
 
 	sc->sc_msr = new_msr;
 	sc->sc_lsr = new_lsr;
 
-	if (onoff) {
+	/*
+	 * Time pulse counting support.
+	 */
+	switch(ucom_pps_mode & UART_PPS_SIGNAL_MASK) {
+	case UART_PPS_CTS:
+		pps_signal = SER_CTS;
+		break;
+	case UART_PPS_DCD:
+		pps_signal = SER_DCD;
+		break;
+	default:
+		pps_signal = 0;
+		break;
+	}
 
+	if ((sc->sc_pps.ppsparam.mode & PPS_CAPTUREBOTH) &&
+	    (msr_delta & pps_signal)) {
+		pps_capture(&sc->sc_pps);
+		onoff = (sc->sc_msr & pps_signal) ? 1 : 0;
+		if (ucom_pps_mode & UART_PPS_INVERT_PULSE)
+			onoff = !onoff;
+		pps_event(&sc->sc_pps, onoff ? PPS_CAPTUREASSERT :
+		    PPS_CAPTURECLEAR);
+	}
+
+	if (msr_delta & SER_DCD) {
+
 		onoff = (sc->sc_msr & SER_DCD) ? 1 : 0;
 
 		DPRINTF("DCD changed to %d\n", onoff);

Modified: trunk/sys/dev/usb/serial/usb_serial.h
===================================================================
--- trunk/sys/dev/usb/serial/usb_serial.h	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/usb_serial.h	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: ucomvar.h,v 1.9 2001/01/23 21:56:17 augustss Exp $	*/
-/*	$FreeBSD: stable/9/sys/dev/usb/serial/usb_serial.h 268208 2014-07-03 08:07:37Z hselasky $	*/
+/*	$FreeBSD: stable/10/sys/dev/usb/serial/usb_serial.h 283341 2015-05-24 00:53:43Z ian $	*/
 
 /*-
  * Copyright (c) 2001-2002, Shunsuke Akiyama <akiyama at jp.FreeBSD.org>.
@@ -64,6 +65,7 @@
 #include <sys/serial.h>
 #include <sys/fcntl.h>
 #include <sys/sysctl.h>
+#include <sys/timepps.h>
 
 /* Module interface related macros */
 #define	UCOM_MODVER	1
@@ -155,6 +157,8 @@
 	struct ucom_cfg_task	sc_line_state_task[2];
 	struct ucom_cfg_task	sc_status_task[2];
 	struct ucom_param_task	sc_param_task[2];
+	/* pulse capturing support, PPS */
+	struct pps_state	sc_pps;
 	/* Used to set "UCOM_FLAG_GP_DATA" flag: */
 	struct usb_proc_msg	*sc_last_start_xfer;
 	const struct ucom_callback *sc_callback;

Modified: trunk/sys/dev/usb/serial/uslcom.c
===================================================================
--- trunk/sys/dev/usb/serial/uslcom.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/uslcom.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,7 +1,8 @@
+/* $MidnightBSD$ */
 /*	$OpenBSD: uslcom.c,v 1.17 2007/11/24 10:52:12 jsg Exp $	*/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/uslcom.c 263166 2014-03-14 10:18:53Z hselasky $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/uslcom.c 329302 2018-02-15 08:52:58Z hselasky $");
 
 /*
  * Copyright (c) 2006 Jonathan Gray <jsg at openbsd.org>
@@ -119,9 +120,17 @@
 #define	USLCOM_FLOW_RTS_HS      0x00000080 /* RTS handshake */
 
 /* USLCOM_VENDOR_SPECIFIC values */
+#define	USLCOM_GET_PARTNUM	0x370B
 #define	USLCOM_WRITE_LATCH	0x37E1
 #define	USLCOM_READ_LATCH	0x00C2
 
+/* USLCOM_GET_PARTNUM values from hardware */
+#define	USLCOM_PARTNUM_CP2101	1
+#define	USLCOM_PARTNUM_CP2102	2
+#define	USLCOM_PARTNUM_CP2103	3
+#define	USLCOM_PARTNUM_CP2104	4
+#define	USLCOM_PARTNUM_CP2105	5
+
 enum {
 	USLCOM_BULK_DT_WR,
 	USLCOM_BULK_DT_RD,
@@ -141,6 +150,7 @@
 	uint8_t		 sc_msr;
 	uint8_t		 sc_lsr;
 	uint8_t		 sc_iface_no;
+	uint8_t		 sc_partnum;
 };
 
 static device_probe_t uslcom_probe;
@@ -155,6 +165,7 @@
 static void	uslcom_free(struct ucom_softc *);
 static void uslcom_open(struct ucom_softc *);
 static void uslcom_close(struct ucom_softc *);
+static uint8_t uslcom_get_partnum(struct uslcom_softc *);
 static void uslcom_set_dtr(struct ucom_softc *, uint8_t);
 static void uslcom_set_rts(struct ucom_softc *, uint8_t);
 static void uslcom_set_break(struct ucom_softc *, uint8_t);
@@ -303,6 +314,7 @@
     USLCOM_DEV(SILABS, EMS_C1007),
     USLCOM_DEV(SILABS, HAMLINKUSB),
     USLCOM_DEV(SILABS, HELICOM),
+    USLCOM_DEV(SILABS, HUBZ),
     USLCOM_DEV(SILABS, IMS_USB_RS422),
     USLCOM_DEV(SILABS, INFINITY_MIC),
     USLCOM_DEV(SILABS, INGENI_ZIGBEE),
@@ -434,6 +446,8 @@
 	usbd_xfer_set_stall(sc->sc_xfer[USLCOM_BULK_DT_RD]);
 	mtx_unlock(&sc->sc_mtx);
 
+	sc->sc_partnum = uslcom_get_partnum(sc);
+
 	error = ucom_attach(&sc->sc_super_ucom, &sc->sc_ucom, 1, sc,
 	    &uslcom_callback, &sc->sc_mtx);
 	if (error) {
@@ -526,6 +540,28 @@
 	}
 }
 
+static uint8_t
+uslcom_get_partnum(struct uslcom_softc *sc)
+{
+	struct usb_device_request req;
+	uint8_t partnum;
+
+	/* Find specific chip type */
+	partnum = 0;
+	req.bmRequestType = USLCOM_READ;
+	req.bRequest = USLCOM_VENDOR_SPECIFIC;
+	USETW(req.wValue, USLCOM_GET_PARTNUM);
+	USETW(req.wIndex, sc->sc_iface_no);
+	USETW(req.wLength, sizeof(partnum));
+
+	if (usbd_do_request_flags(sc->sc_udev, NULL,
+	    &req, &partnum, 0, NULL, 1000)) {
+		DPRINTF("GET_PARTNUM failed\n");
+	}
+
+	return(partnum);
+}
+
 static void
 uslcom_set_dtr(struct ucom_softc *ucom, uint8_t onoff)
 {
@@ -705,10 +741,14 @@
 
 	switch (cmd) {
 	case USB_GET_GPIO:
+		if (sc->sc_partnum < USLCOM_PARTNUM_CP2103) {
+			error = ENODEV;
+			break;
+		}
 		req.bmRequestType = USLCOM_READ;
 		req.bRequest = USLCOM_VENDOR_SPECIFIC;
 		USETW(req.wValue, USLCOM_READ_LATCH);
-		USETW(req.wIndex, 0);
+		USETW(req.wIndex, sc->sc_iface_no);
 		USETW(req.wLength, sizeof(latch));
 
 		if (ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, 
@@ -720,17 +760,23 @@
 		break;
 
 	case USB_SET_GPIO:
-		req.bmRequestType = USLCOM_WRITE;
-		req.bRequest = USLCOM_VENDOR_SPECIFIC;
-		USETW(req.wValue, USLCOM_WRITE_LATCH);
-		USETW(req.wIndex, (*(int *)data));
-		USETW(req.wLength, 0);
-		
-		if (ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, 
-		    &req, NULL, 0, 1000)) {
-			DPRINTF("Set LATCH failed\n");
-			error = EIO;
-		}
+		if (sc->sc_partnum < USLCOM_PARTNUM_CP2103)
+			error = ENODEV;
+		else if ((sc->sc_partnum == USLCOM_PARTNUM_CP2103) ||
+		    (sc->sc_partnum == USLCOM_PARTNUM_CP2104)) {
+			req.bmRequestType = USLCOM_WRITE;
+			req.bRequest = USLCOM_VENDOR_SPECIFIC;
+			USETW(req.wValue, USLCOM_WRITE_LATCH);
+			USETW(req.wIndex, (*(int *)data));
+			USETW(req.wLength, 0);
+
+			if (ucom_cfg_do_request(sc->sc_udev, &sc->sc_ucom, 
+			    &req, NULL, 0, 1000)) {
+				DPRINTF("Set LATCH failed\n");
+				error = EIO;
+			}
+		} else
+			error = ENODEV;	/* Not yet */
 		break;
 
 	default:

Modified: trunk/sys/dev/usb/serial/uvisor.c
===================================================================
--- trunk/sys/dev/usb/serial/uvisor.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/uvisor.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: uvisor.c,v 1.9 2001/01/23 14:04:14 augustss Exp $	*/
-/*      $FreeBSD: stable/9/sys/dev/usb/serial/uvisor.c 248085 2013-03-09 02:36:32Z marius $ */
+/*      $FreeBSD: stable/10/sys/dev/usb/serial/uvisor.c 239299 2012-08-15 15:42:57Z hselasky $ */
 
 /* Also already merged from NetBSD:
  *	$NetBSD: uvisor.c,v 1.12 2001/11/13 06:24:57 lukem Exp $

Modified: trunk/sys/dev/usb/serial/uvscom.c
===================================================================
--- trunk/sys/dev/usb/serial/uvscom.c	2018-05-27 22:41:38 UTC (rev 10047)
+++ trunk/sys/dev/usb/serial/uvscom.c	2018-05-27 22:42:00 UTC (rev 10048)
@@ -1,7 +1,8 @@
+/* $MidnightBSD$ */
 /*	$NetBSD: usb/uvscom.c,v 1.1 2002/03/19 15:08:42 augustss Exp $	*/
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/dev/usb/serial/uvscom.c 248085 2013-03-09 02:36:32Z marius $");
+__FBSDID("$FreeBSD: stable/10/sys/dev/usb/serial/uvscom.c 239299 2012-08-15 15:42:57Z hselasky $");
 
 /*-
  * Copyright (c) 2001-2003, 2005 Shunsuke Akiyama <akiyama at jp.FreeBSD.org>.



More information about the Midnightbsd-cvs mailing list