From: Johan Hovold <johan@kernel.org>
To: Johan Hovold <johan@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
Manivannan Sadhasivam <mani@kernel.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 08/12] USB: serial: xr: add support for XR21B1411
Date: Mon, 12 Apr 2021 11:55:53 +0200 [thread overview]
Message-ID: <20210412095557.1213-9-johan@kernel.org> (raw)
In-Reply-To: <20210412095557.1213-1-johan@kernel.org>
The 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.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/serial/xr_serial.c | 64 +++++++++++++++++++++++++---------
1 file changed, 48 insertions(+), 16 deletions(-)
diff --git a/drivers/usb/serial/xr_serial.c b/drivers/usb/serial/xr_serial.c
index 32055c763147..46e5e1b2f3c0 100644
--- a/drivers/usb/serial/xr_serial.c
+++ b/drivers/usb/serial/xr_serial.c
@@ -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 *val
return 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) },
--
2.26.3
next prev parent reply other threads:[~2021-04-12 10:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-12 9:55 [PATCH RESEND 00/12] USB: serial: xr: add support for more device types Johan Hovold
2021-04-12 9:55 ` [PATCH 01/12] USB: serial: xr: add support for XR21V1412 and XR21V1414 Johan Hovold
2021-04-12 9:55 ` [PATCH 02/12] USB: serial: xr: rename GPIO-mode defines Johan Hovold
2021-04-12 9:55 ` [PATCH 03/12] USB: serial: xr: rename GPIO-pin defines Johan Hovold
2021-04-12 9:55 ` [PATCH 04/12] USB: serial: xr: move pin configuration to probe Johan Hovold
2021-04-12 9:55 ` [PATCH 05/12] USB: serial: xr: drop type prefix from shared defines Johan Hovold
2021-04-12 9:55 ` [PATCH 06/12] USB: serial: xr: add type abstraction Johan Hovold
2021-04-12 9:55 ` [PATCH 07/12] USB: serial: xr: add support for XR21B1421, XR21B1422 and XR21B1424 Johan Hovold
2021-04-12 9:55 ` Johan Hovold [this message]
2021-04-12 9:55 ` [PATCH 09/12] USB: serial: xr: add support for XR22801, XR22802, XR22804 Johan Hovold
2021-04-12 9:55 ` [PATCH 10/12] USB: serial: xr: reset FIFOs on open Johan Hovold
2021-04-12 9:55 ` [PATCH 11/12] USB: serial: xr: add copyright notice Johan Hovold
2021-04-12 9:55 ` [PATCH 12/12] USB: cdc-acm: add more Maxlinear/Exar models to ignore list Johan Hovold
2021-04-12 11:00 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2021-03-30 14:39 [PATCH 00/12] USB: serial: xr: add support for more device types Johan Hovold
2021-03-30 14:39 ` [PATCH 08/12] USB: serial: xr: add support for XR21B1411 Johan Hovold
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210412095557.1213-9-johan@kernel.org \
--to=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mani@kernel.org \
--cc=mchehab+huawei@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).