mirror of
https://github.com/torvalds/linux.git
synced 2024-12-18 17:12:55 +00:00
USB-serial updates for 4.21-rc1
Here are the USB-serial updates for 4.21-rc1, including: - support for mos7840 3-port devices - improved ftdi baud-rate divisor calculations - support for a new class of f81534 devices Included are also various clean ups and some new pl2303 device ids. All have been in linux-next with no reported issues. Signed-off-by: Johan Hovold <johan@kernel.org> -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQQHbPq+cpGvN/peuzMLxc3C7H1lCAUCXBva9AAKCRALxc3C7H1l CP6XAQClpmmKj59AiAJK+hlWIbNpznPUUrkGHS7mFyuWkDrllQEAsK2IofNWbs9y g0ot/v4UgUVZHySGl5yYoV4A0uKJdAQ= =oyPx -----END PGP SIGNATURE----- Merge tag 'usb-serial-4.21-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next Johan writes: USB-serial updates for 4.21-rc1 Here are the USB-serial updates for 4.21-rc1, including: - support for mos7840 3-port devices - improved ftdi baud-rate divisor calculations - support for a new class of f81534 devices Included are also various clean ups and some new pl2303 device ids. All have been in linux-next with no reported issues. Signed-off-by: Johan Hovold <johan@kernel.org> * tag 'usb-serial-4.21-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial: USB: serial: pl2303: add ids for Hewlett-Packard HP POS pole displays USB: serial: mos7840: remove set but not used variables 'number, serial' USB: serial: mos7840: add a product ID for the new product USB: serial: mos7840: clean up register handling USB: serial: ftdi_sio: use rounding when calculating baud rate divisors USB: serial: f81534: fix reading old/new IC config USB: serial: mos7840: remove set but not used variables 'st, data1, iflag' USB: serial: quatech2: remove set but not used variable 'port_priv'
This commit is contained in:
commit
1e12a521d6
@ -45,14 +45,17 @@
|
||||
#define F81534_CONFIG1_REG (0x09 + F81534_UART_BASE_ADDRESS)
|
||||
|
||||
#define F81534_DEF_CONF_ADDRESS_START 0x3000
|
||||
#define F81534_DEF_CONF_SIZE 8
|
||||
#define F81534_DEF_CONF_SIZE 12
|
||||
|
||||
#define F81534_CUSTOM_ADDRESS_START 0x2f00
|
||||
#define F81534_CUSTOM_DATA_SIZE 0x10
|
||||
#define F81534_CUSTOM_NO_CUSTOM_DATA 0xff
|
||||
#define F81534_CUSTOM_VALID_TOKEN 0xf0
|
||||
#define F81534_CONF_OFFSET 1
|
||||
#define F81534_CONF_GPIO_OFFSET 4
|
||||
#define F81534_CONF_INIT_GPIO_OFFSET 4
|
||||
#define F81534_CONF_WORK_GPIO_OFFSET 8
|
||||
#define F81534_CONF_GPIO_SHUTDOWN 7
|
||||
#define F81534_CONF_GPIO_RS232 1
|
||||
|
||||
#define F81534_MAX_DATA_BLOCK 64
|
||||
#define F81534_MAX_BUS_RETRY 20
|
||||
@ -1337,8 +1340,19 @@ static int f81534_set_port_output_pin(struct usb_serial_port *port)
|
||||
serial_priv = usb_get_serial_data(serial);
|
||||
port_priv = usb_get_serial_port_data(port);
|
||||
|
||||
idx = F81534_CONF_GPIO_OFFSET + port_priv->phy_num;
|
||||
idx = F81534_CONF_INIT_GPIO_OFFSET + port_priv->phy_num;
|
||||
value = serial_priv->conf_data[idx];
|
||||
if (value >= F81534_CONF_GPIO_SHUTDOWN) {
|
||||
/*
|
||||
* Newer IC configure will make transceiver in shutdown mode on
|
||||
* initial power on. We need enable it before using UARTs.
|
||||
*/
|
||||
idx = F81534_CONF_WORK_GPIO_OFFSET + port_priv->phy_num;
|
||||
value = serial_priv->conf_data[idx];
|
||||
if (value >= F81534_CONF_GPIO_SHUTDOWN)
|
||||
value = F81534_CONF_GPIO_RS232;
|
||||
}
|
||||
|
||||
pins = &f81534_port_out_pins[port_priv->phy_num];
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(pins->pin); ++i) {
|
||||
|
@ -1130,7 +1130,7 @@ static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base)
|
||||
{
|
||||
unsigned short int divisor;
|
||||
/* divisor shifted 3 bits to the left */
|
||||
int divisor3 = base / 2 / baud;
|
||||
int divisor3 = DIV_ROUND_CLOSEST(base, 2 * baud);
|
||||
if ((divisor3 & 0x7) == 7)
|
||||
divisor3++; /* round x.7/8 up to x+1 */
|
||||
divisor = divisor3 >> 3;
|
||||
@ -1156,7 +1156,7 @@ static u32 ftdi_232bm_baud_base_to_divisor(int baud, int base)
|
||||
static const unsigned char divfrac[8] = { 0, 3, 2, 4, 1, 5, 6, 7 };
|
||||
u32 divisor;
|
||||
/* divisor shifted 3 bits to the left */
|
||||
int divisor3 = base / 2 / baud;
|
||||
int divisor3 = DIV_ROUND_CLOSEST(base, 2 * baud);
|
||||
divisor = divisor3 >> 3;
|
||||
divisor |= (u32)divfrac[divisor3 & 0x7] << 14;
|
||||
/* Deal with special cases for highest baud rates. */
|
||||
@ -1179,7 +1179,7 @@ static u32 ftdi_2232h_baud_base_to_divisor(int baud, int base)
|
||||
int divisor3;
|
||||
|
||||
/* hi-speed baud rate is 10-bit sampling instead of 16-bit */
|
||||
divisor3 = base * 8 / (baud * 10);
|
||||
divisor3 = DIV_ROUND_CLOSEST(8 * base, 10 * baud);
|
||||
|
||||
divisor = divisor3 >> 3;
|
||||
divisor |= (u32)divfrac[divisor3 & 0x7] << 14;
|
||||
|
@ -94,6 +94,7 @@
|
||||
/* The native mos7840/7820 component */
|
||||
#define USB_VENDOR_ID_MOSCHIP 0x9710
|
||||
#define MOSCHIP_DEVICE_ID_7840 0x7840
|
||||
#define MOSCHIP_DEVICE_ID_7843 0x7843
|
||||
#define MOSCHIP_DEVICE_ID_7820 0x7820
|
||||
#define MOSCHIP_DEVICE_ID_7810 0x7810
|
||||
/* The native component can have its vendor/device id's overridden
|
||||
@ -176,6 +177,7 @@ enum mos7840_flag {
|
||||
|
||||
static const struct usb_device_id id_table[] = {
|
||||
{USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)},
|
||||
{USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7843)},
|
||||
{USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)},
|
||||
{USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7810)},
|
||||
{USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)},
|
||||
@ -298,15 +300,10 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg,
|
||||
val = val & 0x00ff;
|
||||
/* For the UART control registers, the application number need
|
||||
to be Or'ed */
|
||||
if (port->serial->num_ports == 4) {
|
||||
if (port->serial->num_ports == 2 && port->port_number != 0)
|
||||
val |= ((__u16)port->port_number + 2) << 8;
|
||||
else
|
||||
val |= ((__u16)port->port_number + 1) << 8;
|
||||
} else {
|
||||
if (port->port_number == 0) {
|
||||
val |= ((__u16)port->port_number + 1) << 8;
|
||||
} else {
|
||||
val |= ((__u16)port->port_number + 2) << 8;
|
||||
}
|
||||
}
|
||||
dev_dbg(&port->dev, "%s application number is %x\n", __func__, val);
|
||||
return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ,
|
||||
MCS_WR_RTYPE, val, reg, NULL, 0,
|
||||
@ -332,15 +329,10 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
|
||||
return -ENOMEM;
|
||||
|
||||
/* Wval is same as application number */
|
||||
if (port->serial->num_ports == 4) {
|
||||
if (port->serial->num_ports == 2 && port->port_number != 0)
|
||||
Wval = ((__u16)port->port_number + 2) << 8;
|
||||
else
|
||||
Wval = ((__u16)port->port_number + 1) << 8;
|
||||
} else {
|
||||
if (port->port_number == 0) {
|
||||
Wval = ((__u16)port->port_number + 1) << 8;
|
||||
} else {
|
||||
Wval = ((__u16)port->port_number + 2) << 8;
|
||||
}
|
||||
}
|
||||
dev_dbg(&port->dev, "%s application number is %x\n", __func__, Wval);
|
||||
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
|
||||
MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH,
|
||||
@ -601,7 +593,7 @@ static void mos7840_interrupt_callback(struct urb *urb)
|
||||
struct usb_serial *serial;
|
||||
__u16 Data;
|
||||
unsigned char *data;
|
||||
__u8 sp[5], st;
|
||||
__u8 sp[5];
|
||||
int i, rv = 0;
|
||||
__u16 wval, wreg = 0;
|
||||
int status = urb->status;
|
||||
@ -644,7 +636,6 @@ static void mos7840_interrupt_callback(struct urb *urb)
|
||||
sp[1] = (__u8) data[1];
|
||||
sp[2] = (__u8) data[2];
|
||||
sp[3] = (__u8) data[3];
|
||||
st = (__u8) data[4];
|
||||
|
||||
for (i = 0; i < serial->num_ports; i++) {
|
||||
mos7840_port = mos7840_get_port_private(serial->port[i]);
|
||||
@ -1300,7 +1291,6 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
|
||||
struct urb *urb;
|
||||
/* __u16 Data; */
|
||||
const unsigned char *current_position = data;
|
||||
unsigned char *data1;
|
||||
|
||||
if (mos7840_port_paranoia_check(port, __func__))
|
||||
return -1;
|
||||
@ -1361,7 +1351,6 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
|
||||
mos7840_bulk_out_data_callback, mos7840_port);
|
||||
}
|
||||
|
||||
data1 = urb->transfer_buffer;
|
||||
dev_dbg(&port->dev, "bulkout endpoint is %d\n", port->bulk_out_endpointAddress);
|
||||
|
||||
if (mos7840_port->has_led)
|
||||
@ -1592,7 +1581,6 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
|
||||
int divisor = 0;
|
||||
int status;
|
||||
__u16 Data;
|
||||
unsigned char number;
|
||||
__u16 clk_sel_val;
|
||||
struct usb_serial_port *port;
|
||||
|
||||
@ -1606,8 +1594,6 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
|
||||
if (mos7840_serial_paranoia_check(port->serial, __func__))
|
||||
return -1;
|
||||
|
||||
number = mos7840_port->port->port_number;
|
||||
|
||||
dev_dbg(&port->dev, "%s - baud = %d\n", __func__, baudRate);
|
||||
/* reset clk_uart_sel in spregOffset */
|
||||
if (baudRate > 115200) {
|
||||
@ -1697,14 +1683,12 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
|
||||
{
|
||||
int baud;
|
||||
unsigned cflag;
|
||||
unsigned iflag;
|
||||
__u8 lData;
|
||||
__u8 lParity;
|
||||
__u8 lStop;
|
||||
int status;
|
||||
__u16 Data;
|
||||
struct usb_serial_port *port;
|
||||
struct usb_serial *serial;
|
||||
|
||||
if (mos7840_port == NULL)
|
||||
return;
|
||||
@ -1717,8 +1701,6 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
|
||||
if (mos7840_serial_paranoia_check(port->serial, __func__))
|
||||
return;
|
||||
|
||||
serial = port->serial;
|
||||
|
||||
if (!mos7840_port->open) {
|
||||
dev_dbg(&port->dev, "%s - port not opened\n", __func__);
|
||||
return;
|
||||
@ -1729,7 +1711,6 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
|
||||
lParity = LCR_PAR_NONE;
|
||||
|
||||
cflag = tty->termios.c_cflag;
|
||||
iflag = tty->termios.c_iflag;
|
||||
|
||||
/* Change the number of bits */
|
||||
switch (cflag & CSIZE) {
|
||||
@ -2043,7 +2024,8 @@ static int mos7840_probe(struct usb_serial *serial,
|
||||
int device_type;
|
||||
|
||||
if (product == MOSCHIP_DEVICE_ID_7810 ||
|
||||
product == MOSCHIP_DEVICE_ID_7820) {
|
||||
product == MOSCHIP_DEVICE_ID_7820 ||
|
||||
product == MOSCHIP_DEVICE_ID_7843) {
|
||||
device_type = product;
|
||||
goto out;
|
||||
}
|
||||
@ -2077,7 +2059,10 @@ static int mos7840_calc_num_ports(struct usb_serial *serial,
|
||||
int device_type = (unsigned long)usb_get_serial_data(serial);
|
||||
int num_ports;
|
||||
|
||||
num_ports = (device_type >> 4) & 0x000F;
|
||||
if (device_type == MOSCHIP_DEVICE_ID_7843)
|
||||
num_ports = 3;
|
||||
else
|
||||
num_ports = (device_type >> 4) & 0x000F;
|
||||
|
||||
/*
|
||||
* num_ports is currently never zero as device_type is one of
|
||||
@ -2132,22 +2117,16 @@ static int mos7840_port_probe(struct usb_serial_port *port)
|
||||
mos7840_port->SpRegOffset = 0x0;
|
||||
mos7840_port->ControlRegOffset = 0x1;
|
||||
mos7840_port->DcrRegOffset = 0x4;
|
||||
} else if ((mos7840_port->port_num == 2) && (serial->num_ports == 4)) {
|
||||
mos7840_port->SpRegOffset = 0x8;
|
||||
mos7840_port->ControlRegOffset = 0x9;
|
||||
mos7840_port->DcrRegOffset = 0x16;
|
||||
} else if ((mos7840_port->port_num == 2) && (serial->num_ports == 2)) {
|
||||
mos7840_port->SpRegOffset = 0xa;
|
||||
mos7840_port->ControlRegOffset = 0xb;
|
||||
mos7840_port->DcrRegOffset = 0x19;
|
||||
} else if ((mos7840_port->port_num == 3) && (serial->num_ports == 4)) {
|
||||
mos7840_port->SpRegOffset = 0xa;
|
||||
mos7840_port->ControlRegOffset = 0xb;
|
||||
mos7840_port->DcrRegOffset = 0x19;
|
||||
} else if ((mos7840_port->port_num == 4) && (serial->num_ports == 4)) {
|
||||
mos7840_port->SpRegOffset = 0xc;
|
||||
mos7840_port->ControlRegOffset = 0xd;
|
||||
mos7840_port->DcrRegOffset = 0x1c;
|
||||
} else {
|
||||
u8 phy_num = mos7840_port->port_num;
|
||||
|
||||
/* Port 2 in the 2-port case uses registers of port 3 */
|
||||
if (serial->num_ports == 2)
|
||||
phy_num = 3;
|
||||
|
||||
mos7840_port->SpRegOffset = 0x8 + 2 * (phy_num - 2);
|
||||
mos7840_port->ControlRegOffset = 0x9 + 2 * (phy_num - 2);
|
||||
mos7840_port->DcrRegOffset = 0x16 + 3 * (phy_num - 2);
|
||||
}
|
||||
mos7840_dump_serial_port(port, mos7840_port);
|
||||
mos7840_set_port_private(port, mos7840_port);
|
||||
|
@ -91,9 +91,14 @@ static const struct usb_device_id id_table[] = {
|
||||
{ USB_DEVICE(YCCABLE_VENDOR_ID, YCCABLE_PRODUCT_ID) },
|
||||
{ USB_DEVICE(SUPERIAL_VENDOR_ID, SUPERIAL_PRODUCT_ID) },
|
||||
{ USB_DEVICE(HP_VENDOR_ID, HP_LD220_PRODUCT_ID) },
|
||||
{ USB_DEVICE(HP_VENDOR_ID, HP_LD220TA_PRODUCT_ID) },
|
||||
{ USB_DEVICE(HP_VENDOR_ID, HP_LD960_PRODUCT_ID) },
|
||||
{ USB_DEVICE(HP_VENDOR_ID, HP_LD960TA_PRODUCT_ID) },
|
||||
{ USB_DEVICE(HP_VENDOR_ID, HP_LCM220_PRODUCT_ID) },
|
||||
{ USB_DEVICE(HP_VENDOR_ID, HP_LCM960_PRODUCT_ID) },
|
||||
{ USB_DEVICE(HP_VENDOR_ID, HP_LM920_PRODUCT_ID) },
|
||||
{ USB_DEVICE(HP_VENDOR_ID, HP_LM940_PRODUCT_ID) },
|
||||
{ USB_DEVICE(HP_VENDOR_ID, HP_TD620_PRODUCT_ID) },
|
||||
{ USB_DEVICE(CRESSI_VENDOR_ID, CRESSI_EDY_PRODUCT_ID) },
|
||||
{ USB_DEVICE(ZEAGLE_VENDOR_ID, ZEAGLE_N2ITION3_PRODUCT_ID) },
|
||||
{ USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) },
|
||||
|
@ -119,10 +119,15 @@
|
||||
|
||||
/* Hewlett-Packard POS Pole Displays */
|
||||
#define HP_VENDOR_ID 0x03f0
|
||||
#define HP_LM920_PRODUCT_ID 0x026b
|
||||
#define HP_TD620_PRODUCT_ID 0x0956
|
||||
#define HP_LD960_PRODUCT_ID 0x0b39
|
||||
#define HP_LCM220_PRODUCT_ID 0x3139
|
||||
#define HP_LCM960_PRODUCT_ID 0x3239
|
||||
#define HP_LD220_PRODUCT_ID 0x3524
|
||||
#define HP_LD220TA_PRODUCT_ID 0x4349
|
||||
#define HP_LD960TA_PRODUCT_ID 0x4439
|
||||
#define HP_LM940_PRODUCT_ID 0x5039
|
||||
|
||||
/* Cressi Edy (diving computer) PC interface */
|
||||
#define CRESSI_VENDOR_ID 0x04b8
|
||||
|
@ -500,7 +500,6 @@ static void qt2_process_read_urb(struct urb *urb)
|
||||
struct usb_serial *serial;
|
||||
struct qt2_serial_private *serial_priv;
|
||||
struct usb_serial_port *port;
|
||||
struct qt2_port_private *port_priv;
|
||||
bool escapeflag;
|
||||
unsigned char *ch;
|
||||
int i;
|
||||
@ -514,7 +513,6 @@ static void qt2_process_read_urb(struct urb *urb)
|
||||
serial = urb->context;
|
||||
serial_priv = usb_get_serial_data(serial);
|
||||
port = serial->port[serial_priv->current_port];
|
||||
port_priv = usb_get_serial_port_data(port);
|
||||
|
||||
for (i = 0; i < urb->actual_length; i++) {
|
||||
ch = (unsigned char *)urb->transfer_buffer + i;
|
||||
@ -566,7 +564,6 @@ static void qt2_process_read_urb(struct urb *urb)
|
||||
|
||||
serial_priv->current_port = newport;
|
||||
port = serial->port[serial_priv->current_port];
|
||||
port_priv = usb_get_serial_port_data(port);
|
||||
i += 3;
|
||||
escapeflag = true;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user