svn commit: r237380 - in stable/9/sys/dev/usb: . serial
Marius Strobl
marius at FreeBSD.org
Thu Jun 21 11:06:30 UTC 2012
Author: marius
Date: Thu Jun 21 11:06:29 2012
New Revision: 237380
URL: http://svn.freebsd.org/changeset/base/237380
Log:
MFC: r230242, r237102, r237236
- Add support for the FT2232 based egnite Turtelizer 2 JTAG/RS232 Adapter.
This includes adding support for skipping FTDI interfaces used for JTAG
leaving them for userland and just attaching to the RS232 half, similarly
to how the corresponding Linux drivers handles these kind of adapters.
While at it, sort uftdi_devs and return BUS_PROBE_SPECIFIC (because
uftdi_probe() alters the instance variables for better or worse as do
other probe routines of USB drivers) instead of 0.
- Remove duplicated entries for BeagleBone.
- Use DEVMETHOD_END.
- Use NULL instead of 0 for pointers.
- Remove some stray lines.
Modified:
stable/9/sys/dev/usb/serial/uftdi.c
stable/9/sys/dev/usb/serial/uftdi_reg.h
stable/9/sys/dev/usb/usbdevs
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/amd64/include/xen/ (props changed)
stable/9/sys/boot/ (props changed)
stable/9/sys/boot/i386/efi/ (props changed)
stable/9/sys/boot/ia64/efi/ (props changed)
stable/9/sys/boot/ia64/ski/ (props changed)
stable/9/sys/boot/powerpc/boot1.chrp/ (props changed)
stable/9/sys/boot/powerpc/ofw/ (props changed)
stable/9/sys/cddl/contrib/opensolaris/ (props changed)
stable/9/sys/conf/ (props changed)
stable/9/sys/contrib/dev/acpica/ (props changed)
stable/9/sys/contrib/octeon-sdk/ (props changed)
stable/9/sys/contrib/pf/ (props changed)
stable/9/sys/contrib/x86emu/ (props changed)
stable/9/sys/dev/ (props changed)
stable/9/sys/dev/e1000/ (props changed)
stable/9/sys/dev/isp/ (props changed)
stable/9/sys/dev/ixgbe/ (props changed)
stable/9/sys/fs/ (props changed)
stable/9/sys/fs/ntfs/ (props changed)
stable/9/sys/modules/ (props changed)
Modified: stable/9/sys/dev/usb/serial/uftdi.c
==============================================================================
--- stable/9/sys/dev/usb/serial/uftdi.c Thu Jun 21 10:41:27 2012 (r237379)
+++ stable/9/sys/dev/usb/serial/uftdi.c Thu Jun 21 11:06:29 2012 (r237380)
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");
*/
/*
- * FTDI FT8U100AX serial adapter driver
+ * FTDI FT2232x, FT8U100AX and FT8U232AM serial adapter driver
*/
#include <sys/stdint.h>
@@ -81,7 +81,7 @@ SYSCTL_INT(_hw_usb_uftdi, OID_AUTO, debu
#endif
#define UFTDI_CONFIG_INDEX 0
-#define UFTDI_IFACE_INDEX 0
+#define UFTDI_IFACE_INDEX_JTAG 0
#define UFTDI_OBUFSIZE 64 /* bytes, cannot be increased due to
* do size encoding */
@@ -102,10 +102,10 @@ struct uftdi_softc {
struct mtx sc_mtx;
uint32_t sc_unit;
- enum uftdi_type sc_type;
uint16_t sc_last_lcr;
+ uint8_t sc_type;
uint8_t sc_iface_index;
uint8_t sc_hdrlen;
uint8_t sc_msr;
@@ -190,7 +190,7 @@ static device_method_t uftdi_methods[] =
DEVMETHOD(device_attach, uftdi_attach),
DEVMETHOD(device_detach, uftdi_detach),
- {0, 0}
+ DEVMETHOD_END
};
static devclass_t uftdi_devclass;
@@ -201,58 +201,61 @@ static driver_t uftdi_driver = {
.size = sizeof(struct uftdi_softc),
};
-DRIVER_MODULE(uftdi, uhub, uftdi_driver, uftdi_devclass, NULL, 0);
+DRIVER_MODULE(uftdi, uhub, uftdi_driver, uftdi_devclass, NULL, NULL);
MODULE_DEPEND(uftdi, ucom, 1, 1, 1);
MODULE_DEPEND(uftdi, usb, 1, 1, 1);
MODULE_VERSION(uftdi, 1);
-static STRUCT_USB_HOST_ID uftdi_devs[] = {
-#define UFTDI_DEV(v,p,t) \
- { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, UFTDI_TYPE_##t) }
- UFTDI_DEV(ATMEL, STK541, 8U232AM),
- UFTDI_DEV(DRESDENELEKTRONIK, SENSORTERMINALBOARD, 8U232AM),
- UFTDI_DEV(DRESDENELEKTRONIK, WIRELESSHANDHELDTERMINAL, 8U232AM),
- UFTDI_DEV(FALCOM, TWIST, 8U232AM),
- UFTDI_DEV(FTDI, GAMMASCOUT, 8U232AM),
- UFTDI_DEV(FTDI, SERIAL_8U100AX, SIO),
- UFTDI_DEV(FTDI, SERIAL_2232C, 8U232AM),
- UFTDI_DEV(FTDI, SERIAL_2232D, 8U232AM),
- UFTDI_DEV(FTDI, BEAGLEBONE, 8U232AM),
- UFTDI_DEV(FTDI, SERIAL_4232H, 8U232AM),
- UFTDI_DEV(FTDI, SERIAL_8U232AM, 8U232AM),
- UFTDI_DEV(FTDI, SERIAL_8U232AM4, 8U232AM),
- UFTDI_DEV(FTDI, SEMC_DSS20, 8U232AM),
- UFTDI_DEV(FTDI, CFA_631, 8U232AM),
- UFTDI_DEV(FTDI, CFA_632, 8U232AM),
- UFTDI_DEV(FTDI, CFA_633, 8U232AM),
- UFTDI_DEV(FTDI, CFA_634, 8U232AM),
- UFTDI_DEV(FTDI, CFA_635, 8U232AM),
- UFTDI_DEV(FTDI, USB_UIRT, 8U232AM),
- UFTDI_DEV(FTDI, USBSERIAL, 8U232AM),
- UFTDI_DEV(FTDI, KBS, 8U232AM),
- UFTDI_DEV(FTDI, MX2_3, 8U232AM),
- UFTDI_DEV(FTDI, MX4_5, 8U232AM),
- UFTDI_DEV(FTDI, LK202, 8U232AM),
- UFTDI_DEV(FTDI, LK204, 8U232AM),
- UFTDI_DEV(FTDI, TACTRIX_OPENPORT_13M, 8U232AM),
- UFTDI_DEV(FTDI, TACTRIX_OPENPORT_13S, 8U232AM),
- UFTDI_DEV(FTDI, TACTRIX_OPENPORT_13U, 8U232AM),
- UFTDI_DEV(FTDI, EISCOU, 8U232AM),
- UFTDI_DEV(FTDI, UOPTBR, 8U232AM),
- UFTDI_DEV(FTDI, EMCU2D, 8U232AM),
- UFTDI_DEV(FTDI, PCMSFU, 8U232AM),
- UFTDI_DEV(FTDI, EMCU2H, 8U232AM),
- UFTDI_DEV(FTDI, MAXSTREAM, 8U232AM),
- UFTDI_DEV(FTDI, CTI_USB_NANO_485, 8U232AM),
- UFTDI_DEV(FTDI, CTI_USB_MINI_485, 8U232AM),
- UFTDI_DEV(SIIG2, US2308, 8U232AM),
- UFTDI_DEV(INTREPIDCS, VALUECAN, 8U232AM),
- UFTDI_DEV(INTREPIDCS, NEOVI, 8U232AM),
- UFTDI_DEV(BBELECTRONICS, USOTL4, 8U232AM),
- UFTDI_DEV(MATRIXORBITAL, MOUA, 8U232AM),
- UFTDI_DEV(MARVELL, SHEEVAPLUG, 8U232AM),
- UFTDI_DEV(MELCO, PCOPRS1, 8U232AM),
- UFTDI_DEV(RATOC, REXUSB60F, 8U232AM),
+static const STRUCT_USB_HOST_ID uftdi_devs[] = {
+#define UFTDI_DEV(v, p, i) \
+ { USB_VPI(USB_VENDOR_##v, USB_PRODUCT_##v##_##p, i) }
+ UFTDI_DEV(ATMEL, STK541, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(BBELECTRONICS, USOTL4, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(DRESDENELEKTRONIK, SENSORTERMINALBOARD,
+ UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(DRESDENELEKTRONIK, WIRELESSHANDHELDTERMINAL,
+ UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FALCOM, TWIST, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, BEAGLEBONE, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, CFA_631, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, CFA_632, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, CFA_633, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, CFA_634, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, CFA_635, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, CTI_USB_MINI_485, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, CTI_USB_NANO_485, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, EISCOU, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, EMCU2D, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, EMCU2H, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, GAMMASCOUT, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, KBS, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, LK202, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, LK204, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, MAXSTREAM, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, MX2_3, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, MX4_5, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, PCMSFU, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, SEMC_DSS20, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, SERIAL_2232C, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, SERIAL_2232D, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, SERIAL_4232H, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, SERIAL_8U100AX, UFTDI_TYPE_SIO),
+ UFTDI_DEV(FTDI, SERIAL_8U232AM, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, SERIAL_8U232AM4, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, TACTRIX_OPENPORT_13M, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, TACTRIX_OPENPORT_13S, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, TACTRIX_OPENPORT_13U, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, TURTELIZER2, UFTDI_TYPE_8U232AM | UFTDI_FLAG_JTAG),
+ UFTDI_DEV(FTDI, UOPTBR, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, USBSERIAL, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(FTDI, USB_UIRT, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(INTREPIDCS, NEOVI, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(INTREPIDCS, VALUECAN, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(MARVELL, SHEEVAPLUG, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(MATRIXORBITAL, MOUA, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(MELCO, PCOPRS1, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(RATOC, REXUSB60F, UFTDI_TYPE_8U232AM),
+ UFTDI_DEV(SIIG2, US2308, UFTDI_TYPE_8U232AM)
#undef UFTDI_DEV
};
@@ -260,6 +263,7 @@ static int
uftdi_probe(device_t dev)
{
struct usb_attach_arg *uaa = device_get_ivars(dev);
+ const struct usb_device_id *id;
if (uaa->usb_mode != USB_MODE_HOST) {
return (ENXIO);
@@ -267,9 +271,24 @@ uftdi_probe(device_t dev)
if (uaa->info.bConfigIndex != UFTDI_CONFIG_INDEX) {
return (ENXIO);
}
- /* attach to all present interfaces */
- return (usbd_lookup_id_by_uaa(uftdi_devs, sizeof(uftdi_devs), uaa));
+ /*
+ * Attach to all present interfaces unless this is a JTAG one, which
+ * we leave for userland.
+ */
+ id = usbd_lookup_id_by_info(uftdi_devs, sizeof(uftdi_devs),
+ &uaa->info);
+ if (id == NULL)
+ return (ENXIO);
+ if ((id->driver_info & UFTDI_FLAG_JTAG) != 0 &&
+ uaa->info.bIfaceIndex == UFTDI_IFACE_INDEX_JTAG) {
+ printf("%s: skipping JTAG interface at %u.%u\n",
+ device_get_name(dev), usbd_get_bus_index(uaa->device),
+ usbd_get_device_index(uaa->device));
+ return (ENXIO);
+ }
+ uaa->driver_info = id->driver_info;
+ return (BUS_PROBE_SPECIFIC);
}
static int
@@ -292,7 +311,7 @@ uftdi_attach(device_t dev)
DPRINTF("\n");
sc->sc_iface_index = uaa->info.bIfaceIndex;
- sc->sc_type = USB_GET_DRIVER_INFO(uaa);
+ sc->sc_type = USB_GET_DRIVER_INFO(uaa) & UFTDI_TYPE_MASK;
switch (sc->sc_type) {
case UFTDI_TYPE_SIO:
@@ -561,6 +580,7 @@ static int
uftdi_set_parm_soft(struct termios *t,
struct uftdi_param_config *cfg, uint8_t type)
{
+
memset(cfg, 0, sizeof(*cfg));
switch (type) {
@@ -823,5 +843,6 @@ static void
uftdi_poll(struct ucom_softc *ucom)
{
struct uftdi_softc *sc = ucom->sc_parent;
+
usbd_transfer_poll(sc->sc_xfer, UFTDI_N_TRANSFER);
}
Modified: stable/9/sys/dev/usb/serial/uftdi_reg.h
==============================================================================
--- stable/9/sys/dev/usb/serial/uftdi_reg.h Thu Jun 21 10:41:27 2012 (r237379)
+++ stable/9/sys/dev/usb/serial/uftdi_reg.h Thu Jun 21 11:06:29 2012 (r237380)
@@ -35,10 +35,12 @@
#define FTDI_PIT_SIOB 2 /* SIOB */
#define FTDI_PIT_PARALLEL 3 /* Parallel */
-enum uftdi_type {
- UFTDI_TYPE_SIO,
- UFTDI_TYPE_8U232AM
-};
+/* Values for driver_info */
+#define UFTDI_TYPE_MASK 0x000000ff
+#define UFTDI_TYPE_SIO 0x00000001
+#define UFTDI_TYPE_8U232AM 0x00000002
+#define UFTDI_FLAG_MASK 0x0000ff00
+#define UFTDI_FLAG_JTAG 0x00000100
/*
* BmRequestType: 0100 0000B
@@ -63,14 +65,12 @@ enum uftdi_type {
* baud and data format not reset
*
* The Purge RX and TX buffer commands affect nothing except the buffers
- *
*/
/* FTDI_SIO_RESET */
#define FTDI_SIO_RESET_SIO 0
#define FTDI_SIO_RESET_PURGE_RX 1
#define FTDI_SIO_RESET_PURGE_TX 2
-
/*
* BmRequestType: 0100 0000B
* bRequest: FTDI_SIO_SET_BAUDRATE
@@ -135,7 +135,6 @@ enum {
#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11)
#define FTDI_SIO_SET_BREAK (0x1 << 14)
-
/*
* BmRequestType: 0100 0000B
* bRequest: FTDI_SIO_MODEM_CTRL
@@ -172,7 +171,6 @@ enum {
#define FTDI_SIO_SET_RTS_HIGH (2 | ( FTDI_SIO_SET_RTS_MASK << 8))
#define FTDI_SIO_SET_RTS_LOW (0 | ( FTDI_SIO_SET_RTS_MASK << 8))
-
/*
* BmRequestType: 0100 0000b
* bRequest: FTDI_SIO_SET_FLOW_CTRL
@@ -203,7 +201,6 @@ enum {
#define FTDI_SIO_DTR_DSR_HS 0x2
#define FTDI_SIO_XON_XOFF_HS 0x4
-
/*
* BmRequestType: 0100 0000b
* bRequest: FTDI_SIO_SET_EVENT_CHAR
@@ -227,8 +224,6 @@ enum {
* which is what normally happens.
*/
-
-
/*
* BmRequestType: 0100 0000b
* bRequest: FTDI_SIO_SET_ERROR_CHAR
@@ -243,14 +238,11 @@ enum {
* 0 = disabled
* 1 = enabled
* B9..15 Reserved
- *
- *
* FTDI_SIO_SET_ERROR_CHAR
* Set the parity error replacement character for the specified communications
* port.
*/
-
/*
* BmRequestType: 1100 0000b
* bRequest: FTDI_SIO_GET_MODEM_STATUS
@@ -282,10 +274,7 @@ enum {
#define FTDI_SIO_RI_MASK 0x40
#define FTDI_SIO_RLSD_MASK 0x80
-
-
/*
- *
* DATA FORMAT
*
* IN Endpoint
@@ -317,8 +306,6 @@ enum {
* B5 Transmitter Holding Register (THRE)
* B6 Transmitter Empty (TEMT)
* B7 Error in RCVR FIFO
- *
- *
* OUT Endpoint
*
* This device reserves the first bytes of data on this endpoint contain the
@@ -330,7 +317,6 @@ enum {
* Offset Description
* B0..1 Port
* B2..7 Length of message - (not including Byte 0)
- *
*/
#define FTDI_PORT_MASK 0x0f
#define FTDI_MSR_MASK 0xf0
Modified: stable/9/sys/dev/usb/usbdevs
==============================================================================
--- stable/9/sys/dev/usb/usbdevs Thu Jun 21 10:41:27 2012 (r237379)
+++ stable/9/sys/dev/usb/usbdevs Thu Jun 21 11:06:29 2012 (r237380)
@@ -1604,8 +1604,9 @@ product FTDI SERIAL_8U232AM 0x6001 8U232
product FTDI SERIAL_8U232AM4 0x6004 8U232AM Serial
product FTDI SERIAL_2232C 0x6010 FT2232C Dual port Serial
product FTDI SERIAL_2232D 0x9e90 FT2232D Dual port Serial
-product FTDI BEAGLEBONE 0xA6D0 BeagleBone
product FTDI SERIAL_4232H 0x6011 FT4232H Quad port Serial
+product FTDI BEAGLEBONE 0xa6d0 BeagleBone
+product FTDI TURTELIZER2 0xbdc8 egnite Turtelizer 2 JTAG/RS232 Adapter
/* Gude Analog- und Digitalsysteme products also uses FTDI's id: */
product FTDI TACTRIX_OPENPORT_13M 0xcc48 OpenPort 1.3 Mitsubishi
product FTDI TACTRIX_OPENPORT_13S 0xcc49 OpenPort 1.3 Subaru
More information about the svn-src-stable-9
mailing list