![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0+ */ 0002 /* 0003 * Definitions for MCT (Magic Control Technology) USB-RS232 Converter Driver 0004 * 0005 * Copyright (C) 2000 Wolfgang Grandegger (wolfgang@ces.ch) 0006 * 0007 * This driver is for the device MCT USB-RS232 Converter (25 pin, Model No. 0008 * U232-P25) from Magic Control Technology Corp. (there is also a 9 pin 0009 * Model No. U232-P9). See http://www.mct.com.tw/products/product_us232.html 0010 * for further information. The properties of this device are listed at the end 0011 * of this file. This device was used in the Dlink DSB-S25. 0012 * 0013 * All of the information about the device was acquired by using SniffUSB 0014 * on Windows98. The technical details of the reverse engineering are 0015 * summarized at the end of this file. 0016 */ 0017 0018 #ifndef __LINUX_USB_SERIAL_MCT_U232_H 0019 #define __LINUX_USB_SERIAL_MCT_U232_H 0020 0021 #define MCT_U232_VID 0x0711 /* Vendor Id */ 0022 #define MCT_U232_PID 0x0210 /* Original MCT Product Id */ 0023 0024 /* U232-P25, Sitecom */ 0025 #define MCT_U232_SITECOM_PID 0x0230 /* Sitecom Product Id */ 0026 0027 /* DU-H3SP USB BAY hub */ 0028 #define MCT_U232_DU_H3SP_PID 0x0200 /* D-Link DU-H3SP USB BAY */ 0029 0030 /* Belkin badge the MCT U232-P9 as the F5U109 */ 0031 #define MCT_U232_BELKIN_F5U109_VID 0x050d /* Vendor Id */ 0032 #define MCT_U232_BELKIN_F5U109_PID 0x0109 /* Product Id */ 0033 0034 /* 0035 * Vendor Request Interface 0036 */ 0037 #define MCT_U232_SET_REQUEST_TYPE 0x40 0038 #define MCT_U232_GET_REQUEST_TYPE 0xc0 0039 0040 /* Get Modem Status Register (MSR) */ 0041 #define MCT_U232_GET_MODEM_STAT_REQUEST 2 0042 #define MCT_U232_GET_MODEM_STAT_SIZE 1 0043 0044 /* Get Line Control Register (LCR) */ 0045 /* ... not used by this driver */ 0046 #define MCT_U232_GET_LINE_CTRL_REQUEST 6 0047 #define MCT_U232_GET_LINE_CTRL_SIZE 1 0048 0049 /* Set Baud Rate Divisor */ 0050 #define MCT_U232_SET_BAUD_RATE_REQUEST 5 0051 #define MCT_U232_SET_BAUD_RATE_SIZE 4 0052 0053 /* Set Line Control Register (LCR) */ 0054 #define MCT_U232_SET_LINE_CTRL_REQUEST 7 0055 #define MCT_U232_SET_LINE_CTRL_SIZE 1 0056 0057 /* Set Modem Control Register (MCR) */ 0058 #define MCT_U232_SET_MODEM_CTRL_REQUEST 10 0059 #define MCT_U232_SET_MODEM_CTRL_SIZE 1 0060 0061 /* 0062 * This USB device request code is not well understood. It is transmitted by 0063 * the MCT-supplied Windows driver whenever the baud rate changes. 0064 */ 0065 #define MCT_U232_SET_UNKNOWN1_REQUEST 11 /* Unknown functionality */ 0066 #define MCT_U232_SET_UNKNOWN1_SIZE 1 0067 0068 /* 0069 * This USB device request code appears to control whether CTS is required 0070 * during transmission. 0071 * 0072 * Sending a zero byte allows data transmission to a device which is not 0073 * asserting CTS. Sending a '1' byte will cause transmission to be deferred 0074 * until the device asserts CTS. 0075 */ 0076 #define MCT_U232_SET_CTS_REQUEST 12 0077 #define MCT_U232_SET_CTS_SIZE 1 0078 0079 #define MCT_U232_MAX_SIZE 4 /* of MCT_XXX_SIZE */ 0080 0081 /* 0082 * Baud rate (divisor) 0083 * Actually, there are two of them, MCT website calls them "Philips solution" 0084 * and "Intel solution". They are the regular MCT and "Sitecom" for us. 0085 * This is pointless to document in the header, see the code for the bits. 0086 */ 0087 static int mct_u232_calculate_baud_rate(struct usb_serial *serial, 0088 speed_t value, speed_t *result); 0089 0090 /* 0091 * Line Control Register (LCR) 0092 */ 0093 #define MCT_U232_SET_BREAK 0x40 0094 0095 #define MCT_U232_PARITY_SPACE 0x38 0096 #define MCT_U232_PARITY_MARK 0x28 0097 #define MCT_U232_PARITY_EVEN 0x18 0098 #define MCT_U232_PARITY_ODD 0x08 0099 #define MCT_U232_PARITY_NONE 0x00 0100 0101 #define MCT_U232_DATA_BITS_5 0x00 0102 #define MCT_U232_DATA_BITS_6 0x01 0103 #define MCT_U232_DATA_BITS_7 0x02 0104 #define MCT_U232_DATA_BITS_8 0x03 0105 0106 #define MCT_U232_STOP_BITS_2 0x04 0107 #define MCT_U232_STOP_BITS_1 0x00 0108 0109 /* 0110 * Modem Control Register (MCR) 0111 */ 0112 #define MCT_U232_MCR_NONE 0x8 /* Deactivate DTR and RTS */ 0113 #define MCT_U232_MCR_RTS 0xa /* Activate RTS */ 0114 #define MCT_U232_MCR_DTR 0x9 /* Activate DTR */ 0115 0116 /* 0117 * Modem Status Register (MSR) 0118 */ 0119 #define MCT_U232_MSR_INDEX 0x0 /* data[index] */ 0120 #define MCT_U232_MSR_CD 0x80 /* Current CD */ 0121 #define MCT_U232_MSR_RI 0x40 /* Current RI */ 0122 #define MCT_U232_MSR_DSR 0x20 /* Current DSR */ 0123 #define MCT_U232_MSR_CTS 0x10 /* Current CTS */ 0124 #define MCT_U232_MSR_DCD 0x08 /* Delta CD */ 0125 #define MCT_U232_MSR_DRI 0x04 /* Delta RI */ 0126 #define MCT_U232_MSR_DDSR 0x02 /* Delta DSR */ 0127 #define MCT_U232_MSR_DCTS 0x01 /* Delta CTS */ 0128 0129 /* 0130 * Line Status Register (LSR) 0131 */ 0132 #define MCT_U232_LSR_INDEX 1 /* data[index] */ 0133 #define MCT_U232_LSR_ERR 0x80 /* OE | PE | FE | BI */ 0134 #define MCT_U232_LSR_TEMT 0x40 /* transmit register empty */ 0135 #define MCT_U232_LSR_THRE 0x20 /* transmit holding register empty */ 0136 #define MCT_U232_LSR_BI 0x10 /* break indicator */ 0137 #define MCT_U232_LSR_FE 0x08 /* framing error */ 0138 #define MCT_U232_LSR_OE 0x02 /* overrun error */ 0139 #define MCT_U232_LSR_PE 0x04 /* parity error */ 0140 #define MCT_U232_LSR_OE 0x02 /* overrun error */ 0141 #define MCT_U232_LSR_DR 0x01 /* receive data ready */ 0142 0143 0144 /* ----------------------------------------------------------------------------- 0145 * Technical Specification reverse engineered with SniffUSB on Windows98 0146 * ===================================================================== 0147 * 0148 * The technical details of the device have been acquired be using "SniffUSB" 0149 * and the vendor-supplied device driver (version 2.3A) under Windows98. To 0150 * identify the USB vendor-specific requests and to assign them to terminal 0151 * settings (flow control, baud rate, etc.) the program "SerialSettings" from 0152 * William G. Greathouse has been proven to be very useful. I also used the 0153 * Win98 "HyperTerminal" and "usb-robot" on Linux for testing. The results and 0154 * observations are summarized below: 0155 * 0156 * The USB requests seem to be directly mapped to the registers of a 8250, 0157 * 16450 or 16550 UART. The FreeBSD handbook (appendix F.4 "Input/Output 0158 * devices") contains a comprehensive description of UARTs and its registers. 0159 * The bit descriptions are actually taken from there. 0160 * 0161 * 0162 * Baud rate (divisor) 0163 * ------------------- 0164 * 0165 * BmRequestType: 0x40 (0100 0000B) 0166 * bRequest: 0x05 0167 * wValue: 0x0000 0168 * wIndex: 0x0000 0169 * wLength: 0x0004 0170 * Data: divisor = 115200 / baud_rate 0171 * 0172 * SniffUSB observations (Nov 2003): Contrary to the 'wLength' value of 4 0173 * shown above, observations with a Belkin F5U109 adapter, using the 0174 * MCT-supplied Windows98 driver (U2SPORT.VXD, "File version: 1.21P.0104 for 0175 * Win98/Me"), show this request has a length of 1 byte, presumably because 0176 * of the fact that the Belkin adapter and the 'Sitecom U232-P25' adapter 0177 * use a baud-rate code instead of a conventional RS-232 baud rate divisor. 0178 * The current source code for this driver does not reflect this fact, but 0179 * the driver works fine with this adapter/driver combination nonetheless. 0180 * 0181 * 0182 * Line Control Register (LCR) 0183 * --------------------------- 0184 * 0185 * BmRequestType: 0x40 (0100 0000B) 0xc0 (1100 0000B) 0186 * bRequest: 0x07 0x06 0187 * wValue: 0x0000 0188 * wIndex: 0x0000 0189 * wLength: 0x0001 0190 * Data: LCR (see below) 0191 * 0192 * Bit 7: Divisor Latch Access Bit (DLAB). When set, access to the data 0193 * transmit/receive register (THR/RBR) and the Interrupt Enable Register 0194 * (IER) is disabled. Any access to these ports is now redirected to the 0195 * Divisor Latch Registers. Setting this bit, loading the Divisor 0196 * Registers, and clearing DLAB should be done with interrupts disabled. 0197 * Bit 6: Set Break. When set to "1", the transmitter begins to transmit 0198 * continuous Spacing until this bit is set to "0". This overrides any 0199 * bits of characters that are being transmitted. 0200 * Bit 5: Stick Parity. When parity is enabled, setting this bit causes parity 0201 * to always be "1" or "0", based on the value of Bit 4. 0202 * Bit 4: Even Parity Select (EPS). When parity is enabled and Bit 5 is "0", 0203 * setting this bit causes even parity to be transmitted and expected. 0204 * Otherwise, odd parity is used. 0205 * Bit 3: Parity Enable (PEN). When set to "1", a parity bit is inserted 0206 * between the last bit of the data and the Stop Bit. The UART will also 0207 * expect parity to be present in the received data. 0208 * Bit 2: Number of Stop Bits (STB). If set to "1" and using 5-bit data words, 0209 * 1.5 Stop Bits are transmitted and expected in each data word. For 0210 * 6, 7 and 8-bit data words, 2 Stop Bits are transmitted and expected. 0211 * When this bit is set to "0", one Stop Bit is used on each data word. 0212 * Bit 1: Word Length Select Bit #1 (WLSB1) 0213 * Bit 0: Word Length Select Bit #0 (WLSB0) 0214 * Together these bits specify the number of bits in each data word. 0215 * 1 0 Word Length 0216 * 0 0 5 Data Bits 0217 * 0 1 6 Data Bits 0218 * 1 0 7 Data Bits 0219 * 1 1 8 Data Bits 0220 * 0221 * SniffUSB observations: Bit 7 seems not to be used. There seem to be two bugs 0222 * in the Win98 driver: the break does not work (bit 6 is not asserted) and the 0223 * stick parity bit is not cleared when set once. The LCR can also be read 0224 * back with USB request 6 but this has never been observed with SniffUSB. 0225 * 0226 * 0227 * Modem Control Register (MCR) 0228 * ---------------------------- 0229 * 0230 * BmRequestType: 0x40 (0100 0000B) 0231 * bRequest: 0x0a 0232 * wValue: 0x0000 0233 * wIndex: 0x0000 0234 * wLength: 0x0001 0235 * Data: MCR (Bit 4..7, see below) 0236 * 0237 * Bit 7: Reserved, always 0. 0238 * Bit 6: Reserved, always 0. 0239 * Bit 5: Reserved, always 0. 0240 * Bit 4: Loop-Back Enable. When set to "1", the UART transmitter and receiver 0241 * are internally connected together to allow diagnostic operations. In 0242 * addition, the UART modem control outputs are connected to the UART 0243 * modem control inputs. CTS is connected to RTS, DTR is connected to 0244 * DSR, OUT1 is connected to RI, and OUT 2 is connected to DCD. 0245 * Bit 3: OUT 2. An auxiliary output that the host processor may set high or 0246 * low. In the IBM PC serial adapter (and most clones), OUT 2 is used 0247 * to tri-state (disable) the interrupt signal from the 0248 * 8250/16450/16550 UART. 0249 * Bit 2: OUT 1. An auxiliary output that the host processor may set high or 0250 * low. This output is not used on the IBM PC serial adapter. 0251 * Bit 1: Request to Send (RTS). When set to "1", the output of the UART -RTS 0252 * line is Low (Active). 0253 * Bit 0: Data Terminal Ready (DTR). When set to "1", the output of the UART 0254 * -DTR line is Low (Active). 0255 * 0256 * SniffUSB observations: Bit 2 and 4 seem not to be used but bit 3 has been 0257 * seen _always_ set. 0258 * 0259 * 0260 * Modem Status Register (MSR) 0261 * --------------------------- 0262 * 0263 * BmRequestType: 0xc0 (1100 0000B) 0264 * bRequest: 0x02 0265 * wValue: 0x0000 0266 * wIndex: 0x0000 0267 * wLength: 0x0001 0268 * Data: MSR (see below) 0269 * 0270 * Bit 7: Data Carrier Detect (CD). Reflects the state of the DCD line on the 0271 * UART. 0272 * Bit 6: Ring Indicator (RI). Reflects the state of the RI line on the UART. 0273 * Bit 5: Data Set Ready (DSR). Reflects the state of the DSR line on the UART. 0274 * Bit 4: Clear To Send (CTS). Reflects the state of the CTS line on the UART. 0275 * Bit 3: Delta Data Carrier Detect (DDCD). Set to "1" if the -DCD line has 0276 * changed state one more more times since the last time the MSR was 0277 * read by the host. 0278 * Bit 2: Trailing Edge Ring Indicator (TERI). Set to "1" if the -RI line has 0279 * had a low to high transition since the last time the MSR was read by 0280 * the host. 0281 * Bit 1: Delta Data Set Ready (DDSR). Set to "1" if the -DSR line has changed 0282 * state one more more times since the last time the MSR was read by the 0283 * host. 0284 * Bit 0: Delta Clear To Send (DCTS). Set to "1" if the -CTS line has changed 0285 * state one more times since the last time the MSR was read by the 0286 * host. 0287 * 0288 * SniffUSB observations: the MSR is also returned as first byte on the 0289 * interrupt-in endpoint 0x83 to signal changes of modem status lines. The USB 0290 * request to read MSR cannot be applied during normal device operation. 0291 * 0292 * 0293 * Line Status Register (LSR) 0294 * -------------------------- 0295 * 0296 * Bit 7 Error in Receiver FIFO. On the 8250/16450 UART, this bit is zero. 0297 * This bit is set to "1" when any of the bytes in the FIFO have one 0298 * or more of the following error conditions: PE, FE, or BI. 0299 * Bit 6 Transmitter Empty (TEMT). When set to "1", there are no words 0300 * remaining in the transmit FIFO or the transmit shift register. The 0301 * transmitter is completely idle. 0302 * Bit 5 Transmitter Holding Register Empty (THRE). When set to "1", the 0303 * FIFO (or holding register) now has room for at least one additional 0304 * word to transmit. The transmitter may still be transmitting when 0305 * this bit is set to "1". 0306 * Bit 4 Break Interrupt (BI). The receiver has detected a Break signal. 0307 * Bit 3 Framing Error (FE). A Start Bit was detected but the Stop Bit did 0308 * not appear at the expected time. The received word is probably 0309 * garbled. 0310 * Bit 2 Parity Error (PE). The parity bit was incorrect for the word 0311 * received. 0312 * Bit 1 Overrun Error (OE). A new word was received and there was no room 0313 * in the receive buffer. The newly-arrived word in the shift register 0314 * is discarded. On 8250/16450 UARTs, the word in the holding register 0315 * is discarded and the newly- arrived word is put in the holding 0316 * register. 0317 * Bit 0 Data Ready (DR). One or more words are in the receive FIFO that the 0318 * host may read. A word must be completely received and moved from 0319 * the shift register into the FIFO (or holding register for 0320 * 8250/16450 designs) before this bit is set. 0321 * 0322 * SniffUSB observations: the LSR is returned as second byte on the 0323 * interrupt-in endpoint 0x83 to signal error conditions. Such errors have 0324 * been seen with minicom/zmodem transfers (CRC errors). 0325 * 0326 * 0327 * Unknown #1 0328 * ------------------- 0329 * 0330 * BmRequestType: 0x40 (0100 0000B) 0331 * bRequest: 0x0b 0332 * wValue: 0x0000 0333 * wIndex: 0x0000 0334 * wLength: 0x0001 0335 * Data: 0x00 0336 * 0337 * SniffUSB observations (Nov 2003): With the MCT-supplied Windows98 driver 0338 * (U2SPORT.VXD, "File version: 1.21P.0104 for Win98/Me"), this request 0339 * occurs immediately after a "Baud rate (divisor)" message. It was not 0340 * observed at any other time. It is unclear what purpose this message 0341 * serves. 0342 * 0343 * 0344 * Unknown #2 0345 * ------------------- 0346 * 0347 * BmRequestType: 0x40 (0100 0000B) 0348 * bRequest: 0x0c 0349 * wValue: 0x0000 0350 * wIndex: 0x0000 0351 * wLength: 0x0001 0352 * Data: 0x00 0353 * 0354 * SniffUSB observations (Nov 2003): With the MCT-supplied Windows98 driver 0355 * (U2SPORT.VXD, "File version: 1.21P.0104 for Win98/Me"), this request 0356 * occurs immediately after the 'Unknown #1' message (see above). It was 0357 * not observed at any other time. It is unclear what other purpose (if 0358 * any) this message might serve, but without it, the USB/RS-232 adapter 0359 * will not write to RS-232 devices which do not assert the 'CTS' signal. 0360 * 0361 * 0362 * Flow control 0363 * ------------ 0364 * 0365 * SniffUSB observations: no flow control specific requests have been realized 0366 * apart from DTR/RTS settings. Both signals are dropped for no flow control 0367 * but asserted for hardware or software flow control. 0368 * 0369 * 0370 * Endpoint usage 0371 * -------------- 0372 * 0373 * SniffUSB observations: the bulk-out endpoint 0x1 and interrupt-in endpoint 0374 * 0x81 is used to transmit and receive characters. The second interrupt-in 0375 * endpoint 0x83 signals exceptional conditions like modem line changes and 0376 * errors. The first byte returned is the MSR and the second byte the LSR. 0377 * 0378 * 0379 * Other observations 0380 * ------------------ 0381 * 0382 * Queued bulk transfers like used in visor.c did not work. 0383 * 0384 * 0385 * Properties of the USB device used (as found in /var/log/messages) 0386 * ----------------------------------------------------------------- 0387 * 0388 * Manufacturer: MCT Corporation. 0389 * Product: USB-232 Interfact Controller 0390 * SerialNumber: U2S22050 0391 * 0392 * Length = 18 0393 * DescriptorType = 01 0394 * USB version = 1.00 0395 * Vendor:Product = 0711:0210 0396 * MaxPacketSize0 = 8 0397 * NumConfigurations = 1 0398 * Device version = 1.02 0399 * Device Class:SubClass:Protocol = 00:00:00 0400 * Per-interface classes 0401 * Configuration: 0402 * bLength = 9 0403 * bDescriptorType = 02 0404 * wTotalLength = 0027 0405 * bNumInterfaces = 01 0406 * bConfigurationValue = 01 0407 * iConfiguration = 00 0408 * bmAttributes = c0 0409 * MaxPower = 100mA 0410 * 0411 * Interface: 0 0412 * Alternate Setting: 0 0413 * bLength = 9 0414 * bDescriptorType = 04 0415 * bInterfaceNumber = 00 0416 * bAlternateSetting = 00 0417 * bNumEndpoints = 03 0418 * bInterface Class:SubClass:Protocol = 00:00:00 0419 * iInterface = 00 0420 * Endpoint: 0421 * bLength = 7 0422 * bDescriptorType = 05 0423 * bEndpointAddress = 81 (in) 0424 * bmAttributes = 03 (Interrupt) 0425 * wMaxPacketSize = 0040 0426 * bInterval = 02 0427 * Endpoint: 0428 * bLength = 7 0429 * bDescriptorType = 05 0430 * bEndpointAddress = 01 (out) 0431 * bmAttributes = 02 (Bulk) 0432 * wMaxPacketSize = 0040 0433 * bInterval = 00 0434 * Endpoint: 0435 * bLength = 7 0436 * bDescriptorType = 05 0437 * bEndpointAddress = 83 (in) 0438 * bmAttributes = 03 (Interrupt) 0439 * wMaxPacketSize = 0002 0440 * bInterval = 02 0441 * 0442 * 0443 * Hardware details (added by Martin Hamilton, 2001/12/06) 0444 * ----------------------------------------------------------------- 0445 * 0446 * This info was gleaned from opening a Belkin F5U109 DB9 USB serial 0447 * adaptor, which turns out to simply be a re-badged U232-P9. We 0448 * know this because there is a sticky label on the circuit board 0449 * which says "U232-P9" ;-) 0450 * 0451 * The circuit board inside the adaptor contains a Philips PDIUSBD12 0452 * USB endpoint chip and a Philips P87C52UBAA microcontroller with 0453 * embedded UART. Exhaustive documentation for these is available at: 0454 * 0455 * http://www.semiconductors.philips.com/pip/p87c52ubaa 0456 * http://www.nxp.com/acrobat_download/various/PDIUSBD12_PROGRAMMING_GUIDE.pdf 0457 * 0458 * Thanks to Julian Highfield for the pointer to the Philips database. 0459 * 0460 */ 0461 0462 #endif /* __LINUX_USB_SERIAL_MCT_U232_H */ 0463
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |