Author: marius Date: Thu Jun 14 21:16:19 2012 New Revision: 237102 URL: http://svn.freebsd.org/changeset/base/237102
Log: - 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. MFC after: 3 days Modified: head/sys/dev/usb/serial/uftdi.c head/sys/dev/usb/serial/uftdi_reg.h head/sys/dev/usb/usbdevs Modified: head/sys/dev/usb/serial/uftdi.c ============================================================================== --- head/sys/dev/usb/serial/uftdi.c Thu Jun 14 20:49:22 2012 (r237101) +++ head/sys/dev/usb/serial/uftdi.c Thu Jun 14 21:16:19 2012 (r237102) @@ -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,59 +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, SERIAL_BEAGLEBONE, 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 }; @@ -261,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); @@ -268,9 +271,18 @@ 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 || ((id->driver_info & UFTDI_FLAG_JTAG) != 0 && + uaa->info.bIfaceIndex == UFTDI_IFACE_INDEX_JTAG)) + return (ENXIO); + uaa->driver_info = id->driver_info; + return (BUS_PROBE_SPECIFIC); } static int @@ -293,7 +305,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: @@ -562,6 +574,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) { @@ -824,5 +837,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: head/sys/dev/usb/serial/uftdi_reg.h ============================================================================== --- head/sys/dev/usb/serial/uftdi_reg.h Thu Jun 14 20:49:22 2012 (r237101) +++ head/sys/dev/usb/serial/uftdi_reg.h Thu Jun 14 21:16:19 2012 (r237102) @@ -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,11 @@ 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 @@ -134,8 +133,6 @@ enum { #define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11) #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 @@ -171,8 +168,6 @@ enum { #define FTDI_SIO_SET_RTS_MASK 0x2 #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 @@ -202,8 +197,6 @@ enum { #define FTDI_SIO_RTS_CTS_HS 0x1 #define FTDI_SIO_DTR_DSR_HS 0x2 #define FTDI_SIO_XON_XOFF_HS 0x4 - - /* * BmRequestType: 0100 0000b * bRequest: FTDI_SIO_SET_EVENT_CHAR @@ -226,9 +219,6 @@ enum { * data read so far - rather than wait 40ms or until 62 bytes are read * which is what normally happens. */ - - - /* * BmRequestType: 0100 0000b * bRequest: FTDI_SIO_SET_ERROR_CHAR @@ -243,14 +233,10 @@ 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 @@ -281,9 +267,6 @@ enum { #define FTDI_SIO_DSR_MASK 0x20 #define FTDI_SIO_RI_MASK 0x40 #define FTDI_SIO_RLSD_MASK 0x80 - - - /* * * DATA FORMAT @@ -317,8 +300,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 +311,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: head/sys/dev/usb/usbdevs ============================================================================== --- head/sys/dev/usb/usbdevs Thu Jun 14 20:49:22 2012 (r237101) +++ head/sys/dev/usb/usbdevs Thu Jun 14 21:16:19 2012 (r237102) @@ -1612,9 +1612,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 SERIAL_BEAGLEBONE 0xa6d0 BeagleBone FTDI 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 _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"