USB: serial: xr: add support for more device types
Subsystems (3)
Johan Hovold
maintainercover USB: serial: xr: add support for more device types
[ I apparently missed the last three patches of the series when posting
on March 30th so resending the whole series. ]
This series adds support for another nine models of Maxlinerar/Exar USB UARTs to the xr driver. The various models can be divided into four types:
XR21V141X
XR21B142X
XR21B1411
XR22804with different register layouts and features.
All types can be used in CDC-ACM mode but further features such as hardware and software flow control and in-band line status are available in a second "custom driver" mode.
The fact that hardware flow control is enabled by default in CDC-ACM mode also prevents using the standard CDC-ACM driver in cases where the hardware engineers have failed to properly connect the CTS input.
The currently supported XR21V141X type stands out from the other three by not being able to accept CDC requests without always entering CDC-ACM mode, requiring a different enable/disable sequence and by using a distinct register layout for certain functionality.
Expect for the above, most differences can be handled by simply using different set of register addresses.
Note that this series depends on the recently posted multi-interface-function series.
Johan
Johan Hovold (11):
USB: serial: xr: add support for XR21V1412 and XR21V1414
USB: serial: xr: rename GPIO-mode defines
USB: serial: xr: rename GPIO-pin defines
USB: serial: xr: move pin configuration to probe
USB: serial: xr: drop type prefix from shared defines
USB: serial: xr: add type abstraction
USB: serial: xr: add support for XR21B1421, XR21B1422 and XR21B1424
USB: serial: xr: add support for XR21B1411
USB: serial: xr: add support for XR22801, XR22802, XR22804
USB: serial: xr: reset FIFOs on open
USB: serial: xr: add copyright notice
Mauro Carvalho Chehab (1):
USB: cdc-acm: add more Maxlinear/Exar models to ignore list
drivers/usb/class/cdc-acm.c | 14 +- drivers/usb/serial/xr_serial.c | 727 ++++++++++++++++++++++++++------- 2 files changed, 580 insertions(+), 161 deletions(-)
Signature · 1 line
2.26.3
Johan Hovold
maintainerPATCH 1/12 USB: serial: xr: add support for XR21V1412 and XR21V1414
Add support for the two- and four-port variants of XR21V1410.
Use the interface number of each control interface (e.g. 0, 2, 4, 6) to derive the zero-based channel index:
XR21V1410 0 XR21V1412 0, 1 XR21V1414 0, 1, 2, 3
Note that the UART registers reside in separate blocks per channel, while the UART Manager functionality is implemented using per-channel registers.
--- drivers/usb/serial/xr_serial.c | 55 +++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-)
drivers/usb/serial/xr_serial.c +51 -4
@@ -109,6 +109,10 @@ struct xr_txrx_clk_mask {#define XR21V141X_REG_GPIO_CLR 0x1e#define XR21V141X_REG_GPIO_STATUS 0x1f +struct xr_data { +u8 channel;/* zero-based index */ +}; +static int xr_set_reg (struct usb_serial_port *port,u8 block,u8 reg,u8 val) {struct usb_serial *serial = port->serial;
@@ -160,16 +164,31 @@ static int xr_get_reg(struct usb_serial_port *port, u8 block, u8 reg, u8 *val)static int xr_set_reg_uart (struct usb_serial_port *port,u8 reg,u8 val) { -return xr_set_reg (port,XR21V141X_UART_REG_BLOCK , reg, val); +struct xr_data *data =usb_get_serial_port_data (port); +u8 block; + + block =XR21V141X_UART_REG_BLOCK + data->channel; + +return xr_set_reg (port, block, reg, val); }static int xr_get_reg_uart (struct usb_serial_port *port,u8 reg,u8 *val) { -return xr_get_reg (port,XR21V141X_UART_REG_BLOCK , reg, val); +struct xr_data *data =usb_get_serial_port_data (port); +u8 block; + + block =XR21V141X_UART_REG_BLOCK + data->channel; + +return xr_get_reg (port, block, reg, val); } -static int xr_set_reg_um (struct usb_serial_port *port,u8 reg,u8 val) +static int xr_set_reg_um (struct usb_serial_port *port,u8 reg_base,u8 val) { +struct xr_data *data =usb_get_serial_port_data (port); +u8 reg; + + reg = reg_base + data->channel; +return xr_set_reg (port,XR21V141X_UM_REG_BLOCK , reg, val); }
@@ -577,8 +596,34 @@ static int xr_probe(struct usb_serial *serial, const struct usb_device_id *id)return 0 ; } +static int xr_port_probe (struct usb_serial_port *port) +{ +struct usb_interface_descriptor *desc; +struct xr_data *data; + + data =kzalloc (sizeof (*data),GFP_KERNEL ); +if (!data) +return -ENOMEM ; + + desc = &port->serial->interface->cur_altsetting->desc; + data->channel = desc->bInterfaceNumber /2 ; + +usb_set_serial_port_data (port, data); + +return 0 ; +} + +static void xr_port_remove (struct usb_serial_port *port) +{ +struct xr_data *data =usb_get_serial_port_data (port); + +kfree (data); +} +static const struct usb_device_id id_table[] = { - {USB_DEVICE_INTERFACE_CLASS (0x04e2 ,0x1410 ,USB_CLASS_COMM ) },/* XR21V141X */ + {USB_DEVICE_INTERFACE_CLASS (0x04e2 ,0x1410 ,USB_CLASS_COMM ) },/* XR21V1410 */ + {USB_DEVICE_INTERFACE_CLASS (0x04e2 ,0x1412 ,USB_CLASS_COMM ) },/* XR21V1412 */ + {USB_DEVICE_INTERFACE_CLASS (0x04e2 ,0x1414 ,USB_CLASS_COMM ) },/* XR21V1414 */ { } };MODULE_DEVICE_TABLE (usb, id_table);
@@ -591,6 +636,8 @@ static struct usb_serial_driver xr_device = { .id_table = id_table, .num_ports = 1, .probe = xr_probe, + .port_probe = xr_port_probe, + .port_remove = xr_port_remove, .open = xr_open, .close = xr_close, .break_ctl = xr_break_ctl,
Signature · 1 line
2.26.3
Johan Hovold
maintainerPATCH 2/12 USB: serial: xr: rename GPIO-mode defines
In reply to Johan HovoldRename the GPIO mode defines so that they reflect the datasheet and how they are used.
--- drivers/usb/serial/xr_serial.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/usb/serial/xr_serial.c +7 -7
@@ -88,11 +88,11 @@ struct xr_txrx_clk_mask {#define XR21V141X_UART_FLOW_MODE_HW 0x1#define XR21V141X_UART_FLOW_MODE_SW 0x2 -#define XR21V141X_UART_MODE_GPIO_MASK GENMASK(2, 0) -#define XR21V141X_UART_MODE_RTS_CTS 0x1 -#define XR21V141X_UART_MODE_DTR_DSR 0x2 -#define XR21V141X_UART_MODE_RS485 0x3 -#define XR21V141X_UART_MODE_RS485_ADDR 0x4 +#define XR21V141X_GPIO_MODE_MASK GENMASK(2, 0) +#define XR21V141X_GPIO_MODE_RTS_CTS 0x1 +#define XR21V141X_GPIO_MODE_DTR_DSR 0x2 +#define XR21V141X_GPIO_MODE_RS485 0x3 +#define XR21V141X_GPIO_MODE_RS485_ADDR 0x4#define XR21V141X_REG_ENABLE 0x03#define XR21V141X_REG_FORMAT 0x0b
@@ -433,11 +433,11 @@ static void xr_set_flow_mode(struct tty_struct *tty,return ;/* Set GPIO mode for controlling the pins manually by default. */ - gpio_mode &= ~XR21V141X_UART_MODE_GPIO_MASK ; + gpio_mode &= ~XR21V141X_GPIO_MODE_MASK ;if (C_CRTSCTS (tty) &&C_BAUD (tty) !=B0 ) {dev_dbg (&port->dev,"Enabling hardware flow ctrl\n" ); - gpio_mode |=XR21V141X_UART_MODE_RTS_CTS ; + gpio_mode |=XR21V141X_GPIO_MODE_RTS_CTS ; flow =XR21V141X_UART_FLOW_MODE_HW ; }else if (I_IXON (tty)) {u8 start_char =START_CHAR (tty);
Signature · 1 line
2.26.3
Johan Hovold
maintainerPATCH 3/12 USB: serial: xr: rename GPIO-pin defines
In reply to Johan HovoldRename the GPIO-pin defines so that they reflect how they are used.
--- drivers/usb/serial/xr_serial.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/usb/serial/xr_serial.c +17 -17
@@ -57,12 +57,12 @@ struct xr_txrx_clk_mask {#define XR21V141X_UART_ENABLE_TX 0x1#define XR21V141X_UART_ENABLE_RX 0x2 -#define XR21V141X_UART_MODE_RI BIT(0) -#define XR21V141X_UART_MODE_CD BIT(1) -#define XR21V141X_UART_MODE_DSR BIT(2) -#define XR21V141X_UART_MODE_DTR BIT(3) -#define XR21V141X_UART_MODE_CTS BIT(4) -#define XR21V141X_UART_MODE_RTS BIT(5) +#define XR21V141X_GPIO_RI BIT(0) +#define XR21V141X_GPIO_CD BIT(1) +#define XR21V141X_GPIO_DSR BIT(2) +#define XR21V141X_GPIO_DTR BIT(3) +#define XR21V141X_GPIO_CTS BIT(4) +#define XR21V141X_GPIO_RTS BIT(5)#define XR21V141X_UART_BREAK_ON 0xff#define XR21V141X_UART_BREAK_OFF 0
@@ -250,12 +250,12 @@ static int xr_tiocmget(struct tty_struct *tty)* Modem control pins are active low, so reading '0' means it is active * and '1' means not active. */ - ret = ((status &XR21V141X_UART_MODE_DTR ) ?0 :TIOCM_DTR ) | - ((status &XR21V141X_UART_MODE_RTS ) ?0 :TIOCM_RTS ) | - ((status &XR21V141X_UART_MODE_CTS ) ?0 :TIOCM_CTS ) | - ((status &XR21V141X_UART_MODE_DSR ) ?0 :TIOCM_DSR ) | - ((status &XR21V141X_UART_MODE_RI ) ?0 :TIOCM_RI ) | - ((status &XR21V141X_UART_MODE_CD ) ?0 :TIOCM_CD ); + ret = ((status &XR21V141X_GPIO_DTR ) ?0 :TIOCM_DTR ) | + ((status &XR21V141X_GPIO_RTS ) ?0 :TIOCM_RTS ) | + ((status &XR21V141X_GPIO_CTS ) ?0 :TIOCM_CTS ) | + ((status &XR21V141X_GPIO_DSR ) ?0 :TIOCM_DSR ) | + ((status &XR21V141X_GPIO_RI ) ?0 :TIOCM_RI ) | + ((status &XR21V141X_GPIO_CD ) ?0 :TIOCM_CD );return ret; }
@@ -269,13 +269,13 @@ static int xr_tiocmset_port(struct usb_serial_port *port,/* Modem control pins are active low, so set & clr are swapped */ if (set &TIOCM_RTS ) - gpio_clr |=XR21V141X_UART_MODE_RTS ; + gpio_clr |=XR21V141X_GPIO_RTS ;if (set &TIOCM_DTR ) - gpio_clr |=XR21V141X_UART_MODE_DTR ; + gpio_clr |=XR21V141X_GPIO_DTR ;if (clear &TIOCM_RTS ) - gpio_set |=XR21V141X_UART_MODE_RTS ; + gpio_set |=XR21V141X_GPIO_RTS ;if (clear &TIOCM_DTR ) - gpio_set |=XR21V141X_UART_MODE_DTR ; + gpio_set |=XR21V141X_GPIO_DTR ;/* Writing '0' to gpio_{set/clr} bits has no effect, so no need to do */ if (gpio_clr)
@@ -545,7 +545,7 @@ static int xr_open(struct tty_struct *tty, struct usb_serial_port *port)* Configure DTR and RTS as outputs and RI, CD, DSR and CTS as * inputs. */ - gpio_dir =XR21V141X_UART_MODE_DTR |XR21V141X_UART_MODE_RTS ; + gpio_dir =XR21V141X_GPIO_DTR |XR21V141X_GPIO_RTS ;xr_set_reg_uart (port,XR21V141X_REG_GPIO_DIR , gpio_dir);/* Setup termios */
Signature · 1 line
2.26.3
Johan Hovold
maintainerPATCH 4/12 USB: serial: xr: move pin configuration to probe
In reply to Johan HovoldThere's no need to configure the pins on every open and judging from the vendor driver and datasheet it can be done before enabling the UART.
Move pin configuration from open() to port probe and make sure to deassert DTR and RTS after configuring all pins as GPIO.
--- drivers/usb/serial/xr_serial.c | 45 ++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 8 deletions(-)
drivers/usb/serial/xr_serial.c +37 -8
@@ -532,7 +532,6 @@ static void xr_set_termios(struct tty_struct *tty,static int xr_open (struct tty_struct *tty,struct usb_serial_port *port) { -u8 gpio_dir;int ret; ret =xr_uart_enable (port);
@@ -541,13 +540,6 @@ static int xr_open(struct tty_struct *tty, struct usb_serial_port *port)return ret; } -/* -* Configure DTR and RTS as outputs and RI, CD, DSR and CTS as -* inputs. -*/ - gpio_dir =XR21V141X_GPIO_DTR |XR21V141X_GPIO_RTS ; -xr_set_reg_uart (port,XR21V141X_REG_GPIO_DIR , gpio_dir); -/* Setup termios */ if (tty)xr_set_termios (tty, port,NULL );
@@ -596,10 +588,38 @@ static int xr_probe(struct usb_serial *serial, const struct usb_device_id *id)return 0 ; } +static int xr_gpio_init (struct usb_serial_port *port) +{ +u8 mask, mode; +int ret; + +/* Configure all pins as GPIO. */ + mode =0 ; + ret =xr_set_reg_uart (port,XR21V141X_REG_GPIO_MODE , mode); +if (ret) +return ret; + +/* +* Configure DTR and RTS as outputs and make sure they are deasserted +* (active low), and configure RI, CD, DSR and CTS as inputs. +*/ + mask =XR21V141X_GPIO_DTR |XR21V141X_GPIO_RTS ; + ret =xr_set_reg_uart (port,XR21V141X_REG_GPIO_DIR , mask); +if (ret) +return ret; + + ret =xr_set_reg_uart (port,XR21V141X_REG_GPIO_SET , mask); +if (ret) +return ret; + +return 0 ; +} +static int xr_port_probe (struct usb_serial_port *port) {struct usb_interface_descriptor *desc;struct xr_data *data; +int ret; data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data)
@@ -610,7 +630,16 @@ static int xr_port_probe(struct usb_serial_port *port)usb_set_serial_port_data (port, data); + ret =xr_gpio_init (port); +if (ret) + goto err_free; +return 0 ; + +err_free: +kfree (data); + +return ret; }static void xr_port_remove (struct usb_serial_port *port)
Signature · 1 line
2.26.3
Johan Hovold
maintainerPATCH 5/12 USB: serial: xr: drop type prefix from shared defines
In reply to Johan HovoldIn preparation for adding support for further types, drop the type prefix from defines that are not specific to XR21V141X.
--- drivers/usb/serial/xr_serial.c | 122 ++++++++++++++++----------------- 1 file changed, 61 insertions(+), 61 deletions(-)
drivers/usb/serial/xr_serial.c +61 -61
@@ -54,45 +54,45 @@ struct xr_txrx_clk_mask {#define XR21V141X_UM_RX_FIFO_RESET 0x18#define XR21V141X_UM_TX_FIFO_RESET 0x1c -#define XR21V141X_UART_ENABLE_TX 0x1 -#define XR21V141X_UART_ENABLE_RX 0x2 +#define XR_UART_ENABLE_TX 0x1 +#define XR_UART_ENABLE_RX 0x2 -#define XR21V141X_GPIO_RI BIT(0) -#define XR21V141X_GPIO_CD BIT(1) -#define XR21V141X_GPIO_DSR BIT(2) -#define XR21V141X_GPIO_DTR BIT(3) -#define XR21V141X_GPIO_CTS BIT(4) -#define XR21V141X_GPIO_RTS BIT(5) +#define XR_GPIO_RI BIT(0) +#define XR_GPIO_CD BIT(1) +#define XR_GPIO_DSR BIT(2) +#define XR_GPIO_DTR BIT(3) +#define XR_GPIO_CTS BIT(4) +#define XR_GPIO_RTS BIT(5)#define XR21V141X_UART_BREAK_ON 0xff#define XR21V141X_UART_BREAK_OFF 0 -#define XR21V141X_UART_DATA_MASK GENMASK(3, 0) -#define XR21V141X_UART_DATA_7 0x7 -#define XR21V141X_UART_DATA_8 0x8 - -#define XR21V141X_UART_PARITY_MASK GENMASK(6, 4) -#define XR21V141X_UART_PARITY_SHIFT 4 -#define XR21V141X_UART_PARITY_NONE (0x0 << XR21V141X_UART_PARITY_SHIFT) -#define XR21V141X_UART_PARITY_ODD (0x1 << XR21V141X_UART_PARITY_SHIFT) -#define XR21V141X_UART_PARITY_EVEN (0x2 << XR21V141X_UART_PARITY_SHIFT) -#define XR21V141X_UART_PARITY_MARK (0x3 << XR21V141X_UART_PARITY_SHIFT) -#define XR21V141X_UART_PARITY_SPACE (0x4 << XR21V141X_UART_PARITY_SHIFT) - -#define XR21V141X_UART_STOP_MASK BIT(7) -#define XR21V141X_UART_STOP_SHIFT 7 -#define XR21V141X_UART_STOP_1 (0x0 << XR21V141X_UART_STOP_SHIFT) -#define XR21V141X_UART_STOP_2 (0x1 << XR21V141X_UART_STOP_SHIFT) - -#define XR21V141X_UART_FLOW_MODE_NONE 0x0 -#define XR21V141X_UART_FLOW_MODE_HW 0x1 -#define XR21V141X_UART_FLOW_MODE_SW 0x2 - -#define XR21V141X_GPIO_MODE_MASK GENMASK(2, 0) -#define XR21V141X_GPIO_MODE_RTS_CTS 0x1 -#define XR21V141X_GPIO_MODE_DTR_DSR 0x2 -#define XR21V141X_GPIO_MODE_RS485 0x3 -#define XR21V141X_GPIO_MODE_RS485_ADDR 0x4 +#define XR_UART_DATA_MASK GENMASK(3, 0) +#define XR_UART_DATA_7 0x7 +#define XR_UART_DATA_8 0x8 + +#define XR_UART_PARITY_MASK GENMASK(6, 4) +#define XR_UART_PARITY_SHIFT 4 +#define XR_UART_PARITY_NONE (0x0 << XR_UART_PARITY_SHIFT) +#define XR_UART_PARITY_ODD (0x1 << XR_UART_PARITY_SHIFT) +#define XR_UART_PARITY_EVEN (0x2 << XR_UART_PARITY_SHIFT) +#define XR_UART_PARITY_MARK (0x3 << XR_UART_PARITY_SHIFT) +#define XR_UART_PARITY_SPACE (0x4 << XR_UART_PARITY_SHIFT) + +#define XR_UART_STOP_MASK BIT(7) +#define XR_UART_STOP_SHIFT 7 +#define XR_UART_STOP_1 (0x0 << XR_UART_STOP_SHIFT) +#define XR_UART_STOP_2 (0x1 << XR_UART_STOP_SHIFT) + +#define XR_UART_FLOW_MODE_NONE 0x0 +#define XR_UART_FLOW_MODE_HW 0x1 +#define XR_UART_FLOW_MODE_SW 0x2 + +#define XR_GPIO_MODE_MASK GENMASK(2, 0) +#define XR_GPIO_MODE_RTS_CTS 0x1 +#define XR_GPIO_MODE_DTR_DSR 0x2 +#define XR_GPIO_MODE_RS485 0x3 +#define XR_GPIO_MODE_RS485_ADDR 0x4#define XR21V141X_REG_ENABLE 0x03#define XR21V141X_REG_FORMAT 0x0b
@@ -210,7 +210,7 @@ static int xr_uart_enable(struct usb_serial_port *port)return ret; ret =xr_set_reg_uart (port,XR21V141X_REG_ENABLE , -XR21V141X_UART_ENABLE_TX |XR21V141X_UART_ENABLE_RX ); +XR_UART_ENABLE_TX |XR_UART_ENABLE_RX );if (ret)return ret;
@@ -250,12 +250,12 @@ static int xr_tiocmget(struct tty_struct *tty)* Modem control pins are active low, so reading '0' means it is active * and '1' means not active. */ - ret = ((status &XR21V141X_GPIO_DTR ) ?0 :TIOCM_DTR ) | - ((status &XR21V141X_GPIO_RTS ) ?0 :TIOCM_RTS ) | - ((status &XR21V141X_GPIO_CTS ) ?0 :TIOCM_CTS ) | - ((status &XR21V141X_GPIO_DSR ) ?0 :TIOCM_DSR ) | - ((status &XR21V141X_GPIO_RI ) ?0 :TIOCM_RI ) | - ((status &XR21V141X_GPIO_CD ) ?0 :TIOCM_CD ); + ret = ((status &XR_GPIO_DTR ) ?0 :TIOCM_DTR ) | + ((status &XR_GPIO_RTS ) ?0 :TIOCM_RTS ) | + ((status &XR_GPIO_CTS ) ?0 :TIOCM_CTS ) | + ((status &XR_GPIO_DSR ) ?0 :TIOCM_DSR ) | + ((status &XR_GPIO_RI ) ?0 :TIOCM_RI ) | + ((status &XR_GPIO_CD ) ?0 :TIOCM_CD );return ret; }
@@ -269,13 +269,13 @@ static int xr_tiocmset_port(struct usb_serial_port *port,/* Modem control pins are active low, so set & clr are swapped */ if (set &TIOCM_RTS ) - gpio_clr |=XR21V141X_GPIO_RTS ; + gpio_clr |=XR_GPIO_RTS ;if (set &TIOCM_DTR ) - gpio_clr |=XR21V141X_GPIO_DTR ; + gpio_clr |=XR_GPIO_DTR ;if (clear &TIOCM_RTS ) - gpio_set |=XR21V141X_GPIO_RTS ; + gpio_set |=XR_GPIO_RTS ;if (clear &TIOCM_DTR ) - gpio_set |=XR21V141X_GPIO_DTR ; + gpio_set |=XR_GPIO_DTR ;/* Writing '0' to gpio_{set/clr} bits has no effect, so no need to do */ if (gpio_clr)
@@ -433,24 +433,24 @@ static void xr_set_flow_mode(struct tty_struct *tty,return ;/* Set GPIO mode for controlling the pins manually by default. */ - gpio_mode &= ~XR21V141X_GPIO_MODE_MASK ; + gpio_mode &= ~XR_GPIO_MODE_MASK ;if (C_CRTSCTS (tty) &&C_BAUD (tty) !=B0 ) {dev_dbg (&port->dev,"Enabling hardware flow ctrl\n" ); - gpio_mode |=XR21V141X_GPIO_MODE_RTS_CTS ; - flow =XR21V141X_UART_FLOW_MODE_HW ; + gpio_mode |=XR_GPIO_MODE_RTS_CTS ; + flow =XR_UART_FLOW_MODE_HW ; }else if (I_IXON (tty)) {u8 start_char =START_CHAR (tty);u8 stop_char =STOP_CHAR (tty);dev_dbg (&port->dev,"Enabling sw flow ctrl\n" ); - flow =XR21V141X_UART_FLOW_MODE_SW ; + flow =XR_UART_FLOW_MODE_SW ;xr_set_reg_uart (port,XR21V141X_REG_XON_CHAR , start_char);xr_set_reg_uart (port,XR21V141X_REG_XOFF_CHAR , stop_char); }else {dev_dbg (&port->dev,"Disabling flow ctrl\n" ); - flow =XR21V141X_UART_FLOW_MODE_NONE ; + flow =XR_UART_FLOW_MODE_NONE ; }/*
@@ -491,37 +491,37 @@ static void xr_set_termios(struct tty_struct *tty, termios->c_cflag |=CS8 ;if (C_CSIZE (tty) ==CS7 ) - bits |=XR21V141X_UART_DATA_7 ; + bits |=XR_UART_DATA_7 ;else - bits |=XR21V141X_UART_DATA_8 ; + bits |=XR_UART_DATA_8 ;break ;case CS7 : - bits |=XR21V141X_UART_DATA_7 ; + bits |=XR_UART_DATA_7 ;break ;case CS8 :default : - bits |=XR21V141X_UART_DATA_8 ; + bits |=XR_UART_DATA_8 ;break ; }if (C_PARENB (tty)) {if (C_CMSPAR (tty)) {if (C_PARODD (tty)) - bits |=XR21V141X_UART_PARITY_MARK ; + bits |=XR_UART_PARITY_MARK ;else - bits |=XR21V141X_UART_PARITY_SPACE ; + bits |=XR_UART_PARITY_SPACE ; }else {if (C_PARODD (tty)) - bits |=XR21V141X_UART_PARITY_ODD ; + bits |=XR_UART_PARITY_ODD ;else - bits |=XR21V141X_UART_PARITY_EVEN ; + bits |=XR_UART_PARITY_EVEN ; } }if (C_CSTOPB (tty)) - bits |=XR21V141X_UART_STOP_2 ; + bits |=XR_UART_STOP_2 ;else - bits |=XR21V141X_UART_STOP_1 ; + bits |=XR_UART_STOP_1 ; ret =xr_set_reg_uart (port,XR21V141X_REG_FORMAT , bits);if (ret)
@@ -603,7 +603,7 @@ static int xr_gpio_init(struct usb_serial_port *port)* Configure DTR and RTS as outputs and make sure they are deasserted * (active low), and configure RI, CD, DSR and CTS as inputs. */ - mask =XR21V141X_GPIO_DTR |XR21V141X_GPIO_RTS ; + mask =XR_GPIO_DTR |XR_GPIO_RTS ; ret =xr_set_reg_uart (port,XR21V141X_REG_GPIO_DIR , mask);if (ret)return ret;
Signature · 1 line
2.26.3
Johan Hovold
maintainerPATCH 6/12 USB: serial: xr: add type abstraction
In reply to Johan HovoldThere are at least four types of Maxlinear/Exar USB UARTs which differ in various ways such as in their register layouts:
XR21V141X XR21B142X XR21B1411 XR22804
It is not clear whether the device type can be inferred from the descriptors so encode it in the device-id table for now.
Add a type structure that can be used to abstract the register layout and other features, and use it when accessing the XR21V141X UART registers that are shared by all types.
Note that the currently supported XR21V141X type is the only type that has a set of UART Manager registers and that these will need to be handled specifically.
Similarly, XR21V141X is the only type which has the divisor registers and that needs to use the format register when configuring the line settings.
--- drivers/usb/serial/xr_serial.c | 128 ++++++++++++++++++++++----------- 1 file changed, 85 insertions(+), 43 deletions(-)
drivers/usb/serial/xr_serial.c +85 -43
@@ -29,10 +29,16 @@ struct xr_txrx_clk_mask {#define XR21V141X_MIN_SPEED 46U#define XR21V141X_MAX_SPEED XR_INT_OSC_HZ -/* USB Requests */ +/* USB requests */ #define XR21V141X_SET_REQ 0#define XR21V141X_GET_REQ 1 +/* XR21V141X register blocks */ +#define XR21V141X_UART_REG_BLOCK 0 +#define XR21V141X_UM_REG_BLOCK 4 +#define XR21V141X_UART_CUSTOM_BLOCK 0x66 + +/* XR21V141X UART registers */ #define XR21V141X_CLOCK_DIVISOR_0 0x04#define XR21V141X_CLOCK_DIVISOR_1 0x05#define XR21V141X_CLOCK_DIVISOR_2 0x06
@@ -40,13 +46,9 @@ struct xr_txrx_clk_mask {#define XR21V141X_TX_CLOCK_MASK_1 0x08#define XR21V141X_RX_CLOCK_MASK_0 0x09#define XR21V141X_RX_CLOCK_MASK_1 0x0a +#define XR21V141X_REG_FORMAT 0x0b -/* XR21V141X register blocks */ -#define XR21V141X_UART_REG_BLOCK 0 -#define XR21V141X_UM_REG_BLOCK 4 -#define XR21V141X_UART_CUSTOM_BLOCK 0x66 - -/* XR21V141X UART Manager Registers */ +/* XR21V141X UART Manager registers */ #define XR21V141X_UM_FIFO_ENABLE_REG 0x10#define XR21V141X_UM_ENABLE_TX_FIFO 0x01#define XR21V141X_UM_ENABLE_RX_FIFO 0x02
@@ -94,23 +96,42 @@ struct xr_txrx_clk_mask {#define XR_GPIO_MODE_RS485 0x3#define XR_GPIO_MODE_RS485_ADDR 0x4 -#define XR21V141X_REG_ENABLE 0x03 -#define XR21V141X_REG_FORMAT 0x0b -#define XR21V141X_REG_FLOW_CTRL 0x0c -#define XR21V141X_REG_XON_CHAR 0x10 -#define XR21V141X_REG_XOFF_CHAR 0x11 -#define XR21V141X_REG_LOOPBACK 0x12 -#define XR21V141X_REG_TX_BREAK 0x14 -#define XR21V141X_REG_RS845_DELAY 0x15 -#define XR21V141X_REG_GPIO_MODE 0x1a -#define XR21V141X_REG_GPIO_DIR 0x1b -#define XR21V141X_REG_GPIO_INT_MASK 0x1c -#define XR21V141X_REG_GPIO_SET 0x1d -#define XR21V141X_REG_GPIO_CLR 0x1e -#define XR21V141X_REG_GPIO_STATUS 0x1f +struct xr_type { +u8 uart_enable; +u8 flow_control; +u8 xon_char; +u8 xoff_char; +u8 tx_break; +u8 gpio_mode; +u8 gpio_direction; +u8 gpio_set; +u8 gpio_clear; +u8 gpio_status; +}; + +enum xr_type_id { +XR21V141X , +XR_TYPE_COUNT , +}; + +static const struct xr_type xr_types[] = { + [XR21V141X ] = { + .uart_enable =0x03 , + .flow_control =0x0c , + .xon_char =0x10 , + .xoff_char =0x11 , + .tx_break =0x14 , + .gpio_mode =0x1a , + .gpio_direction =0x1b , + .gpio_set =0x1d , + .gpio_clear =0x1e , + .gpio_status =0x1f , + }, +};struct xr_data { -u8 channel;/* zero-based index */ +const struct xr_type *type; +u8 channel;/* zero-based index */ };static int xr_set_reg (struct usb_serial_port *port,u8 block,u8 reg,u8 val)
@@ -202,6 +223,7 @@ static int xr_set_reg_um(struct usb_serial_port *port, u8 reg_base, u8 val)*/ static int xr_uart_enable (struct usb_serial_port *port) { +struct xr_data *data =usb_get_serial_port_data (port);int ret; ret = xr_set_reg_um(port, XR21V141X_UM_FIFO_ENABLE_REG,
@@ -209,25 +231,25 @@ static int xr_uart_enable(struct usb_serial_port *port)if (ret)return ret; - ret =xr_set_reg_uart (port,XR21V141X_REG_ENABLE , + ret =xr_set_reg_uart (port, data->type->uart_enable,XR_UART_ENABLE_TX |XR_UART_ENABLE_RX );if (ret)return ret; ret =xr_set_reg_um (port,XR21V141X_UM_FIFO_ENABLE_REG ,XR21V141X_UM_ENABLE_TX_FIFO |XR21V141X_UM_ENABLE_RX_FIFO ); -if (ret) -xr_set_reg_uart (port,XR21V141X_REG_ENABLE ,0 ); +xr_set_reg_uart (port, data->type->uart_enable,0 );return ret; }static int xr_uart_disable (struct usb_serial_port *port) { +struct xr_data *data =usb_get_serial_port_data (port);int ret; - ret =xr_set_reg_uart (port,XR21V141X_REG_ENABLE ,0 ); + ret =xr_set_reg_uart (port, data->type->uart_enable,0 );if (ret)return ret;
@@ -239,10 +261,11 @@ static int xr_uart_disable(struct usb_serial_port *port)static int xr_tiocmget (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data; +struct xr_data *data =usb_get_serial_port_data (port);u8 status;int ret; - ret =xr_get_reg_uart (port,XR21V141X_REG_GPIO_STATUS , &status); + ret =xr_get_reg_uart (port, data->type->gpio_status, &status);if (ret)return ret;
@@ -263,6 +286,8 @@ static int xr_tiocmget(struct tty_struct *tty)static int xr_tiocmset_port (struct usb_serial_port *port,unsigned int set,unsigned int clear) { +struct xr_data *data =usb_get_serial_port_data (port); +const struct xr_type *type = data->type;u8 gpio_set =0 ;u8 gpio_clr =0 ;int ret =0 ;
@@ -279,10 +304,10 @@ static int xr_tiocmset_port(struct usb_serial_port *port,/* Writing '0' to gpio_{set/clr} bits has no effect, so no need to do */ if (gpio_clr) - ret =xr_set_reg_uart (port,XR21V141X_REG_GPIO_CLR , gpio_clr); + ret =xr_set_reg_uart (port, type->gpio_clear, gpio_clr);if (gpio_set) - ret =xr_set_reg_uart (port,XR21V141X_REG_GPIO_SET , gpio_set); + ret =xr_set_reg_uart (port, type->gpio_set, gpio_set);return ret; }
@@ -306,6 +331,8 @@ static void xr_dtr_rts(struct usb_serial_port *port, int on)static void xr_break_ctl (struct tty_struct *tty,int break_state) {struct usb_serial_port *port = tty->driver_data; +struct xr_data *data =usb_get_serial_port_data (port); +const struct xr_type *type = data->type;u8 state;if (break_state ==0 )
@@ -315,7 +342,7 @@ static void xr_break_ctl(struct tty_struct *tty, int break_state)dev_dbg (&port->dev,"Turning break %s\n" , state ==XR21V141X_UART_BREAK_OFF ?"off" :"on" ); -xr_set_reg_uart (port,XR21V141X_REG_TX_BREAK , state); +xr_set_reg_uart (port, type->tx_break, state); }/* Tx and Rx clock mask values obtained from section 3.3.4 of datasheet */
@@ -425,10 +452,12 @@ static void xr_set_flow_mode(struct tty_struct *tty,struct usb_serial_port *port, struct ktermios *old_termios) { + struct xr_data *data = usb_get_serial_port_data(port); +const struct xr_type *type = data->type;u8 flow, gpio_mode;int ret; - ret =xr_get_reg_uart (port,XR21V141X_REG_GPIO_MODE , &gpio_mode); + ret =xr_get_reg_uart (port, type->gpio_mode, &gpio_mode);if (ret)return ;
@@ -446,8 +475,8 @@ static void xr_set_flow_mode(struct tty_struct *tty,dev_dbg (&port->dev,"Enabling sw flow ctrl\n" ); flow =XR_UART_FLOW_MODE_SW ; -xr_set_reg_uart (port,XR21V141X_REG_XON_CHAR , start_char); -xr_set_reg_uart (port,XR21V141X_REG_XOFF_CHAR , stop_char); +xr_set_reg_uart (port, type->xon_char, start_char); +xr_set_reg_uart (port, type->xoff_char, stop_char); }else {dev_dbg (&port->dev,"Disabling flow ctrl\n" ); flow =XR_UART_FLOW_MODE_NONE ;
@@ -458,10 +487,10 @@ static void xr_set_flow_mode(struct tty_struct *tty,* FLOW_CONTROL register. */ xr_uart_disable (port); -xr_set_reg_uart (port,XR21V141X_REG_FLOW_CTRL , flow); +xr_set_reg_uart (port, type->flow_control, flow);xr_uart_enable (port); -xr_set_reg_uart (port,XR21V141X_REG_GPIO_MODE , gpio_mode); +xr_set_reg_uart (port, type->gpio_mode, gpio_mode);if (C_BAUD (tty) ==B0 )xr_dtr_rts (port,0 );
@@ -585,17 +614,19 @@ static int xr_probe(struct usb_serial *serial, const struct usb_device_id *id)if (ret)return ret; +usb_set_serial_data (serial, (void *)id->driver_info); +return 0 ; } -static int xr_gpio_init (struct usb_serial_port *port) +static int xr_gpio_init (struct usb_serial_port *port,const struct xr_type *type) {u8 mask, mode;int ret;/* Configure all pins as GPIO. */ mode =0 ; - ret =xr_set_reg_uart (port,XR21V141X_REG_GPIO_MODE , mode); + ret =xr_set_reg_uart (port, type->gpio_mode, mode);if (ret)return ret;
@@ -604,11 +635,11 @@ static int xr_gpio_init(struct usb_serial_port *port)* (active low), and configure RI, CD, DSR and CTS as inputs. */ mask =XR_GPIO_DTR |XR_GPIO_RTS ; - ret =xr_set_reg_uart (port,XR21V141X_REG_GPIO_DIR , mask); + ret =xr_set_reg_uart (port, type->gpio_direction, mask);if (ret)return ret; - ret =xr_set_reg_uart (port,XR21V141X_REG_GPIO_SET , mask); + ret =xr_set_reg_uart (port, type->gpio_set, mask);if (ret)return ret;
@@ -618,19 +649,26 @@ static int xr_gpio_init(struct usb_serial_port *port)static int xr_port_probe (struct usb_serial_port *port) {struct usb_interface_descriptor *desc; +const struct xr_type *type;struct xr_data *data; +enum xr_type_id type_id;int ret; + type_id = (int )(unsigned long )usb_get_serial_data (port->serial); + type = &xr_types[type_id]; + data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data)return -ENOMEM ; + data->type = type; + desc = &port->serial->interface->cur_altsetting->desc; data->channel = desc->bInterfaceNumber /2 ;usb_set_serial_port_data (port, data); - ret =xr_gpio_init (port); + ret =xr_gpio_init (port, type);if (ret) goto err_free;
@@ -649,10 +687,14 @@ static void xr_port_remove(struct usb_serial_port *port)kfree (data); } +#define XR_DEVICE (vid, pid, type) \ + USB_DEVICE_INTERFACE_CLASS((vid), (pid), USB_CLASS_COMM), \ + .driver_info = (type) +static const struct usb_device_id id_table[] = { - {USB_DEVICE_INTERFACE_CLASS (0x04e2 ,0x1410 ,USB_CLASS_COMM ) },/* XR21V1410 */ - {USB_DEVICE_INTERFACE_CLASS (0x04e2 ,0x1412 ,USB_CLASS_COMM ) },/* XR21V1412 */ - {USB_DEVICE_INTERFACE_CLASS (0x04e2 ,0x1414 ,USB_CLASS_COMM ) },/* XR21V1414 */ + {XR_DEVICE (0x04e2 ,0x1410 ,XR21V141X ) }, + {XR_DEVICE (0x04e2 ,0x1412 ,XR21V141X ) }, + {XR_DEVICE (0x04e2 ,0x1414 ,XR21V141X ) }, { } };MODULE_DEVICE_TABLE (usb, id_table);
Signature · 1 line
2.26.3
Johan Hovold
maintainerPATCH 7/12 USB: serial: xr: add support for XR21B1421, XR21B1422 and XR21B1424
In reply to Johan HovoldThe XR21B1421, XR21B1422 and XR21B1424 are the one-, two- and four-port models of a second XR21B142X type of the Maxlinear/Exar USB UARTs.
The XR21B142X type differs from XR21V141X in several ways, including:
- register layout
- register width (16-bit instead of 8-bit)
- vendor register requests
- UART enable/disable sequence
- custom-driver mode flag
- three additional GPIOs (9 instead of 6)
As for XR21V141X, the XR21B142X vendor requests encode the channel index in the MSB of wIndex, but it lacks the UART Manager registers which have been replaced by regular UART registers. The new type also uses the interface number of the control interface (0, 2, 4, 6) as channel index instead of the channel number (0, 1, 2, 3).
The XR21B142X lacks the divisor and format registers used by XR21V141X and instead uses the CDC SET_LINE_CONTROL request to configure the line settings.
Note that the currently supported XR21V141X type lacks the custom-driver mode flag that prevents the device from entering CDC-ACM mode when a CDC requests is received. This specifically means that the SET_LINE_CONTROL request cannot be used with XR21V141X even though it is otherwise supported.
The UART enable sequence for XR21B142X does not involve explicitly enabling the FIFOs, but according to datasheet the UART must be disabled when writing any register but GPIO_SET, GPIO_CLEAR, TX_BREAK and ERROR_STATUS.
--- drivers/usb/serial/xr_serial.c | 338 +++++++++++++++++++++++++-------- 1 file changed, 262 insertions(+), 76 deletions(-)
drivers/usb/serial/xr_serial.c +262 -76
@@ -29,10 +29,6 @@ struct xr_txrx_clk_mask {#define XR21V141X_MIN_SPEED 46U#define XR21V141X_MAX_SPEED XR_INT_OSC_HZ -/* USB requests */ -#define XR21V141X_SET_REQ 0 -#define XR21V141X_GET_REQ 1 -/* XR21V141X register blocks */ #define XR21V141X_UART_REG_BLOCK 0#define XR21V141X_UM_REG_BLOCK 4
@@ -65,9 +61,10 @@ struct xr_txrx_clk_mask {#define XR_GPIO_DTR BIT(3)#define XR_GPIO_CTS BIT(4)#define XR_GPIO_RTS BIT(5) - -#define XR21V141X_UART_BREAK_ON 0xff -#define XR21V141X_UART_BREAK_OFF 0 +#define XR_GPIO_CLK BIT(6) +#define XR_GPIO_XEN BIT(7) +#define XR_GPIO_TXT BIT(8) +#define XR_GPIO_RXT BIT(9)#define XR_UART_DATA_MASK GENMASK(3, 0)#define XR_UART_DATA_7 0x7
@@ -90,13 +87,27 @@ struct xr_txrx_clk_mask {#define XR_UART_FLOW_MODE_HW 0x1#define XR_UART_FLOW_MODE_SW 0x2 -#define XR_GPIO_MODE_MASK GENMASK(2, 0) -#define XR_GPIO_MODE_RTS_CTS 0x1 -#define XR_GPIO_MODE_DTR_DSR 0x2 -#define XR_GPIO_MODE_RS485 0x3 -#define XR_GPIO_MODE_RS485_ADDR 0x4 +#define XR_GPIO_MODE_SEL_MASK GENMASK(2, 0) +#define XR_GPIO_MODE_SEL_RTS_CTS 0x1 +#define XR_GPIO_MODE_SEL_DTR_DSR 0x2 +#define XR_GPIO_MODE_SEL_RS485 0x3 +#define XR_GPIO_MODE_SEL_RS485_ADDR 0x4 +#define XR_GPIO_MODE_TX_TOGGLE 0x100 +#define XR_GPIO_MODE_RX_TOGGLE 0x200 + +#define XR_CUSTOM_DRIVER_ACTIVE 0x1 + +static int xr21v141x_uart_enable (struct usb_serial_port *port); +static int xr21v141x_uart_disable (struct usb_serial_port *port); +static void xr21v141x_set_line_settings (struct tty_struct *tty, +struct usb_serial_port *port,struct ktermios *old_termios);struct xr_type { +int reg_width; +u8 reg_recipient; +u8 set_reg; +u8 get_reg; +u8 uart_enable;u8 flow_control;u8 xon_char;
@@ -107,15 +118,30 @@ struct xr_type {u8 gpio_set;u8 gpio_clear;u8 gpio_status; +u8 custom_driver; + +bool have_xmit_toggle; + +int (*enable)(struct usb_serial_port *port); +int (*disable)(struct usb_serial_port *port); +void (*set_line_settings)(struct tty_struct *tty, +struct usb_serial_port *port, +struct ktermios *old_termios); };enum xr_type_id {XR21V141X , +XR21B142X ,XR_TYPE_COUNT , };static const struct xr_type xr_types[] = { [XR21V141X ] = { + .reg_width =8 , + .reg_recipient =USB_RECIP_DEVICE , + .set_reg =0x00 , + .get_reg =0x01 , + .uart_enable =0x03 , .flow_control =0x0c , .xon_char =0x10 ,
@@ -126,25 +152,50 @@ static const struct xr_type xr_types[] = { .gpio_set = 0x1d, .gpio_clear = 0x1e, .gpio_status = 0x1f, + + .enable = xr21v141x_uart_enable, + .disable = xr21v141x_uart_disable, + .set_line_settings = xr21v141x_set_line_settings, + }, + [XR21B142X] = { + .reg_width = 16, + .reg_recipient = USB_RECIP_INTERFACE, + .set_reg = 0x00, + .get_reg = 0x00, + + .uart_enable = 0x00, + .flow_control = 0x06, + .xon_char = 0x07, + .xoff_char = 0x08, + .tx_break = 0x0a, + .gpio_mode = 0x0c, + .gpio_direction = 0x0d, + .gpio_set = 0x0e, + .gpio_clear = 0x0f, + .gpio_status = 0x10, + .custom_driver = 0x60, + + .have_xmit_toggle = true, }, };struct xr_data {const struct xr_type *type; -u8 channel;/* zero-based index */ +u8 channel;/* zero-based index or interface number */ }; -static int xr_set_reg (struct usb_serial_port *port,u8 block,u8 reg,u8 val) +static int xr_set_reg (struct usb_serial_port *port,u8 channel,u8 reg,u16 val) { +struct xr_data *data =usb_get_serial_port_data (port); +const struct xr_type *type = data->type;struct usb_serial *serial = port->serial;int ret; - ret =usb_control_msg (serial->dev, -usb_sndctrlpipe (serial->dev,0 ), -XR21V141X_SET_REQ , -USB_DIR_OUT |USB_TYPE_VENDOR |USB_RECIP_DEVICE , - val, reg | (block <<8 ),NULL ,0 , -USB_CTRL_SET_TIMEOUT ); + ret =usb_control_msg (serial->dev,usb_sndctrlpipe (serial->dev,0 ), + type->set_reg, +USB_DIR_OUT |USB_TYPE_VENDOR | type->reg_recipient, + val, (channel <<8 ) | reg,NULL ,0 , +USB_CTRL_SET_TIMEOUT );if (ret <0 ) {dev_err (&port->dev,"Failed to set reg 0x%02x: %d\n" , reg, ret);return ret;
@@ -153,24 +204,33 @@ static int xr_set_reg(struct usb_serial_port *port, u8 block, u8 reg, u8 val)return 0 ; } -static int xr_get_reg (struct usb_serial_port *port,u8 block,u8 reg,u8 *val) +static int xr_get_reg (struct usb_serial_port *port,u8 channel,u8 reg,u16 *val) { +struct xr_data *data =usb_get_serial_port_data (port); +const struct xr_type *type = data->type;struct usb_serial *serial = port->serial;u8 *dmabuf; -int ret; +int ret, len; - dmabuf =kmalloc (1 ,GFP_KERNEL ); +if (type->reg_width ==8 ) + len =1 ; +else + len =2 ; + + dmabuf =kmalloc (len,GFP_KERNEL );if (!dmabuf)return -ENOMEM ; - ret =usb_control_msg (serial->dev, -usb_rcvctrlpipe (serial->dev,0 ), -XR21V141X_GET_REQ , -USB_DIR_IN |USB_TYPE_VENDOR |USB_RECIP_DEVICE , -0 , reg | (block <<8 ), dmabuf,1 , -USB_CTRL_GET_TIMEOUT ); -if (ret ==1 ) { - *val = *dmabuf; + ret =usb_control_msg (serial->dev,usb_rcvctrlpipe (serial->dev,0 ), + type->get_reg, +USB_DIR_IN |USB_TYPE_VENDOR | type->reg_recipient, +0 , (channel <<8 ) | reg, dmabuf, len, +USB_CTRL_GET_TIMEOUT ); +if (ret == len) { +if (len ==2 ) + *val =le16_to_cpup ((__le16 *)dmabuf); +else + *val = *dmabuf; ret =0 ; }else {dev_err (&port->dev,"Failed to get reg 0x%02x: %d\n" , reg, ret);
@@ -183,24 +243,18 @@ static int xr_get_reg(struct usb_serial_port *port, u8 block, u8 reg, u8 *val)return ret; } -static int xr_set_reg_uart (struct usb_serial_port *port,u8 reg,u8 val) +static int xr_set_reg_uart (struct usb_serial_port *port,u8 reg,u16 val) {struct xr_data *data =usb_get_serial_port_data (port); -u8 block; - - block =XR21V141X_UART_REG_BLOCK + data->channel; -return xr_set_reg (port, block, reg, val); +return xr_set_reg (port, data->channel, reg, val); } -static int xr_get_reg_uart (struct usb_serial_port *port,u8 reg,u8 *val) +static int xr_get_reg_uart (struct usb_serial_port *port,u8 reg,u16 *val) {struct xr_data *data =usb_get_serial_port_data (port); -u8 block; - block =XR21V141X_UART_REG_BLOCK + data->channel; - -return xr_get_reg (port, block, reg, val); +return xr_get_reg (port, data->channel, reg, val); }static int xr_set_reg_um (struct usb_serial_port *port,u8 reg_base,u8 val)
@@ -213,6 +267,21 @@ static int xr_set_reg_um(struct usb_serial_port *port, u8 reg_base, u8 val)return xr_set_reg (port,XR21V141X_UM_REG_BLOCK , reg, val); } +static int __xr_uart_enable (struct usb_serial_port *port) +{ +struct xr_data *data =usb_get_serial_port_data (port); + +return xr_set_reg_uart (port, data->type->uart_enable, +XR_UART_ENABLE_TX |XR_UART_ENABLE_RX ); +} + +static int __xr_uart_disable (struct usb_serial_port *port) +{ +struct xr_data *data =usb_get_serial_port_data (port); + +return xr_set_reg_uart (port, data->type->uart_enable,0 ); +} +/* * According to datasheet, below is the recommended sequence for enabling UART * module in XR21V141X:
@@ -221,9 +290,8 @@ static int xr_set_reg_um(struct usb_serial_port *port, u8 reg_base, u8 val)* Enable Tx and Rx * Enable Rx FIFO */ -static int xr_uart_enable (struct usb_serial_port *port) +static int xr21v141x_uart_enable (struct usb_serial_port *port) { -struct xr_data *data =usb_get_serial_port_data (port);int ret; ret = xr_set_reg_um(port, XR21V141X_UM_FIFO_ENABLE_REG,
@@ -231,25 +299,23 @@ static int xr_uart_enable(struct usb_serial_port *port)if (ret)return ret; - ret =xr_set_reg_uart (port, data->type->uart_enable, -XR_UART_ENABLE_TX |XR_UART_ENABLE_RX ); + ret =__xr_uart_enable (port);if (ret)return ret; ret =xr_set_reg_um (port,XR21V141X_UM_FIFO_ENABLE_REG ,XR21V141X_UM_ENABLE_TX_FIFO |XR21V141X_UM_ENABLE_RX_FIFO );if (ret) -xr_set_reg_uart (port, data->type->uart_enable,0 ); +__xr_uart_disable (port);return ret; } -static int xr_uart_disable (struct usb_serial_port *port) +static int xr21v141x_uart_disable (struct usb_serial_port *port) { -struct xr_data *data =usb_get_serial_port_data (port);int ret; - ret =xr_set_reg_uart (port, data->type->uart_enable,0 ); + ret =__xr_uart_disable (port);if (ret)return ret;
@@ -258,11 +324,31 @@ static int xr_uart_disable(struct usb_serial_port *port)return ret; } +static int xr_uart_enable (struct usb_serial_port *port) +{ +struct xr_data *data =usb_get_serial_port_data (port); + +if (data->type->enable) +return data->type->enable (port); + +return __xr_uart_enable (port); +} + +static int xr_uart_disable (struct usb_serial_port *port) +{ +struct xr_data *data =usb_get_serial_port_data (port); + +if (data->type->disable) +return data->type->disable (port); + +return __xr_uart_disable (port); +} +static int xr_tiocmget (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;struct xr_data *data =usb_get_serial_port_data (port); -u8 status; +u16 status;int ret; ret =xr_get_reg_uart (port, data->type->gpio_status, &status);
@@ -288,8 +374,8 @@ static int xr_tiocmset_port(struct usb_serial_port *port, {struct xr_data *data =usb_get_serial_port_data (port);const struct xr_type *type = data->type; -u8 gpio_set =0 ; -u8 gpio_clr =0 ; +u16 gpio_set =0 ; +u16 gpio_clr =0 ;int ret =0 ;/* Modem control pins are active low, so set & clr are swapped */
@@ -333,15 +419,15 @@ static void xr_break_ctl(struct tty_struct *tty, int break_state)struct usb_serial_port *port = tty->driver_data;struct xr_data *data =usb_get_serial_port_data (port);const struct xr_type *type = data->type; -u8 state; +u16 state;if (break_state ==0 ) - state =XR21V141X_UART_BREAK_OFF ; + state =0 ;else - state =XR21V141X_UART_BREAK_ON ; + state =GENMASK (type->reg_width -1 ,0 ); + +dev_dbg (&port->dev,"Turning break %s\n" , state ==0 ?"off" :"on" ); -dev_dbg (&port->dev,"Turning break %s\n" , - state ==XR21V141X_UART_BREAK_OFF ?"off" :"on" );xr_set_reg_uart (port, type->tx_break, state); }
@@ -381,8 +467,7 @@ static const struct xr_txrx_clk_mask xr21v141x_txrx_clk_masks[] = { { 0xfff, 0xffe, 0xffd }, }; -static int xr_set_baudrate (struct tty_struct *tty, -struct usb_serial_port *port) +static int xr21v141x_set_baudrate (struct tty_struct *tty,struct usb_serial_port *port) {u32 divisor, baud, idx;u16 tx_mask, rx_mask;
@@ -454,19 +539,26 @@ static void xr_set_flow_mode(struct tty_struct *tty, {struct xr_data *data =usb_get_serial_port_data (port);const struct xr_type *type = data->type; -u8 flow, gpio_mode; +u16 flow, gpio_mode;int ret; ret =xr_get_reg_uart (port, type->gpio_mode, &gpio_mode);if (ret)return ; +/* +* According to the datasheets, the UART needs to be disabled while +* writing to the FLOW_CONTROL register (XR21V141X), or any register +* but GPIO_SET, GPIO_CLEAR, TX_BREAK and ERROR_STATUS (XR21B142X). +*/ +xr_uart_disable (port); +/* Set GPIO mode for controlling the pins manually by default. */ - gpio_mode &= ~XR_GPIO_MODE_MASK ; + gpio_mode &= ~XR_GPIO_MODE_SEL_MASK ;if (C_CRTSCTS (tty) &&C_BAUD (tty) !=B0 ) {dev_dbg (&port->dev,"Enabling hardware flow ctrl\n" ); - gpio_mode |=XR_GPIO_MODE_RTS_CTS ; + gpio_mode |=XR_GPIO_MODE_SEL_RTS_CTS ; flow =XR_UART_FLOW_MODE_HW ; }else if (I_IXON (tty)) {u8 start_char =START_CHAR (tty);
@@ -482,32 +574,26 @@ static void xr_set_flow_mode(struct tty_struct *tty, flow =XR_UART_FLOW_MODE_NONE ; } -/* -* As per the datasheet, UART needs to be disabled while writing to -* FLOW_CONTROL register. -*/ -xr_uart_disable (port);xr_set_reg_uart (port, type->flow_control, flow); -xr_uart_enable (port); -xr_set_reg_uart (port, type->gpio_mode, gpio_mode); +xr_uart_enable (port); +if (C_BAUD (tty) ==B0 )xr_dtr_rts (port,0 );else if (old_termios && (old_termios->c_cflag &CBAUD ) ==B0 )xr_dtr_rts (port,1 ); } -static void xr_set_termios (struct tty_struct *tty, -struct usb_serial_port *port, -struct ktermios *old_termios) +static void xr21v141x_set_line_settings (struct tty_struct *tty, +struct usb_serial_port *port,struct ktermios *old_termios) {struct ktermios *termios = &tty->termios;u8 bits =0 ;int ret;if (!old_termios || (tty->termios.c_ospeed != old_termios->c_ospeed)) -xr_set_baudrate (tty, port); +xr21v141x_set_baudrate (tty, port);switch (C_CSIZE (tty)) {case CS5 :
@@ -555,6 +641,88 @@ static void xr_set_termios(struct tty_struct *tty, ret =xr_set_reg_uart (port,XR21V141X_REG_FORMAT , bits);if (ret)return ; +} + +static void xr_cdc_set_line_coding (struct tty_struct *tty, +struct usb_serial_port *port,struct ktermios *old_termios) +{ +struct usb_host_interface *alt = port->serial->interface->cur_altsetting; +struct usb_device *udev = port->serial->dev; +struct usb_cdc_line_coding *lc; +int ret; + + lc =kzalloc (sizeof (*lc),GFP_KERNEL ); +if (!lc) +return ; + +if (tty->termios.c_ospeed) + lc->dwDTERate =cpu_to_le32 (tty->termios.c_ospeed); +else if (old_termios) + lc->dwDTERate =cpu_to_le32 (old_termios->c_ospeed); +else + lc->dwDTERate =cpu_to_le32 (9600 ); + +if (C_CSTOPB (tty)) + lc->bCharFormat =USB_CDC_2_STOP_BITS ; +else + lc->bCharFormat =USB_CDC_1_STOP_BITS ; + +if (C_PARENB (tty)) { +if (C_CMSPAR (tty)) { +if (C_PARODD (tty)) + lc->bParityType =USB_CDC_MARK_PARITY ; +else + lc->bParityType =USB_CDC_SPACE_PARITY ; + }else { +if (C_PARODD (tty)) + lc->bParityType =USB_CDC_ODD_PARITY ; +else + lc->bParityType =USB_CDC_EVEN_PARITY ; + } + }else { + lc->bParityType =USB_CDC_NO_PARITY ; + } + +switch (C_CSIZE (tty)) { +case CS5 : + lc->bDataBits =5 ; +break ; +case CS6 : + lc->bDataBits =6 ; +break ; +case CS7 : + lc->bDataBits =7 ; +break ; +case CS8 : +default : + lc->bDataBits =8 ; +break ; + } + + ret =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ), +USB_CDC_REQ_SET_LINE_CODING , +USB_TYPE_CLASS |USB_RECIP_INTERFACE , +0 , alt->desc.bInterfaceNumber, + lc,sizeof (*lc),USB_CTRL_SET_TIMEOUT ); +if (ret <0 ) +dev_err (&port->dev,"Failed to set line coding: %d\n" , ret); + +kfree (lc); +} + +static void xr_set_termios (struct tty_struct *tty, +struct usb_serial_port *port,struct ktermios *old_termios) +{ +struct xr_data *data =usb_get_serial_port_data (port); + +/* +* XR21V141X does not have a CUSTOM_DRIVER flag and always enters CDC +* mode upon receiving CDC requests. +*/ +if (data->type->set_line_settings) + data->type->set_line_settings (tty, port, old_termios); +else +xr_cdc_set_line_coding (tty, port, old_termios);xr_set_flow_mode (tty, port, old_termios); }
@@ -621,11 +789,16 @@ static int xr_probe(struct usb_serial *serial, const struct usb_device_id *id)static int xr_gpio_init (struct usb_serial_port *port,const struct xr_type *type) { -u8 mask, mode; +u16 mask, mode;int ret; -/* Configure all pins as GPIO. */ +/* +* Configure all pins as GPIO except for Receive and Transmit Toggle. +*/ mode =0 ; +if (type->have_xmit_toggle) + mode |=XR_GPIO_MODE_RX_TOGGLE |XR_GPIO_MODE_TX_TOGGLE ; + ret =xr_set_reg_uart (port, type->gpio_mode, mode);if (ret)return ret;
@@ -664,10 +837,20 @@ static int xr_port_probe(struct usb_serial_port *port) data->type = type; desc = &port->serial->interface->cur_altsetting->desc; - data->channel = desc->bInterfaceNumber /2 ; +if (type_id ==XR21V141X ) + data->channel = desc->bInterfaceNumber /2 ; +else + data->channel = desc->bInterfaceNumber;usb_set_serial_port_data (port, data); +if (type->custom_driver) { + ret =xr_set_reg_uart (port, type->custom_driver, +XR_CUSTOM_DRIVER_ACTIVE ); +if (ret) + goto err_free; + } + ret =xr_gpio_init (port, type);if (ret) goto err_free;
@@ -695,6 +878,9 @@ static const struct usb_device_id id_table[] = { { XR_DEVICE(0x04e2, 0x1410, XR21V141X) }, { XR_DEVICE(0x04e2, 0x1412, XR21V141X) }, { XR_DEVICE(0x04e2, 0x1414, XR21V141X) }, + { XR_DEVICE(0x04e2, 0x1420, XR21B142X) }, + { XR_DEVICE(0x04e2, 0x1422, XR21B142X) }, + { XR_DEVICE(0x04e2, 0x1424, XR21B142X) }, { } };MODULE_DEVICE_TABLE (usb, id_table);
Signature · 1 line
2.26.3
Johan Hovold
maintainerPATCH 8/12 USB: serial: xr: add support for XR21B1411
In reply to Johan HovoldThe single-port XR21B1411 is similar to the XR21B142X type but uses 12-bit registers and 16-bit register addresses, the register requests are different and are directed at the device rather than interface, and 5 and 6-bit words are not supported.
The register layout is very similar to XR21B142X except that most registers are offset by 0xc00 (corresponding to a channel index of 12 in the MSB of wIndex). As the device is single-port so that the derived channel index is 0, the current register accessors can be reused after simply changing the address width.
--- drivers/usb/serial/xr_serial.c | 64 +++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 16 deletions(-)
drivers/usb/serial/xr_serial.c +48 -16
@@ -108,18 +108,19 @@ struct xr_type {u8 set_reg;u8 get_reg; -u8 uart_enable; -u8 flow_control; -u8 xon_char; -u8 xoff_char; -u8 tx_break; -u8 gpio_mode; -u8 gpio_direction; -u8 gpio_set; -u8 gpio_clear; -u8 gpio_status; -u8 custom_driver; - +u16 uart_enable; +u16 flow_control; +u16 xon_char; +u16 xoff_char; +u16 tx_break; +u16 gpio_mode; +u16 gpio_direction; +u16 gpio_set; +u16 gpio_clear; +u16 gpio_status; +u16 custom_driver; + +bool have_5_6_bit_mode;bool have_xmit_toggle;int (*enable)(struct usb_serial_port *port);
@@ -132,6 +133,7 @@ struct xr_type {enum xr_type_id {XR21V141X ,XR21B142X , +XR21B1411 ,XR_TYPE_COUNT , };
@@ -175,8 +177,27 @@ static const struct xr_type xr_types[] = { .gpio_status = 0x10, .custom_driver = 0x60, + .have_5_6_bit_mode = true, .have_xmit_toggle = true, }, + [XR21B1411] = { + .reg_width = 12, + .reg_recipient = USB_RECIP_DEVICE, + .set_reg = 0x00, + .get_reg = 0x01, + + .uart_enable = 0xc00, + .flow_control = 0xc06, + .xon_char = 0xc07, + .xoff_char = 0xc08, + .tx_break = 0xc0a, + .gpio_mode = 0xc0c, + .gpio_direction = 0xc0d, + .gpio_set = 0xc0e, + .gpio_clear = 0xc0f, + .gpio_status = 0xc10, + .custom_driver = 0x20d, + }, };struct xr_data {
@@ -184,7 +205,7 @@ struct xr_data {u8 channel;/* zero-based index or interface number */ }; -static int xr_set_reg (struct usb_serial_port *port,u8 channel,u8 reg,u16 val) +static int xr_set_reg (struct usb_serial_port *port,u8 channel,u16 reg,u16 val) {struct xr_data *data =usb_get_serial_port_data (port);const struct xr_type *type = data->type;
@@ -204,7 +225,7 @@ static int xr_set_reg(struct usb_serial_port *port, u8 channel, u8 reg, u16 val)return 0 ; } -static int xr_get_reg (struct usb_serial_port *port,u8 channel,u8 reg,u16 *val) +static int xr_get_reg (struct usb_serial_port *port,u8 channel,u16 reg,u16 *val) {struct xr_data *data =usb_get_serial_port_data (port);const struct xr_type *type = data->type;
@@ -243,14 +264,14 @@ static int xr_get_reg(struct usb_serial_port *port, u8 channel, u8 reg, u16 *valreturn ret; } -static int xr_set_reg_uart (struct usb_serial_port *port,u8 reg,u16 val) +static int xr_set_reg_uart (struct usb_serial_port *port,u16 reg,u16 val) {struct xr_data *data =usb_get_serial_port_data (port);return xr_set_reg (port, data->channel, reg, val); } -static int xr_get_reg_uart (struct usb_serial_port *port,u8 reg,u16 *val) +static int xr_get_reg_uart (struct usb_serial_port *port,u16 reg,u16 *val) {struct xr_data *data =usb_get_serial_port_data (port);
@@ -646,6 +667,7 @@ static void xr21v141x_set_line_settings(struct tty_struct *tty,static void xr_cdc_set_line_coding (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios) { +struct xr_data *data =usb_get_serial_port_data (port);struct usb_host_interface *alt = port->serial->interface->cur_altsetting;struct usb_device *udev = port->serial->dev;struct usb_cdc_line_coding *lc;
@@ -683,6 +705,15 @@ static void xr_cdc_set_line_coding(struct tty_struct *tty, lc->bParityType =USB_CDC_NO_PARITY ; } +if (!data->type->have_5_6_bit_mode && + (C_CSIZE (tty) ==CS5 ||C_CSIZE (tty) ==CS6 )) { + tty->termios.c_cflag &= ~CSIZE ; +if (old_termios) + tty->termios.c_cflag |= old_termios->c_cflag &CSIZE ; +else + tty->termios.c_cflag |=CS8 ; + } +switch (C_CSIZE (tty)) {case CS5 : lc->bDataBits =5 ;
@@ -876,6 +907,7 @@ static void xr_port_remove(struct usb_serial_port *port)static const struct usb_device_id id_table[] = { {XR_DEVICE (0x04e2 ,0x1410 ,XR21V141X ) }, + {XR_DEVICE (0x04e2 ,0x1411 ,XR21B1411 ) }, {XR_DEVICE (0x04e2 ,0x1412 ,XR21V141X ) }, {XR_DEVICE (0x04e2 ,0x1414 ,XR21V141X ) }, {XR_DEVICE (0x04e2 ,0x1420 ,XR21B142X ) },
Signature · 1 line
2.26.3
Johan Hovold
maintainerPATCH 9/12 USB: serial: xr: add support for XR22801, XR22802, XR22804
In reply to Johan HovoldThe XR22801, XR22802 and XR22804 are compound devices with an embedded hub and up to seven downstream USB devices including one, two or four UARTs respectively.
The UART function is similar to XR21B142X but most registers are offset by 0x40, the register requests are different and are directed at the device rather than interface, and 5 and 6-bit words are not supported.
--- drivers/usb/serial/xr_serial.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/usb/serial/xr_serial.c +23 -0
@@ -134,6 +134,7 @@ enum xr_type_id {XR21V141X ,XR21B142X ,XR21B1411 , +XR2280X , XR_TYPE_COUNT, };
@@ -198,6 +199,24 @@ static const struct xr_type xr_types[] = { .gpio_status = 0xc10, .custom_driver = 0x20d, }, + [XR2280X] = { + .reg_width = 16, + .reg_recipient = USB_RECIP_DEVICE, + .set_reg = 0x05, + .get_reg = 0x05, + + .uart_enable = 0x40, + .flow_control = 0x46, + .xon_char = 0x47, + .xoff_char = 0x48, + .tx_break = 0x4a, + .gpio_mode = 0x4c, + .gpio_direction = 0x4d, + .gpio_set = 0x4e, + .gpio_clear = 0x4f, + .gpio_status = 0x50, + .custom_driver = 0x81, + }, };struct xr_data {
@@ -906,6 +925,10 @@ static void xr_port_remove(struct usb_serial_port *port) .driver_info = (type) static const struct usb_device_id id_table[] = { + {XR_DEVICE (0x04e2 ,0x1400 ,XR2280X ) }, + {XR_DEVICE (0x04e2 ,0x1401 ,XR2280X ) }, + {XR_DEVICE (0x04e2 ,0x1402 ,XR2280X ) }, + {XR_DEVICE (0x04e2 ,0x1403 ,XR2280X ) }, {XR_DEVICE (0x04e2 ,0x1410 ,XR21V141X ) }, {XR_DEVICE (0x04e2 ,0x1411 ,XR21B1411 ) }, {XR_DEVICE (0x04e2 ,0x1412 ,XR21V141X ) },
Signature · 1 line
2.26.3
Johan Hovold
maintainerPATCH 10/12 USB: serial: xr: reset FIFOs on open
In reply to Johan HovoldReset the transmit and receive FIFOs before enabling the UARTs as part of open() in order to flush any stale data.
Note that the XR21V141X needs a type-specific implementation due to its UART Manager registers.
--- drivers/usb/serial/xr_serial.c | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
drivers/usb/serial/xr_serial.c +51 -0
@@ -95,10 +95,13 @@ struct xr_txrx_clk_mask {#define XR_GPIO_MODE_TX_TOGGLE 0x100#define XR_GPIO_MODE_RX_TOGGLE 0x200 +#define XR_FIFO_RESET 0x1 +#define XR_CUSTOM_DRIVER_ACTIVE 0x1static int xr21v141x_uart_enable (struct usb_serial_port *port);static int xr21v141x_uart_disable (struct usb_serial_port *port); +static int xr21v141x_fifo_reset (struct usb_serial_port *port);static void xr21v141x_set_line_settings (struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios);
@@ -118,6 +121,8 @@ struct xr_type {u16 gpio_set;u16 gpio_clear;u16 gpio_status; +u16 tx_fifo_reset; +u16 rx_fifo_reset;u16 custom_driver;bool have_5_6_bit_mode;
@@ -125,6 +130,7 @@ struct xr_type {int (*enable)(struct usb_serial_port *port);int (*disable)(struct usb_serial_port *port); +int (*fifo_reset)(struct usb_serial_port *port);void (*set_line_settings)(struct tty_struct *tty,struct usb_serial_port *port,struct ktermios *old_termios);
@@ -158,6 +164,7 @@ static const struct xr_type xr_types[] = { .enable = xr21v141x_uart_enable, .disable = xr21v141x_uart_disable, + .fifo_reset = xr21v141x_fifo_reset, .set_line_settings = xr21v141x_set_line_settings, }, [XR21B142X] = {
@@ -176,6 +183,8 @@ static const struct xr_type xr_types[] = { .gpio_set = 0x0e, .gpio_clear = 0x0f, .gpio_status = 0x10, + .tx_fifo_reset = 0x40, + .rx_fifo_reset = 0x43, .custom_driver = 0x60, .have_5_6_bit_mode = true,
@@ -197,6 +206,8 @@ static const struct xr_type xr_types[] = { .gpio_set = 0xc0e, .gpio_clear = 0xc0f, .gpio_status = 0xc10, + .tx_fifo_reset = 0xc80, + .rx_fifo_reset = 0xcc0, .custom_driver = 0x20d, }, [XR2280X] = {
@@ -215,6 +226,8 @@ static const struct xr_type xr_types[] = { .gpio_set = 0x4e, .gpio_clear = 0x4f, .gpio_status = 0x50, + .tx_fifo_reset = 0x60, + .rx_fifo_reset = 0x63, .custom_driver = 0x81, }, };
@@ -384,6 +397,40 @@ static int xr_uart_disable(struct usb_serial_port *port)return __xr_uart_disable (port); } +static int xr21v141x_fifo_reset (struct usb_serial_port *port) +{ +int ret; + + ret =xr_set_reg_um (port,XR21V141X_UM_TX_FIFO_RESET ,XR_FIFO_RESET ); +if (ret) +return ret; + + ret =xr_set_reg_um (port,XR21V141X_UM_RX_FIFO_RESET ,XR_FIFO_RESET ); +if (ret) +return ret; + +return 0 ; +} + +static int xr_fifo_reset (struct usb_serial_port *port) +{ +struct xr_data *data =usb_get_serial_port_data (port); +int ret; + +if (data->type->fifo_reset) +return data->type->fifo_reset (port); + + ret =xr_set_reg_uart (port, data->type->tx_fifo_reset,XR_FIFO_RESET ); +if (ret) +return ret; + + ret =xr_set_reg_uart (port, data->type->rx_fifo_reset,XR_FIFO_RESET ); +if (ret) +return ret; + +return 0 ; +} +static int xr_tiocmget (struct tty_struct *tty) {struct usb_serial_port *port = tty->driver_data;
@@ -781,6 +828,10 @@ static int xr_open(struct tty_struct *tty, struct usb_serial_port *port) {int ret; + ret =xr_fifo_reset (port); +if (ret) +return ret; + ret =xr_uart_enable (port);if (ret) {dev_err (&port->dev,"Failed to enable UART\n" );
Signature · 1 line
2.26.3
Johan Hovold
maintainerPATCH 11/12 USB: serial: xr: add copyright notice
In reply to Johan HovoldAdd another copyright notice for the work done in 2021.
--- drivers/usb/serial/xr_serial.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/xr_serial.c +1 -0
@@ -3,6 +3,7 @@* MaxLinear/Exar USB to Serial driver * * Copyright (c) 2020 Manivannan Sadhasivam <[email protected]> +* Copyright (c) 2021 Johan Hovold <[email protected]> * * Based on the initial driver written by Patong Yang: *
Signature · 1 line
2.26.3
Johan Hovold
maintainerPATCH 12/12 USB: cdc-acm: add more Maxlinear/Exar models to ignore list
In reply to Johan HovoldFrom: Mauro Carvalho Chehab <[email protected]>
Now that the xr_serial got support for other models, add their USB IDs as well.
The Maxlinear/Exar USB UARTs can be used in either ACM mode using the cdc-acm driver or in "custom driver" mode in which further features such as hardware and software flow control, GPIO control and in-band line-status reporting are available.
In ACM mode the device always enables RTS/CTS flow control, something which could prevent transmission in case the CTS input isn't wired up correctly.
Ensure that cdc_acm will not bind to these devices if the custom USB-serial driver is enabled.
--- drivers/usb/class/cdc-acm.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/usb/class/cdc-acm.c +11 -3
@@ -1903,9 +1903,17 @@ static const struct usb_device_id acm_ids[] = {#endif #if IS_ENABLED(CONFIG_USB_SERIAL_XR) - { USB_DEVICE(0x04e2, 0x1410), /* Ignore XR21V141X USB to Serial converter */ - .driver_info = IGNORE_DEVICE, - }, + { USB_DEVICE(0x04e2, 0x1400), .driver_info = IGNORE_DEVICE }, + { USB_DEVICE(0x04e2, 0x1401), .driver_info = IGNORE_DEVICE }, + { USB_DEVICE(0x04e2, 0x1402), .driver_info = IGNORE_DEVICE }, + { USB_DEVICE(0x04e2, 0x1403), .driver_info = IGNORE_DEVICE }, + { USB_DEVICE(0x04e2, 0x1410), .driver_info = IGNORE_DEVICE }, + { USB_DEVICE(0x04e2, 0x1411), .driver_info = IGNORE_DEVICE }, + { USB_DEVICE(0x04e2, 0x1412), .driver_info = IGNORE_DEVICE }, + { USB_DEVICE(0x04e2, 0x1414), .driver_info = IGNORE_DEVICE }, + { USB_DEVICE(0x04e2, 0x1420), .driver_info = IGNORE_DEVICE }, + { USB_DEVICE(0x04e2, 0x1422), .driver_info = IGNORE_DEVICE }, + { USB_DEVICE(0x04e2, 0x1424), .driver_info = IGNORE_DEVICE }, #endif /*Samsung phone in firmware update mode */
Signature · 1 line
2.26.3
Re: [PATCH 12/12] USB: cdc-acm: add more Maxlinear/Exar models to ignore list
Quoted 14 lines · Johan Hovold
From: Mauro Carvalho Chehab <[email protected]>
Now that the
xr_serialgot support for other models, add their USB IDs as well.The Maxlinear/Exar USB UARTs can be used in either ACM mode using the cdc-acm driver or in "custom driver" mode in which further features such as hardware and software flow control, GPIO control and in-band line-status reporting are available.
In ACM mode the device always enables RTS/CTS flow control, something which could prevent transmission in case the CTS input isn't wired up correctly.
Quoted 8 lines
Ensure that
cdc_acmwill not bind to these devices if the custom USB-serial driver is enabled.Signed-off-by Mauro Carvalho Chehab <[email protected]>Link https://lore.kernel.org/r/5155887a764cbc11f8da0217fe08a24a77d120b4.1616571453.git.mchehab+huawei@kernel.org open here[ johan: rewrite commit message, clean up entries ]Cc Oliver Neukum <[email protected]>Signed-off-by Johan Hovold <[email protected]>