xref: /linux/drivers/usb/serial/mct_u232.h (revision 631dd1a885b6d7e9f6f51b4e5b311c2bb04c323c)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * Definitions for MCT (Magic Control Technology) USB-RS232 Converter Driver
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  *   Copyright (C) 2000 Wolfgang Grandegger (wolfgang@ces.ch)
51da177e4SLinus Torvalds  *
61da177e4SLinus Torvalds  *   This program is free software; you can redistribute it and/or modify
71da177e4SLinus Torvalds  *   it under the terms of the GNU General Public License as published by
81da177e4SLinus Torvalds  *   the Free Software Foundation; either version 2 of the License, or
91da177e4SLinus Torvalds  *   (at your option) any later version.
101da177e4SLinus Torvalds  *
111da177e4SLinus Torvalds  * This driver is for the device MCT USB-RS232 Converter (25 pin, Model No.
121da177e4SLinus Torvalds  * U232-P25) from Magic Control Technology Corp. (there is also a 9 pin
13*631dd1a8SJustin P. Mattock  * Model No. U232-P9). See http://www.mct.com.tw/products/product_us232.html
14*631dd1a8SJustin P. Mattock  * for further information. The properties of this device are listed at the end
15*631dd1a8SJustin P. Mattock  * of this file. This device was used in the Dlink DSB-S25.
161da177e4SLinus Torvalds  *
171da177e4SLinus Torvalds  * All of the information about the device was acquired by using SniffUSB
181da177e4SLinus Torvalds  * on Windows98. The technical details of the reverse engineering are
191da177e4SLinus Torvalds  * summarized at the end of this file.
201da177e4SLinus Torvalds  */
211da177e4SLinus Torvalds 
221da177e4SLinus Torvalds #ifndef __LINUX_USB_SERIAL_MCT_U232_H
231da177e4SLinus Torvalds #define __LINUX_USB_SERIAL_MCT_U232_H
241da177e4SLinus Torvalds 
251da177e4SLinus Torvalds #define MCT_U232_VID	                0x0711	/* Vendor Id */
261da177e4SLinus Torvalds #define MCT_U232_PID	                0x0210	/* Original MCT Product Id */
271da177e4SLinus Torvalds 
281da177e4SLinus Torvalds /* U232-P25, Sitecom */
291da177e4SLinus Torvalds #define MCT_U232_SITECOM_PID		0x0230	/* Sitecom Product Id */
301da177e4SLinus Torvalds 
311da177e4SLinus Torvalds /* DU-H3SP USB BAY hub */
321da177e4SLinus Torvalds #define MCT_U232_DU_H3SP_PID		0x0200	/* D-Link DU-H3SP USB BAY */
331da177e4SLinus Torvalds 
341da177e4SLinus Torvalds /* Belkin badge the MCT U232-P9 as the F5U109 */
351da177e4SLinus Torvalds #define MCT_U232_BELKIN_F5U109_VID	0x050d	/* Vendor Id */
361da177e4SLinus Torvalds #define MCT_U232_BELKIN_F5U109_PID	0x0109	/* Product Id */
371da177e4SLinus Torvalds 
381da177e4SLinus Torvalds /*
391da177e4SLinus Torvalds  * Vendor Request Interface
401da177e4SLinus Torvalds  */
411da177e4SLinus Torvalds #define MCT_U232_SET_REQUEST_TYPE	0x40
421da177e4SLinus Torvalds #define MCT_U232_GET_REQUEST_TYPE	0xc0
431da177e4SLinus Torvalds 
4442047699SGreg Kroah-Hartman /* Get Modem Status Register (MSR) */
4542047699SGreg Kroah-Hartman #define MCT_U232_GET_MODEM_STAT_REQUEST	2
461da177e4SLinus Torvalds #define MCT_U232_GET_MODEM_STAT_SIZE	1
471da177e4SLinus Torvalds 
4842047699SGreg Kroah-Hartman /* Get Line Control Register (LCR) */
4942047699SGreg Kroah-Hartman /* ... not used by this driver */
5042047699SGreg Kroah-Hartman #define MCT_U232_GET_LINE_CTRL_REQUEST	6
5142047699SGreg Kroah-Hartman #define MCT_U232_GET_LINE_CTRL_SIZE	1
521da177e4SLinus Torvalds 
5342047699SGreg Kroah-Hartman /* Set Baud Rate Divisor */
5442047699SGreg Kroah-Hartman #define MCT_U232_SET_BAUD_RATE_REQUEST	5
551da177e4SLinus Torvalds #define MCT_U232_SET_BAUD_RATE_SIZE	4
561da177e4SLinus Torvalds 
5742047699SGreg Kroah-Hartman /* Set Line Control Register (LCR) */
5842047699SGreg Kroah-Hartman #define MCT_U232_SET_LINE_CTRL_REQUEST	7
591da177e4SLinus Torvalds #define MCT_U232_SET_LINE_CTRL_SIZE	1
601da177e4SLinus Torvalds 
6142047699SGreg Kroah-Hartman /* Set Modem Control Register (MCR) */
6242047699SGreg Kroah-Hartman #define MCT_U232_SET_MODEM_CTRL_REQUEST	10
631da177e4SLinus Torvalds #define MCT_U232_SET_MODEM_CTRL_SIZE	1
641da177e4SLinus Torvalds 
6542047699SGreg Kroah-Hartman /*
6642047699SGreg Kroah-Hartman  * This USB device request code is not well understood.  It is transmitted by
6742047699SGreg Kroah-Hartman  * the MCT-supplied Windows driver whenever the baud rate changes.
681da177e4SLinus Torvalds  */
691da177e4SLinus Torvalds #define MCT_U232_SET_UNKNOWN1_REQUEST	11  /* Unknown functionality */
701da177e4SLinus Torvalds #define MCT_U232_SET_UNKNOWN1_SIZE	1
711da177e4SLinus Torvalds 
7242047699SGreg Kroah-Hartman /*
7342047699SGreg Kroah-Hartman  * This USB device request code appears to control whether CTS is required
7442047699SGreg Kroah-Hartman  * during transmission.
7542047699SGreg Kroah-Hartman  *
7642047699SGreg Kroah-Hartman  * Sending a zero byte allows data transmission to a device which is not
7742047699SGreg Kroah-Hartman  * asserting CTS.  Sending a '1' byte will cause transmission to be deferred
7842047699SGreg Kroah-Hartman  * until the device asserts CTS.
791da177e4SLinus Torvalds  */
8045b844dfSDave Platt #define MCT_U232_SET_CTS_REQUEST	12
8145b844dfSDave Platt #define MCT_U232_SET_CTS_SIZE		1
821da177e4SLinus Torvalds 
83af2ac1a0SPete Zaitcev #define MCT_U232_MAX_SIZE		4	/* of MCT_XXX_SIZE */
84af2ac1a0SPete Zaitcev 
851da177e4SLinus Torvalds /*
861da177e4SLinus Torvalds  * Baud rate (divisor)
871da177e4SLinus Torvalds  * Actually, there are two of them, MCT website calls them "Philips solution"
881da177e4SLinus Torvalds  * and "Intel solution". They are the regular MCT and "Sitecom" for us.
891da177e4SLinus Torvalds  * This is pointless to document in the header, see the code for the bits.
901da177e4SLinus Torvalds  */
9142047699SGreg Kroah-Hartman static int mct_u232_calculate_baud_rate(struct usb_serial *serial,
9242047699SGreg Kroah-Hartman 					speed_t value, speed_t *result);
931da177e4SLinus Torvalds 
941da177e4SLinus Torvalds /*
951da177e4SLinus Torvalds  * Line Control Register (LCR)
961da177e4SLinus Torvalds  */
971da177e4SLinus Torvalds #define MCT_U232_SET_BREAK              0x40
981da177e4SLinus Torvalds 
991da177e4SLinus Torvalds #define MCT_U232_PARITY_SPACE		0x38
1001da177e4SLinus Torvalds #define MCT_U232_PARITY_MARK		0x28
1011da177e4SLinus Torvalds #define MCT_U232_PARITY_EVEN		0x18
1021da177e4SLinus Torvalds #define MCT_U232_PARITY_ODD		0x08
1031da177e4SLinus Torvalds #define MCT_U232_PARITY_NONE		0x00
1041da177e4SLinus Torvalds 
1051da177e4SLinus Torvalds #define MCT_U232_DATA_BITS_5            0x00
1061da177e4SLinus Torvalds #define MCT_U232_DATA_BITS_6            0x01
1071da177e4SLinus Torvalds #define MCT_U232_DATA_BITS_7            0x02
1081da177e4SLinus Torvalds #define MCT_U232_DATA_BITS_8            0x03
1091da177e4SLinus Torvalds 
1101da177e4SLinus Torvalds #define MCT_U232_STOP_BITS_2            0x04
1111da177e4SLinus Torvalds #define MCT_U232_STOP_BITS_1            0x00
1121da177e4SLinus Torvalds 
1131da177e4SLinus Torvalds /*
1141da177e4SLinus Torvalds  * Modem Control Register (MCR)
1151da177e4SLinus Torvalds  */
1161da177e4SLinus Torvalds #define MCT_U232_MCR_NONE               0x8     /* Deactivate DTR and RTS */
1171da177e4SLinus Torvalds #define MCT_U232_MCR_RTS                0xa     /* Activate RTS */
1181da177e4SLinus Torvalds #define MCT_U232_MCR_DTR                0x9     /* Activate DTR */
1191da177e4SLinus Torvalds 
1201da177e4SLinus Torvalds /*
1211da177e4SLinus Torvalds  * Modem Status Register (MSR)
1221da177e4SLinus Torvalds  */
1231da177e4SLinus Torvalds #define MCT_U232_MSR_INDEX              0x0     /* data[index] */
1241da177e4SLinus Torvalds #define MCT_U232_MSR_CD                 0x80    /* Current CD */
1251da177e4SLinus Torvalds #define MCT_U232_MSR_RI                 0x40    /* Current RI */
1261da177e4SLinus Torvalds #define MCT_U232_MSR_DSR                0x20    /* Current DSR */
1271da177e4SLinus Torvalds #define MCT_U232_MSR_CTS                0x10    /* Current CTS */
1281da177e4SLinus Torvalds #define MCT_U232_MSR_DCD                0x08    /* Delta CD */
1291da177e4SLinus Torvalds #define MCT_U232_MSR_DRI                0x04    /* Delta RI */
1301da177e4SLinus Torvalds #define MCT_U232_MSR_DDSR               0x02    /* Delta DSR */
1311da177e4SLinus Torvalds #define MCT_U232_MSR_DCTS               0x01    /* Delta CTS */
1321da177e4SLinus Torvalds 
1331da177e4SLinus Torvalds /*
1341da177e4SLinus Torvalds  * Line Status Register (LSR)
1351da177e4SLinus Torvalds  */
1361da177e4SLinus Torvalds #define MCT_U232_LSR_INDEX	1	/* data[index] */
1371da177e4SLinus Torvalds #define MCT_U232_LSR_ERR	0x80	/* OE | PE | FE | BI */
1381da177e4SLinus Torvalds #define MCT_U232_LSR_TEMT	0x40	/* transmit register empty */
1391da177e4SLinus Torvalds #define MCT_U232_LSR_THRE	0x20	/* transmit holding register empty */
1401da177e4SLinus Torvalds #define MCT_U232_LSR_BI		0x10	/* break indicator */
1411da177e4SLinus Torvalds #define MCT_U232_LSR_FE		0x08	/* framing error */
1421da177e4SLinus Torvalds #define MCT_U232_LSR_OE		0x02	/* overrun error */
1431da177e4SLinus Torvalds #define MCT_U232_LSR_PE		0x04	/* parity error */
1441da177e4SLinus Torvalds #define MCT_U232_LSR_OE		0x02	/* overrun error */
1451da177e4SLinus Torvalds #define MCT_U232_LSR_DR		0x01	/* receive data ready */
1461da177e4SLinus Torvalds 
1471da177e4SLinus Torvalds 
1481da177e4SLinus Torvalds /* -----------------------------------------------------------------------------
1491da177e4SLinus Torvalds  * Technical Specification reverse engineered with SniffUSB on Windows98
1501da177e4SLinus Torvalds  * =====================================================================
1511da177e4SLinus Torvalds  *
1521da177e4SLinus Torvalds  *  The technical details of the device have been acquired be using "SniffUSB"
1531da177e4SLinus Torvalds  *  and the vendor-supplied device driver (version 2.3A) under Windows98. To
1541da177e4SLinus Torvalds  *  identify the USB vendor-specific requests and to assign them to terminal
1551da177e4SLinus Torvalds  *  settings (flow control, baud rate, etc.) the program "SerialSettings" from
1561da177e4SLinus Torvalds  *  William G. Greathouse has been proven to be very useful. I also used the
1571da177e4SLinus Torvalds  *  Win98 "HyperTerminal" and "usb-robot" on Linux for testing. The results and
1581da177e4SLinus Torvalds  *  observations are summarized below:
1591da177e4SLinus Torvalds  *
1601da177e4SLinus Torvalds  *  The USB requests seem to be directly mapped to the registers of a 8250,
1611da177e4SLinus Torvalds  *  16450 or 16550 UART. The FreeBSD handbook (appendix F.4 "Input/Output
1621da177e4SLinus Torvalds  *  devices") contains a comprehensive description of UARTs and its registers.
1631da177e4SLinus Torvalds  *  The bit descriptions are actually taken from there.
1641da177e4SLinus Torvalds  *
1651da177e4SLinus Torvalds  *
1661da177e4SLinus Torvalds  * Baud rate (divisor)
1671da177e4SLinus Torvalds  * -------------------
1681da177e4SLinus Torvalds  *
1691da177e4SLinus Torvalds  *   BmRequestType:  0x40 (0100 0000B)
1701da177e4SLinus Torvalds  *   bRequest:       0x05
1711da177e4SLinus Torvalds  *   wValue:         0x0000
1721da177e4SLinus Torvalds  *   wIndex:         0x0000
1731da177e4SLinus Torvalds  *   wLength:        0x0004
1741da177e4SLinus Torvalds  *   Data:           divisor = 115200 / baud_rate
1751da177e4SLinus Torvalds  *
1761da177e4SLinus Torvalds  *   SniffUSB observations (Nov 2003): Contrary to the 'wLength' value of 4
1771da177e4SLinus Torvalds  *   shown above, observations with a Belkin F5U109 adapter, using the
1781da177e4SLinus Torvalds  *   MCT-supplied Windows98 driver (U2SPORT.VXD, "File version: 1.21P.0104 for
1791da177e4SLinus Torvalds  *   Win98/Me"), show this request has a length of 1 byte, presumably because
1801da177e4SLinus Torvalds  *   of the fact that the Belkin adapter and the 'Sitecom U232-P25' adapter
1811da177e4SLinus Torvalds  *   use a baud-rate code instead of a conventional RS-232 baud rate divisor.
1821da177e4SLinus Torvalds  *   The current source code for this driver does not reflect this fact, but
1831da177e4SLinus Torvalds  *   the driver works fine with this adapter/driver combination nonetheless.
1841da177e4SLinus Torvalds  *
1851da177e4SLinus Torvalds  *
1861da177e4SLinus Torvalds  * Line Control Register (LCR)
1871da177e4SLinus Torvalds  * ---------------------------
1881da177e4SLinus Torvalds  *
1891da177e4SLinus Torvalds  *  BmRequestType:  0x40 (0100 0000B)    0xc0 (1100 0000B)
1901da177e4SLinus Torvalds  *  bRequest:       0x07                 0x06
1911da177e4SLinus Torvalds  *  wValue:         0x0000
1921da177e4SLinus Torvalds  *  wIndex:         0x0000
1931da177e4SLinus Torvalds  *  wLength:        0x0001
1941da177e4SLinus Torvalds  *  Data:           LCR (see below)
1951da177e4SLinus Torvalds  *
1961da177e4SLinus Torvalds  *  Bit 7: Divisor Latch Access Bit (DLAB). When set, access to the data
1971da177e4SLinus Torvalds  *	   transmit/receive register (THR/RBR) and the Interrupt Enable Register
1981da177e4SLinus Torvalds  *	   (IER) is disabled. Any access to these ports is now redirected to the
1991da177e4SLinus Torvalds  *	   Divisor Latch Registers. Setting this bit, loading the Divisor
2001da177e4SLinus Torvalds  *	   Registers, and clearing DLAB should be done with interrupts disabled.
2011da177e4SLinus Torvalds  *  Bit 6: Set Break. When set to "1", the transmitter begins to transmit
2021da177e4SLinus Torvalds  *	   continuous Spacing until this bit is set to "0". This overrides any
2031da177e4SLinus Torvalds  *	   bits of characters that are being transmitted.
2041da177e4SLinus Torvalds  *  Bit 5: Stick Parity. When parity is enabled, setting this bit causes parity
2051da177e4SLinus Torvalds  *	   to always be "1" or "0", based on the value of Bit 4.
2061da177e4SLinus Torvalds  *  Bit 4: Even Parity Select (EPS). When parity is enabled and Bit 5 is "0",
2071da177e4SLinus Torvalds  *	   setting this bit causes even parity to be transmitted and expected.
2081da177e4SLinus Torvalds  *	   Otherwise, odd parity is used.
2091da177e4SLinus Torvalds  *  Bit 3: Parity Enable (PEN). When set to "1", a parity bit is inserted
2101da177e4SLinus Torvalds  *	   between the last bit of the data and the Stop Bit. The UART will also
2111da177e4SLinus Torvalds  *	   expect parity to be present in the received data.
2121da177e4SLinus Torvalds  *  Bit 2: Number of Stop Bits (STB). If set to "1" and using 5-bit data words,
2131da177e4SLinus Torvalds  *	   1.5 Stop Bits are transmitted and expected in each data word. For
2141da177e4SLinus Torvalds  *	   6, 7 and 8-bit data words, 2 Stop Bits are transmitted and expected.
2151da177e4SLinus Torvalds  *	   When this bit is set to "0", one Stop Bit is used on each data word.
2161da177e4SLinus Torvalds  *  Bit 1: Word Length Select Bit #1 (WLSB1)
2171da177e4SLinus Torvalds  *  Bit 0: Word Length Select Bit #0 (WLSB0)
2181da177e4SLinus Torvalds  *	   Together these bits specify the number of bits in each data word.
2191da177e4SLinus Torvalds  *	     1 0  Word Length
2201da177e4SLinus Torvalds  *	     0 0  5 Data Bits
2211da177e4SLinus Torvalds  *	     0 1  6 Data Bits
2221da177e4SLinus Torvalds  *	     1 0  7 Data Bits
2231da177e4SLinus Torvalds  *	     1 1  8 Data Bits
2241da177e4SLinus Torvalds  *
2251da177e4SLinus Torvalds  *  SniffUSB observations: Bit 7 seems not to be used. There seem to be two bugs
2261da177e4SLinus Torvalds  *  in the Win98 driver: the break does not work (bit 6 is not asserted) and the
2271da177e4SLinus Torvalds  *  stick parity bit is not cleared when set once. The LCR can also be read
2281da177e4SLinus Torvalds  *  back with USB request 6 but this has never been observed with SniffUSB.
2291da177e4SLinus Torvalds  *
2301da177e4SLinus Torvalds  *
2311da177e4SLinus Torvalds  * Modem Control Register (MCR)
2321da177e4SLinus Torvalds  * ----------------------------
2331da177e4SLinus Torvalds  *
2341da177e4SLinus Torvalds  *  BmRequestType:  0x40  (0100 0000B)
2351da177e4SLinus Torvalds  *  bRequest:       0x0a
2361da177e4SLinus Torvalds  *  wValue:         0x0000
2371da177e4SLinus Torvalds  *  wIndex:         0x0000
2381da177e4SLinus Torvalds  *  wLength:        0x0001
2391da177e4SLinus Torvalds  *  Data:           MCR (Bit 4..7, see below)
2401da177e4SLinus Torvalds  *
2411da177e4SLinus Torvalds  *  Bit 7: Reserved, always 0.
2421da177e4SLinus Torvalds  *  Bit 6: Reserved, always 0.
2431da177e4SLinus Torvalds  *  Bit 5: Reserved, always 0.
2441da177e4SLinus Torvalds  *  Bit 4: Loop-Back Enable. When set to "1", the UART transmitter and receiver
2451da177e4SLinus Torvalds  *	   are internally connected together to allow diagnostic operations. In
2461da177e4SLinus Torvalds  *	   addition, the UART modem control outputs are connected to the UART
2471da177e4SLinus Torvalds  *	   modem control inputs. CTS is connected to RTS, DTR is connected to
2481da177e4SLinus Torvalds  *	   DSR, OUT1 is connected to RI, and OUT 2 is connected to DCD.
2491da177e4SLinus Torvalds  *  Bit 3: OUT 2. An auxiliary output that the host processor may set high or
2501da177e4SLinus Torvalds  *	   low. In the IBM PC serial adapter (and most clones), OUT 2 is used
2511da177e4SLinus Torvalds  *	   to tri-state (disable) the interrupt signal from the
2521da177e4SLinus Torvalds  *	   8250/16450/16550 UART.
2531da177e4SLinus Torvalds  *  Bit 2: OUT 1. An auxiliary output that the host processor may set high or
2541da177e4SLinus Torvalds  *	   low. This output is not used on the IBM PC serial adapter.
2551da177e4SLinus Torvalds  *  Bit 1: Request to Send (RTS). When set to "1", the output of the UART -RTS
2561da177e4SLinus Torvalds  *	   line is Low (Active).
2571da177e4SLinus Torvalds  *  Bit 0: Data Terminal Ready (DTR). When set to "1", the output of the UART
2581da177e4SLinus Torvalds  *	   -DTR line is Low (Active).
2591da177e4SLinus Torvalds  *
2601da177e4SLinus Torvalds  *  SniffUSB observations: Bit 2 and 4 seem not to be used but bit 3 has been
2611da177e4SLinus Torvalds  *  seen _always_ set.
2621da177e4SLinus Torvalds  *
2631da177e4SLinus Torvalds  *
2641da177e4SLinus Torvalds  * Modem Status Register (MSR)
2651da177e4SLinus Torvalds  * ---------------------------
2661da177e4SLinus Torvalds  *
2671da177e4SLinus Torvalds  *  BmRequestType:  0xc0  (1100 0000B)
2681da177e4SLinus Torvalds  *  bRequest:       0x02
2691da177e4SLinus Torvalds  *  wValue:         0x0000
2701da177e4SLinus Torvalds  *  wIndex:         0x0000
2711da177e4SLinus Torvalds  *  wLength:        0x0001
2721da177e4SLinus Torvalds  *  Data:           MSR (see below)
2731da177e4SLinus Torvalds  *
2741da177e4SLinus Torvalds  *  Bit 7: Data Carrier Detect (CD). Reflects the state of the DCD line on the
2751da177e4SLinus Torvalds  *	   UART.
2761da177e4SLinus Torvalds  *  Bit 6: Ring Indicator (RI). Reflects the state of the RI line on the UART.
2771da177e4SLinus Torvalds  *  Bit 5: Data Set Ready (DSR). Reflects the state of the DSR line on the UART.
2781da177e4SLinus Torvalds  *  Bit 4: Clear To Send (CTS). Reflects the state of the CTS line on the UART.
2791da177e4SLinus Torvalds  *  Bit 3: Delta Data Carrier Detect (DDCD). Set to "1" if the -DCD line has
2801da177e4SLinus Torvalds  *	   changed state one more more times since the last time the MSR was
2811da177e4SLinus Torvalds  *	   read by the host.
2821da177e4SLinus Torvalds  *  Bit 2: Trailing Edge Ring Indicator (TERI). Set to "1" if the -RI line has
2831da177e4SLinus Torvalds  *	   had a low to high transition since the last time the MSR was read by
2841da177e4SLinus Torvalds  *	   the host.
2851da177e4SLinus Torvalds  *  Bit 1: Delta Data Set Ready (DDSR). Set to "1" if the -DSR line has changed
2861da177e4SLinus Torvalds  *	   state one more more times since the last time the MSR was read by the
2871da177e4SLinus Torvalds  *	   host.
2881da177e4SLinus Torvalds  *  Bit 0: Delta Clear To Send (DCTS). Set to "1" if the -CTS line has changed
2891da177e4SLinus Torvalds  *	   state one more times since the last time the MSR was read by the
2901da177e4SLinus Torvalds  *	   host.
2911da177e4SLinus Torvalds  *
2921da177e4SLinus Torvalds  *  SniffUSB observations: the MSR is also returned as first byte on the
2931da177e4SLinus Torvalds  *  interrupt-in endpoint 0x83 to signal changes of modem status lines. The USB
2941da177e4SLinus Torvalds  *  request to read MSR cannot be applied during normal device operation.
2951da177e4SLinus Torvalds  *
2961da177e4SLinus Torvalds  *
2971da177e4SLinus Torvalds  * Line Status Register (LSR)
2981da177e4SLinus Torvalds  * --------------------------
2991da177e4SLinus Torvalds  *
3001da177e4SLinus Torvalds  *  Bit 7   Error in Receiver FIFO. On the 8250/16450 UART, this bit is zero.
30142047699SGreg Kroah-Hartman  *	    This bit is set to "1" when any of the bytes in the FIFO have one
30242047699SGreg Kroah-Hartman  *	    or more of the following error conditions: PE, FE, or BI.
3031da177e4SLinus Torvalds  *  Bit 6   Transmitter Empty (TEMT). When set to "1", there are no words
3041da177e4SLinus Torvalds  *	    remaining in the transmit FIFO or the transmit shift register. The
3051da177e4SLinus Torvalds  *	    transmitter is completely idle.
30642047699SGreg Kroah-Hartman  *  Bit 5   Transmitter Holding Register Empty (THRE). When set to "1", the
30742047699SGreg Kroah-Hartman  *	    FIFO (or holding register) now has room for at least one additional
30842047699SGreg Kroah-Hartman  *	    word to transmit. The transmitter may still be transmitting when
30942047699SGreg Kroah-Hartman  *	    this bit is set to "1".
3101da177e4SLinus Torvalds  *  Bit 4   Break Interrupt (BI). The receiver has detected a Break signal.
31142047699SGreg Kroah-Hartman  *  Bit 3   Framing Error (FE). A Start Bit was detected but the Stop Bit did
31242047699SGreg Kroah-Hartman  *	    not appear at the expected time. The received word is probably
31342047699SGreg Kroah-Hartman  *	    garbled.
31442047699SGreg Kroah-Hartman  *  Bit 2   Parity Error (PE). The parity bit was incorrect for the word
31542047699SGreg Kroah-Hartman  *	    received.
31642047699SGreg Kroah-Hartman  *  Bit 1   Overrun Error (OE). A new word was received and there was no room
31742047699SGreg Kroah-Hartman  *	    in the receive buffer. The newly-arrived word in the shift register
31842047699SGreg Kroah-Hartman  *	    is discarded. On 8250/16450 UARTs, the word in the holding register
31942047699SGreg Kroah-Hartman  *	    is discarded and the newly- arrived word is put in the holding
32042047699SGreg Kroah-Hartman  *	    register.
3211da177e4SLinus Torvalds  *  Bit 0   Data Ready (DR). One or more words are in the receive FIFO that the
32242047699SGreg Kroah-Hartman  *	    host may read. A word must be completely received and moved from
32342047699SGreg Kroah-Hartman  *	    the shift register into the FIFO (or holding register for
32442047699SGreg Kroah-Hartman  *	    8250/16450 designs) before this bit is set.
3251da177e4SLinus Torvalds  *
32642047699SGreg Kroah-Hartman  *  SniffUSB observations: the LSR is returned as second byte on the
32742047699SGreg Kroah-Hartman  *  interrupt-in endpoint 0x83 to signal error conditions. Such errors have
32842047699SGreg Kroah-Hartman  *  been seen with minicom/zmodem transfers (CRC errors).
3291da177e4SLinus Torvalds  *
3301da177e4SLinus Torvalds  *
3311da177e4SLinus Torvalds  * Unknown #1
3321da177e4SLinus Torvalds  * -------------------
3331da177e4SLinus Torvalds  *
3341da177e4SLinus Torvalds  *   BmRequestType:  0x40 (0100 0000B)
3351da177e4SLinus Torvalds  *   bRequest:       0x0b
3361da177e4SLinus Torvalds  *   wValue:         0x0000
3371da177e4SLinus Torvalds  *   wIndex:         0x0000
3381da177e4SLinus Torvalds  *   wLength:        0x0001
3391da177e4SLinus Torvalds  *   Data:           0x00
3401da177e4SLinus Torvalds  *
3411da177e4SLinus Torvalds  *   SniffUSB observations (Nov 2003): With the MCT-supplied Windows98 driver
3421da177e4SLinus Torvalds  *   (U2SPORT.VXD, "File version: 1.21P.0104 for Win98/Me"), this request
3431da177e4SLinus Torvalds  *   occurs immediately after a "Baud rate (divisor)" message.  It was not
3441da177e4SLinus Torvalds  *   observed at any other time.  It is unclear what purpose this message
3451da177e4SLinus Torvalds  *   serves.
3461da177e4SLinus Torvalds  *
3471da177e4SLinus Torvalds  *
3481da177e4SLinus Torvalds  * Unknown #2
3491da177e4SLinus Torvalds  * -------------------
3501da177e4SLinus Torvalds  *
3511da177e4SLinus Torvalds  *   BmRequestType:  0x40 (0100 0000B)
3521da177e4SLinus Torvalds  *   bRequest:       0x0c
3531da177e4SLinus Torvalds  *   wValue:         0x0000
3541da177e4SLinus Torvalds  *   wIndex:         0x0000
3551da177e4SLinus Torvalds  *   wLength:        0x0001
3561da177e4SLinus Torvalds  *   Data:           0x00
3571da177e4SLinus Torvalds  *
3581da177e4SLinus Torvalds  *   SniffUSB observations (Nov 2003): With the MCT-supplied Windows98 driver
3591da177e4SLinus Torvalds  *   (U2SPORT.VXD, "File version: 1.21P.0104 for Win98/Me"), this request
3601da177e4SLinus Torvalds  *   occurs immediately after the 'Unknown #1' message (see above).  It was
3611da177e4SLinus Torvalds  *   not observed at any other time.  It is unclear what other purpose (if
3621da177e4SLinus Torvalds  *   any) this message might serve, but without it, the USB/RS-232 adapter
3631da177e4SLinus Torvalds  *   will not write to RS-232 devices which do not assert the 'CTS' signal.
3641da177e4SLinus Torvalds  *
3651da177e4SLinus Torvalds  *
3661da177e4SLinus Torvalds  * Flow control
3671da177e4SLinus Torvalds  * ------------
3681da177e4SLinus Torvalds  *
3691da177e4SLinus Torvalds  *  SniffUSB observations: no flow control specific requests have been realized
3701da177e4SLinus Torvalds  *  apart from DTR/RTS settings. Both signals are dropped for no flow control
3711da177e4SLinus Torvalds  *  but asserted for hardware or software flow control.
3721da177e4SLinus Torvalds  *
3731da177e4SLinus Torvalds  *
3741da177e4SLinus Torvalds  * Endpoint usage
3751da177e4SLinus Torvalds  * --------------
3761da177e4SLinus Torvalds  *
3771da177e4SLinus Torvalds  *  SniffUSB observations: the bulk-out endpoint 0x1 and interrupt-in endpoint
3781da177e4SLinus Torvalds  *  0x81 is used to transmit and receive characters. The second interrupt-in
3791da177e4SLinus Torvalds  *  endpoint 0x83 signals exceptional conditions like modem line changes and
3801da177e4SLinus Torvalds  *  errors. The first byte returned is the MSR and the second byte the LSR.
3811da177e4SLinus Torvalds  *
3821da177e4SLinus Torvalds  *
3831da177e4SLinus Torvalds  * Other observations
3841da177e4SLinus Torvalds  * ------------------
3851da177e4SLinus Torvalds  *
3861da177e4SLinus Torvalds  *  Queued bulk transfers like used in visor.c did not work.
3871da177e4SLinus Torvalds  *
3881da177e4SLinus Torvalds  *
3891da177e4SLinus Torvalds  * Properties of the USB device used (as found in /var/log/messages)
3901da177e4SLinus Torvalds  * -----------------------------------------------------------------
3911da177e4SLinus Torvalds  *
3921da177e4SLinus Torvalds  *  Manufacturer: MCT Corporation.
3931da177e4SLinus Torvalds  *  Product: USB-232 Interfact Controller
3941da177e4SLinus Torvalds  *  SerialNumber: U2S22050
3951da177e4SLinus Torvalds  *
3961da177e4SLinus Torvalds  *    Length              = 18
3971da177e4SLinus Torvalds  *    DescriptorType      = 01
3981da177e4SLinus Torvalds  *    USB version         = 1.00
3991da177e4SLinus Torvalds  *    Vendor:Product      = 0711:0210
4001da177e4SLinus Torvalds  *    MaxPacketSize0      = 8
4011da177e4SLinus Torvalds  *    NumConfigurations   = 1
4021da177e4SLinus Torvalds  *    Device version      = 1.02
4031da177e4SLinus Torvalds  *    Device Class:SubClass:Protocol = 00:00:00
4041da177e4SLinus Torvalds  *      Per-interface classes
4051da177e4SLinus Torvalds  *  Configuration:
4061da177e4SLinus Torvalds  *    bLength             =    9
4071da177e4SLinus Torvalds  *    bDescriptorType     =   02
4081da177e4SLinus Torvalds  *    wTotalLength        = 0027
4091da177e4SLinus Torvalds  *    bNumInterfaces      =   01
4101da177e4SLinus Torvalds  *    bConfigurationValue =   01
4111da177e4SLinus Torvalds  *    iConfiguration      =   00
4121da177e4SLinus Torvalds  *    bmAttributes        =   c0
4131da177e4SLinus Torvalds  *    MaxPower            =  100mA
4141da177e4SLinus Torvalds  *
4151da177e4SLinus Torvalds  *    Interface: 0
4161da177e4SLinus Torvalds  *    Alternate Setting:  0
4171da177e4SLinus Torvalds  *      bLength             =    9
4181da177e4SLinus Torvalds  *      bDescriptorType     =   04
4191da177e4SLinus Torvalds  *      bInterfaceNumber    =   00
4201da177e4SLinus Torvalds  *      bAlternateSetting   =   00
4211da177e4SLinus Torvalds  *      bNumEndpoints       =   03
4221da177e4SLinus Torvalds  *      bInterface Class:SubClass:Protocol =   00:00:00
4231da177e4SLinus Torvalds  *      iInterface          =   00
4241da177e4SLinus Torvalds  *      Endpoint:
4251da177e4SLinus Torvalds  *	  bLength             =    7
4261da177e4SLinus Torvalds  *	  bDescriptorType     =   05
4271da177e4SLinus Torvalds  *	  bEndpointAddress    =   81 (in)
4281da177e4SLinus Torvalds  *	  bmAttributes        =   03 (Interrupt)
4291da177e4SLinus Torvalds  *	  wMaxPacketSize      = 0040
4301da177e4SLinus Torvalds  *	  bInterval           =   02
4311da177e4SLinus Torvalds  *      Endpoint:
4321da177e4SLinus Torvalds  *	  bLength             =    7
4331da177e4SLinus Torvalds  *	  bDescriptorType     =   05
4341da177e4SLinus Torvalds  *	  bEndpointAddress    =   01 (out)
4351da177e4SLinus Torvalds  *	  bmAttributes        =   02 (Bulk)
4361da177e4SLinus Torvalds  *	  wMaxPacketSize      = 0040
4371da177e4SLinus Torvalds  *	  bInterval           =   00
4381da177e4SLinus Torvalds  *      Endpoint:
4391da177e4SLinus Torvalds  *	  bLength             =    7
4401da177e4SLinus Torvalds  *	  bDescriptorType     =   05
4411da177e4SLinus Torvalds  *	  bEndpointAddress    =   83 (in)
4421da177e4SLinus Torvalds  *	  bmAttributes        =   03 (Interrupt)
4431da177e4SLinus Torvalds  *	  wMaxPacketSize      = 0002
4441da177e4SLinus Torvalds  *	  bInterval           =   02
4451da177e4SLinus Torvalds  *
4461da177e4SLinus Torvalds  *
4471da177e4SLinus Torvalds  * Hardware details (added by Martin Hamilton, 2001/12/06)
4481da177e4SLinus Torvalds  * -----------------------------------------------------------------
4491da177e4SLinus Torvalds  *
4501da177e4SLinus Torvalds  * This info was gleaned from opening a Belkin F5U109 DB9 USB serial
4511da177e4SLinus Torvalds  * adaptor, which turns out to simply be a re-badged U232-P9.  We
4521da177e4SLinus Torvalds  * know this because there is a sticky label on the circuit board
4531da177e4SLinus Torvalds  * which says "U232-P9" ;-)
4541da177e4SLinus Torvalds  *
4551da177e4SLinus Torvalds  * The circuit board inside the adaptor contains a Philips PDIUSBD12
45645b844dfSDave Platt  * USB endpoint chip and a Philips P87C52UBAA microcontroller with
4571da177e4SLinus Torvalds  * embedded UART.  Exhaustive documentation for these is available at:
4581da177e4SLinus Torvalds  *
4591da177e4SLinus Torvalds  *   http://www.semiconductors.philips.com/pip/p87c52ubaa
460*631dd1a8SJustin P. Mattock  *   http://www.nxp.com/acrobat_download/various/PDIUSBD12_PROGRAMMING_GUIDE.pdf
4611da177e4SLinus Torvalds  *
4621da177e4SLinus Torvalds  * Thanks to Julian Highfield for the pointer to the Philips database.
4631da177e4SLinus Torvalds  *
4641da177e4SLinus Torvalds  */
4651da177e4SLinus Torvalds 
4661da177e4SLinus Torvalds #endif /* __LINUX_USB_SERIAL_MCT_U232_H */
4671da177e4SLinus Torvalds 
468