aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/ftdi_sio.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/ftdi_sio.h')
-rw-r--r--drivers/usb/serial/ftdi_sio.h126
1 files changed, 66 insertions, 60 deletions
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index ff9bf80327a3..213fe3d61282 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -23,14 +23,16 @@
23 */ 23 */
24 24
25/* Commands */ 25/* Commands */
26#define FTDI_SIO_RESET 0 /* Reset the port */ 26#define FTDI_SIO_RESET 0 /* Reset the port */
27#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 27#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
28#define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */ 28#define FTDI_SIO_SET_FLOW_CTRL 2 /* Set flow control register */
29#define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */ 29#define FTDI_SIO_SET_BAUD_RATE 3 /* Set baud rate */
30#define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of the port */ 30#define FTDI_SIO_SET_DATA 4 /* Set the data characteristics of
31#define FTDI_SIO_GET_MODEM_STATUS 5 /* Retrieve current value of modem status register */ 31 the port */
32#define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */ 32#define FTDI_SIO_GET_MODEM_STATUS 5 /* Retrieve current value of modem
33#define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */ 33 status register */
34#define FTDI_SIO_SET_EVENT_CHAR 6 /* Set the event character */
35#define FTDI_SIO_SET_ERROR_CHAR 7 /* Set the error character */
34#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */ 36#define FTDI_SIO_SET_LATENCY_TIMER 9 /* Set the latency timer */
35#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */ 37#define FTDI_SIO_GET_LATENCY_TIMER 10 /* Get the latency timer */
36 38
@@ -52,7 +54,7 @@
52 */ 54 */
53 55
54/* Port Identifier Table */ 56/* Port Identifier Table */
55#define PIT_DEFAULT 0 /* SIOA */ 57#define PIT_DEFAULT 0 /* SIOA */
56#define PIT_SIOA 1 /* SIOA */ 58#define PIT_SIOA 1 /* SIOA */
57/* The device this driver is tested with one has only one port */ 59/* The device this driver is tested with one has only one port */
58#define PIT_SIOB 2 /* SIOB */ 60#define PIT_SIOB 2 /* SIOB */
@@ -103,20 +105,21 @@
103 * wLength: 0 105 * wLength: 0
104 * Data: None 106 * Data: None
105 * The BaudDivisor values are calculated as follows: 107 * The BaudDivisor values are calculated as follows:
106 * - BaseClock is either 12000000 or 48000000 depending on the device. FIXME: I wish 108 * - BaseClock is either 12000000 or 48000000 depending on the device.
107 * I knew how to detect old chips to select proper base clock! 109 * FIXME: I wish I knew how to detect old chips to select proper base clock!
108 * - BaudDivisor is a fixed point number encoded in a funny way. 110 * - BaudDivisor is a fixed point number encoded in a funny way.
109 * (--WRONG WAY OF THINKING--) 111 * (--WRONG WAY OF THINKING--)
110 * BaudDivisor is a fixed point number encoded with following bit weighs: 112 * BaudDivisor is a fixed point number encoded with following bit weighs:
111 * (-2)(-1)(13..0). It is a radical with a denominator of 4, so values 113 * (-2)(-1)(13..0). It is a radical with a denominator of 4, so values
112 * end with 0.0 (00...), 0.25 (10...), 0.5 (01...), and 0.75 (11...). 114 * end with 0.0 (00...), 0.25 (10...), 0.5 (01...), and 0.75 (11...).
113 * (--THE REALITY--) 115 * (--THE REALITY--)
114 * The both-bits-set has quite different meaning from 0.75 - the chip designers 116 * The both-bits-set has quite different meaning from 0.75 - the chip
115 * have decided it to mean 0.125 instead of 0.75. 117 * designers have decided it to mean 0.125 instead of 0.75.
116 * This info looked up in FTDI application note "FT8U232 DEVICES \ Data Rates 118 * This info looked up in FTDI application note "FT8U232 DEVICES \ Data Rates
117 * and Flow Control Consideration for USB to RS232". 119 * and Flow Control Consideration for USB to RS232".
118 * - BaudDivisor = (BaseClock / 16) / BaudRate, where the (=) operation should 120 * - BaudDivisor = (BaseClock / 16) / BaudRate, where the (=) operation should
119 * automagically re-encode the resulting value to take fractions into consideration. 121 * automagically re-encode the resulting value to take fractions into
122 * consideration.
120 * As all values are integers, some bit twiddling is in order: 123 * As all values are integers, some bit twiddling is in order:
121 * BaudDivisor = (BaseClock / 16 / BaudRate) | 124 * BaudDivisor = (BaseClock / 16 / BaudRate) |
122 * (((BaseClock / 2 / BaudRate) & 4) ? 0x4000 // 0.5 125 * (((BaseClock / 2 / BaudRate) & 4) ? 0x4000 // 0.5
@@ -146,7 +149,7 @@
146 * not supported by the FT8U232AM). 149 * not supported by the FT8U232AM).
147 */ 150 */
148 151
149typedef enum { 152enum ftdi_chip_type {
150 SIO = 1, 153 SIO = 1,
151 FT8U232AM = 2, 154 FT8U232AM = 2,
152 FT232BM = 3, 155 FT232BM = 3,
@@ -154,37 +157,36 @@ typedef enum {
154 FT232RL = 5, 157 FT232RL = 5,
155 FT2232H = 6, 158 FT2232H = 6,
156 FT4232H = 7 159 FT4232H = 7
157} ftdi_chip_type_t; 160};
158 161
159typedef enum { 162enum ftdi_sio_baudrate {
160 ftdi_sio_b300 = 0, 163 ftdi_sio_b300 = 0,
161 ftdi_sio_b600 = 1, 164 ftdi_sio_b600 = 1,
162 ftdi_sio_b1200 = 2, 165 ftdi_sio_b1200 = 2,
163 ftdi_sio_b2400 = 3, 166 ftdi_sio_b2400 = 3,
164 ftdi_sio_b4800 = 4, 167 ftdi_sio_b4800 = 4,
165 ftdi_sio_b9600 = 5, 168 ftdi_sio_b9600 = 5,
166 ftdi_sio_b19200 = 6, 169 ftdi_sio_b19200 = 6,
167 ftdi_sio_b38400 = 7, 170 ftdi_sio_b38400 = 7,
168 ftdi_sio_b57600 = 8, 171 ftdi_sio_b57600 = 8,
169 ftdi_sio_b115200 = 9 172 ftdi_sio_b115200 = 9
170} FTDI_SIO_baudrate_t; 173};
171 174
172/* 175/*
173 * The ftdi_8U232AM_xxMHz_byyy constants have been removed. The encoded divisor values 176 * The ftdi_8U232AM_xxMHz_byyy constants have been removed. The encoded divisor
174 * are calculated internally. 177 * values are calculated internally.
175 */ 178 */
176 179#define FTDI_SIO_SET_DATA_REQUEST FTDI_SIO_SET_DATA
177#define FTDI_SIO_SET_DATA_REQUEST FTDI_SIO_SET_DATA 180#define FTDI_SIO_SET_DATA_REQUEST_TYPE 0x40
178#define FTDI_SIO_SET_DATA_REQUEST_TYPE 0x40 181#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8)
179#define FTDI_SIO_SET_DATA_PARITY_NONE (0x0 << 8) 182#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8)
180#define FTDI_SIO_SET_DATA_PARITY_ODD (0x1 << 8) 183#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8)
181#define FTDI_SIO_SET_DATA_PARITY_EVEN (0x2 << 8) 184#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8)
182#define FTDI_SIO_SET_DATA_PARITY_MARK (0x3 << 8) 185#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8)
183#define FTDI_SIO_SET_DATA_PARITY_SPACE (0x4 << 8) 186#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11)
184#define FTDI_SIO_SET_DATA_STOP_BITS_1 (0x0 << 11) 187#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11)
185#define FTDI_SIO_SET_DATA_STOP_BITS_15 (0x1 << 11) 188#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11)
186#define FTDI_SIO_SET_DATA_STOP_BITS_2 (0x2 << 11) 189#define FTDI_SIO_SET_BREAK (0x1 << 14)
187#define FTDI_SIO_SET_BREAK (0x1 << 14)
188/* FTDI_SIO_SET_DATA */ 190/* FTDI_SIO_SET_DATA */
189 191
190/* 192/*
@@ -287,8 +289,8 @@ typedef enum {
287 * 289 *
288 * A value of zero in the hIndex field disables handshaking 290 * A value of zero in the hIndex field disables handshaking
289 * 291 *
290 * If Xon/Xoff handshaking is specified, the hValue field should contain the XOFF character 292 * If Xon/Xoff handshaking is specified, the hValue field should contain the
291 * and the lValue field contains the XON character. 293 * XOFF character and the lValue field contains the XON character.
292 */ 294 */
293 295
294/* 296/*
@@ -373,7 +375,10 @@ typedef enum {
373 375
374/* FTDI_SIO_SET_ERROR_CHAR */ 376/* FTDI_SIO_SET_ERROR_CHAR */
375 377
376/* Set the parity error replacement character for the specified communications port */ 378/*
379 * Set the parity error replacement character for the specified communications
380 * port
381 */
377 382
378/* 383/*
379 * BmRequestType: 0100 0000b 384 * BmRequestType: 0100 0000b
@@ -496,9 +501,10 @@ typedef enum {
496 * 501 *
497 * IN Endpoint 502 * IN Endpoint
498 * 503 *
499 * The device reserves the first two bytes of data on this endpoint to contain the current 504 * The device reserves the first two bytes of data on this endpoint to contain
500 * values of the modem and line status registers. In the absence of data, the device 505 * the current values of the modem and line status registers. In the absence of
501 * generates a message consisting of these two status bytes every 40 ms 506 * data, the device generates a message consisting of these two status bytes
507 * every 40 ms
502 * 508 *
503 * Byte 0: Modem Status 509 * Byte 0: Modem Status
504 * 510 *
@@ -530,21 +536,21 @@ typedef enum {
530#define FTDI_RS0_RI (1 << 6) 536#define FTDI_RS0_RI (1 << 6)
531#define FTDI_RS0_RLSD (1 << 7) 537#define FTDI_RS0_RLSD (1 << 7)
532 538
533#define FTDI_RS_DR 1 539#define FTDI_RS_DR 1
534#define FTDI_RS_OE (1<<1) 540#define FTDI_RS_OE (1<<1)
535#define FTDI_RS_PE (1<<2) 541#define FTDI_RS_PE (1<<2)
536#define FTDI_RS_FE (1<<3) 542#define FTDI_RS_FE (1<<3)
537#define FTDI_RS_BI (1<<4) 543#define FTDI_RS_BI (1<<4)
538#define FTDI_RS_THRE (1<<5) 544#define FTDI_RS_THRE (1<<5)
539#define FTDI_RS_TEMT (1<<6) 545#define FTDI_RS_TEMT (1<<6)
540#define FTDI_RS_FIFO (1<<7) 546#define FTDI_RS_FIFO (1<<7)
541 547
542/* 548/*
543 * OUT Endpoint 549 * OUT Endpoint
544 * 550 *
545 * This device reserves the first bytes of data on this endpoint contain the length 551 * This device reserves the first bytes of data on this endpoint contain the
546 * and port identifier of the message. For the FTDI USB Serial converter the port 552 * length and port identifier of the message. For the FTDI USB Serial converter
547 * identifier is always 1. 553 * the port identifier is always 1.
548 * 554 *
549 * Byte 0: Line Status 555 * Byte 0: Line Status
550 * 556 *