Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'usb-serial-5.5-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next

Johan writes:

USB-serial updates for 5.5-rc1

Here are the USB-serial updates for 5.5-rc1, including:

- support for a new class of pl2303 devices
- improved divisor calculations for ch341
- fixes for a remote-wakeup bug in the moschip drivers
- improved device-type handling in mos7840
- various cleanups of mos7840

Included are also some new device ids.

All have been in linux-next with no reported issues.

Signed-off-by: Johan Hovold <johan@kernel.org>

* tag 'usb-serial-5.5-rc1' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial:
USB: serial: ftdi_sio: add device IDs for U-Blox C099-F9P
USB: serial: option: add support for Foxconn T77W968 LTE modules
USB: serial: mos7840: drop port open flag
USB: serial: mos7840: drop read-urb check
USB: serial: mos7840: drop port driver data accessors
USB: serial: mos7840: drop serial struct accessor
USB: serial: mos7840: drop paranoid serial checks
USB: serial: mos7840: drop paranoid port checks
USB: serial: mos7840: drop redundant urb context check
USB: serial: mos7840: rip out broken interrupt handling
USB: serial: mos7840: fix probe error handling
USB: serial: mos7840: document MCS7810 detection hack
USB: serial: mos7840: clean up device-type handling
USB: serial: mos7840: fix remote wakeup
USB: serial: mos7720: fix remote wakeup
USB: serial: option: add support for DW5821e with eSIM support
USB: serial: mos7840: add USB ID to support Moxa UPort 2210
USB: serial: ch341: reimplement line-speed handling
USB: serial: pl2303: add support for PL2303HXN

+300 -710
+75 -22
drivers/usb/serial/ch341.c
··· 48 48 #define CH341_BIT_DCD 0x08 49 49 #define CH341_BITS_MODEM_STAT 0x0f /* all bits */ 50 50 51 - /*******************************/ 52 - /* baudrate calculation factor */ 53 - /*******************************/ 54 - #define CH341_BAUDBASE_FACTOR 1532620800 55 - #define CH341_BAUDBASE_DIVMAX 3 56 - 57 51 /* Break support - the information used to implement this was gleaned from 58 52 * the Net/FreeBSD uchcom.c driver by Takanori Watanabe. Domo arigato. 59 53 */ ··· 138 144 return 0; 139 145 } 140 146 147 + #define CH341_CLKRATE 48000000 148 + #define CH341_CLK_DIV(ps, fact) (1 << (12 - 3 * (ps) - (fact))) 149 + #define CH341_MIN_RATE(ps) (CH341_CLKRATE / (CH341_CLK_DIV((ps), 1) * 512)) 150 + 151 + static const speed_t ch341_min_rates[] = { 152 + CH341_MIN_RATE(0), 153 + CH341_MIN_RATE(1), 154 + CH341_MIN_RATE(2), 155 + CH341_MIN_RATE(3), 156 + }; 157 + 158 + /* 159 + * The device line speed is given by the following equation: 160 + * 161 + * baudrate = 48000000 / (2^(12 - 3 * ps - fact) * div), where 162 + * 163 + * 0 <= ps <= 3, 164 + * 0 <= fact <= 1, 165 + * 2 <= div <= 256 if fact = 0, or 166 + * 9 <= div <= 256 if fact = 1 167 + */ 168 + static int ch341_get_divisor(speed_t speed) 169 + { 170 + unsigned int fact, div, clk_div; 171 + int ps; 172 + 173 + /* 174 + * Clamp to supported range, this makes the (ps < 0) and (div < 2) 175 + * sanity checks below redundant. 176 + */ 177 + speed = clamp(speed, 46U, 3000000U); 178 + 179 + /* 180 + * Start with highest possible base clock (fact = 1) that will give a 181 + * divisor strictly less than 512. 182 + */ 183 + fact = 1; 184 + for (ps = 3; ps >= 0; ps--) { 185 + if (speed > ch341_min_rates[ps]) 186 + break; 187 + } 188 + 189 + if (ps < 0) 190 + return -EINVAL; 191 + 192 + /* Determine corresponding divisor, rounding down. */ 193 + clk_div = CH341_CLK_DIV(ps, fact); 194 + div = CH341_CLKRATE / (clk_div * speed); 195 + 196 + /* Halve base clock (fact = 0) if required. */ 197 + if (div < 9 || div > 255) { 198 + div /= 2; 199 + clk_div *= 2; 200 + fact = 0; 201 + } 202 + 203 + if (div < 2) 204 + return -EINVAL; 205 + 206 + /* 207 + * Pick next divisor if resulting rate is closer to the requested one, 208 + * scale up to avoid rounding errors on low rates. 209 + */ 210 + if (16 * CH341_CLKRATE / (clk_div * div) - 16 * speed >= 211 + 16 * speed - 16 * CH341_CLKRATE / (clk_div * (div + 1))) 212 + div++; 213 + 214 + return (0x100 - div) << 8 | fact << 2 | ps; 215 + } 216 + 141 217 static int ch341_set_baudrate_lcr(struct usb_device *dev, 142 218 struct ch341_private *priv, u8 lcr) 143 219 { 144 - short a; 220 + int val; 145 221 int r; 146 - unsigned long factor; 147 - short divisor; 148 222 149 223 if (!priv->baud_rate) 150 224 return -EINVAL; 151 - factor = (CH341_BAUDBASE_FACTOR / priv->baud_rate); 152 - divisor = CH341_BAUDBASE_DIVMAX; 153 225 154 - while ((factor > 0xfff0) && divisor) { 155 - factor >>= 3; 156 - divisor--; 157 - } 158 - 159 - if (factor > 0xfff0) 226 + val = ch341_get_divisor(priv->baud_rate); 227 + if (val < 0) 160 228 return -EINVAL; 161 - 162 - factor = 0x10000 - factor; 163 - a = (factor & 0xff00) | divisor; 164 229 165 230 /* 166 231 * CH341A buffers data until a full endpoint-size packet (32 bytes) 167 232 * has been received unless bit 7 is set. 168 233 */ 169 - a |= BIT(7); 234 + val |= BIT(7); 170 235 171 - r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x1312, a); 236 + r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x1312, val); 172 237 if (r) 173 238 return r; 174 239
+3
drivers/usb/serial/ftdi_sio.c
··· 1033 1033 /* Sienna devices */ 1034 1034 { USB_DEVICE(FTDI_VID, FTDI_SIENNA_PID) }, 1035 1035 { USB_DEVICE(ECHELON_VID, ECHELON_U20_PID) }, 1036 + /* U-Blox devices */ 1037 + { USB_DEVICE(UBLOX_VID, UBLOX_C099F9P_ZED_PID) }, 1038 + { USB_DEVICE(UBLOX_VID, UBLOX_C099F9P_ODIN_PID) }, 1036 1039 { } /* Terminating entry */ 1037 1040 }; 1038 1041
+7
drivers/usb/serial/ftdi_sio_ids.h
··· 1558 1558 */ 1559 1559 #define UNJO_VID 0x22B7 1560 1560 #define UNJO_ISODEBUG_V1_PID 0x150D 1561 + 1562 + /* 1563 + * U-Blox products (http://www.u-blox.com). 1564 + */ 1565 + #define UBLOX_VID 0x1546 1566 + #define UBLOX_C099F9P_ZED_PID 0x0502 1567 + #define UBLOX_C099F9P_ODIN_PID 0x0503
-4
drivers/usb/serial/mos7720.c
··· 1833 1833 product = le16_to_cpu(serial->dev->descriptor.idProduct); 1834 1834 dev = serial->dev; 1835 1835 1836 - /* setting configuration feature to one */ 1837 - usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 1838 - (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5000); 1839 - 1840 1836 if (product == MOSCHIP_DEVICE_ID_7715) { 1841 1837 struct urb *urb = serial->port[0]->interrupt_in_urb; 1842 1838
+101 -661
drivers/usb/serial/mos7840.c
··· 89 89 /* For higher baud Rates use TIOCEXBAUD */ 90 90 #define TIOCEXBAUD 0x5462 91 91 92 - /* vendor id and device id defines */ 93 - 94 - /* The native mos7840/7820 component */ 95 - #define USB_VENDOR_ID_MOSCHIP 0x9710 96 - #define MOSCHIP_DEVICE_ID_7840 0x7840 97 - #define MOSCHIP_DEVICE_ID_7843 0x7843 98 - #define MOSCHIP_DEVICE_ID_7820 0x7820 99 - #define MOSCHIP_DEVICE_ID_7810 0x7810 100 - /* The native component can have its vendor/device id's overridden 101 - * in vendor-specific implementations. Such devices can be handled 102 - * by making a change here, in id_table. 92 + /* 93 + * Vendor id and device id defines 94 + * 95 + * NOTE: Do not add new defines, add entries directly to the id_table instead. 103 96 */ 104 97 #define USB_VENDOR_ID_BANDB 0x0856 105 98 #define BANDB_DEVICE_ID_USO9ML2_2 0xAC22 ··· 108 115 #define BANDB_DEVICE_ID_USOPTL4_4 0xAC44 109 116 #define BANDB_DEVICE_ID_USOPTL4_4P 0xBC03 110 117 #define BANDB_DEVICE_ID_USOPTL2_4 0xAC24 111 - 112 - /* This driver also supports 113 - * ATEN UC2324 device using Moschip MCS7840 114 - * ATEN UC2322 device using Moschip MCS7820 115 - */ 116 - #define USB_VENDOR_ID_ATENINTL 0x0557 117 - #define ATENINTL_DEVICE_ID_UC2324 0x2011 118 - #define ATENINTL_DEVICE_ID_UC2322 0x7820 119 118 120 119 /* Interrupt Routine Defines */ 121 120 ··· 156 171 #define LED_OFF_MS 500 157 172 158 173 enum mos7840_flag { 159 - MOS7840_FLAG_CTRL_BUSY, 160 174 MOS7840_FLAG_LED_BUSY, 161 175 }; 162 176 177 + #define MCS_PORT_MASK GENMASK(2, 0) 178 + #define MCS_PORTS(nr) ((nr) & MCS_PORT_MASK) 179 + #define MCS_LED BIT(3) 180 + 181 + #define MCS_DEVICE(vid, pid, flags) \ 182 + USB_DEVICE((vid), (pid)), .driver_info = (flags) 183 + 163 184 static const struct usb_device_id id_table[] = { 164 - {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)}, 165 - {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7843)}, 166 - {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)}, 167 - {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7810)}, 168 - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2)}, 169 - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2P)}, 170 - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_4)}, 171 - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_4P)}, 172 - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_US9ML2_2)}, 173 - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_US9ML2_4)}, 174 - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_2)}, 175 - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_4)}, 176 - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2)}, 177 - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2P)}, 178 - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4)}, 179 - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4P)}, 180 - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL2_4)}, 181 - {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2324)}, 182 - {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2322)}, 185 + { MCS_DEVICE(0x0557, 0x2011, MCS_PORTS(4)) }, /* ATEN UC2324 */ 186 + { MCS_DEVICE(0x0557, 0x7820, MCS_PORTS(2)) }, /* ATEN UC2322 */ 187 + { MCS_DEVICE(0x110a, 0x2210, MCS_PORTS(2)) }, /* Moxa UPort 2210 */ 188 + { MCS_DEVICE(0x9710, 0x7810, MCS_PORTS(1) | MCS_LED) }, /* ASIX MCS7810 */ 189 + { MCS_DEVICE(0x9710, 0x7820, MCS_PORTS(2)) }, /* MosChip MCS7820 */ 190 + { MCS_DEVICE(0x9710, 0x7840, MCS_PORTS(4)) }, /* MosChip MCS7840 */ 191 + { MCS_DEVICE(0x9710, 0x7843, MCS_PORTS(3)) }, /* ASIX MCS7840 3 port */ 192 + { USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2) }, 193 + { USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_2P) }, 194 + { USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_4) }, 195 + { USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USO9ML2_4P) }, 196 + { USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_US9ML2_2) }, 197 + { USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_US9ML2_4) }, 198 + { USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_2) }, 199 + { USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USPTL4_4) }, 200 + { USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2) }, 201 + { USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2P) }, 202 + { USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4) }, 203 + { USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4P) }, 204 + { USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL2_4) }, 183 205 {} /* terminating entry */ 184 206 }; 185 207 MODULE_DEVICE_TABLE(usb, id_table); ··· 198 206 struct urb *read_urb; /* read URB for this port */ 199 207 __u8 shadowLCR; /* last LCR value received */ 200 208 __u8 shadowMCR; /* last MCR value received */ 201 - char open; 202 - char open_ports; 203 209 struct usb_serial_port *port; /* loop back to the owner of this object */ 204 210 205 211 /* Offsets */ 206 212 __u8 SpRegOffset; 207 213 __u8 ControlRegOffset; 208 214 __u8 DcrRegOffset; 209 - /* for processing control URBS in interrupt context */ 210 - struct urb *control_urb; 211 - struct usb_ctrlrequest *dr; 212 - char *ctrl_buf; 213 - int MsrLsr; 214 215 215 216 spinlock_t pool_lock; 216 217 struct urb *write_urb_pool[NUM_URBS]; ··· 345 360 346 361 /************************************************************************/ 347 362 /************************************************************************/ 348 - /* I N T E R F A C E F U N C T I O N S */ 349 - /* I N T E R F A C E F U N C T I O N S */ 350 - /************************************************************************/ 351 - /************************************************************************/ 352 - 353 - static inline void mos7840_set_port_private(struct usb_serial_port *port, 354 - struct moschip_port *data) 355 - { 356 - usb_set_serial_port_data(port, (void *)data); 357 - } 358 - 359 - static inline struct moschip_port *mos7840_get_port_private(struct 360 - usb_serial_port 361 - *port) 362 - { 363 - return (struct moschip_port *)usb_get_serial_port_data(port); 364 - } 365 - 366 - static void mos7840_handle_new_msr(struct moschip_port *port, __u8 new_msr) 367 - { 368 - struct moschip_port *mos7840_port; 369 - struct async_icount *icount; 370 - mos7840_port = port; 371 - if (new_msr & 372 - (MOS_MSR_DELTA_CTS | MOS_MSR_DELTA_DSR | MOS_MSR_DELTA_RI | 373 - MOS_MSR_DELTA_CD)) { 374 - icount = &mos7840_port->port->icount; 375 - 376 - /* update input line counters */ 377 - if (new_msr & MOS_MSR_DELTA_CTS) 378 - icount->cts++; 379 - if (new_msr & MOS_MSR_DELTA_DSR) 380 - icount->dsr++; 381 - if (new_msr & MOS_MSR_DELTA_CD) 382 - icount->dcd++; 383 - if (new_msr & MOS_MSR_DELTA_RI) 384 - icount->rng++; 385 - 386 - wake_up_interruptible(&port->port->port.delta_msr_wait); 387 - } 388 - } 389 - 390 - static void mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr) 391 - { 392 - struct async_icount *icount; 393 - 394 - if (new_lsr & SERIAL_LSR_BI) { 395 - /* 396 - * Parity and Framing errors only count if they 397 - * occur exclusive of a break being 398 - * received. 399 - */ 400 - new_lsr &= (__u8) (SERIAL_LSR_OE | SERIAL_LSR_BI); 401 - } 402 - 403 - /* update input line counters */ 404 - icount = &port->port->icount; 405 - if (new_lsr & SERIAL_LSR_BI) 406 - icount->brk++; 407 - if (new_lsr & SERIAL_LSR_OE) 408 - icount->overrun++; 409 - if (new_lsr & SERIAL_LSR_PE) 410 - icount->parity++; 411 - if (new_lsr & SERIAL_LSR_FE) 412 - icount->frame++; 413 - } 414 - 415 - /************************************************************************/ 416 - /************************************************************************/ 417 363 /* U S B C A L L B A C K F U N C T I O N S */ 418 364 /* U S B C A L L B A C K F U N C T I O N S */ 419 365 /************************************************************************/ 420 366 /************************************************************************/ 421 - 422 - static void mos7840_control_callback(struct urb *urb) 423 - { 424 - unsigned char *data; 425 - struct moschip_port *mos7840_port; 426 - struct device *dev = &urb->dev->dev; 427 - __u8 regval = 0x0; 428 - int status = urb->status; 429 - 430 - mos7840_port = urb->context; 431 - 432 - switch (status) { 433 - case 0: 434 - /* success */ 435 - break; 436 - case -ECONNRESET: 437 - case -ENOENT: 438 - case -ESHUTDOWN: 439 - /* this urb is terminated, clean up */ 440 - dev_dbg(dev, "%s - urb shutting down with status: %d\n", __func__, status); 441 - goto out; 442 - default: 443 - dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status); 444 - goto out; 445 - } 446 - 447 - dev_dbg(dev, "%s urb buffer size is %d\n", __func__, urb->actual_length); 448 - if (urb->actual_length < 1) 449 - goto out; 450 - 451 - dev_dbg(dev, "%s mos7840_port->MsrLsr is %d port %d\n", __func__, 452 - mos7840_port->MsrLsr, mos7840_port->port_num); 453 - data = urb->transfer_buffer; 454 - regval = (__u8) data[0]; 455 - dev_dbg(dev, "%s data is %x\n", __func__, regval); 456 - if (mos7840_port->MsrLsr == 0) 457 - mos7840_handle_new_msr(mos7840_port, regval); 458 - else if (mos7840_port->MsrLsr == 1) 459 - mos7840_handle_new_lsr(mos7840_port, regval); 460 - out: 461 - clear_bit_unlock(MOS7840_FLAG_CTRL_BUSY, &mos7840_port->flags); 462 - } 463 - 464 - static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg, 465 - __u16 *val) 466 - { 467 - struct usb_device *dev = mcs->port->serial->dev; 468 - struct usb_ctrlrequest *dr = mcs->dr; 469 - unsigned char *buffer = mcs->ctrl_buf; 470 - int ret; 471 - 472 - if (test_and_set_bit_lock(MOS7840_FLAG_CTRL_BUSY, &mcs->flags)) 473 - return -EBUSY; 474 - 475 - dr->bRequestType = MCS_RD_RTYPE; 476 - dr->bRequest = MCS_RDREQ; 477 - dr->wValue = cpu_to_le16(Wval); /* 0 */ 478 - dr->wIndex = cpu_to_le16(reg); 479 - dr->wLength = cpu_to_le16(2); 480 - 481 - usb_fill_control_urb(mcs->control_urb, dev, usb_rcvctrlpipe(dev, 0), 482 - (unsigned char *)dr, buffer, 2, 483 - mos7840_control_callback, mcs); 484 - mcs->control_urb->transfer_buffer_length = 2; 485 - ret = usb_submit_urb(mcs->control_urb, GFP_ATOMIC); 486 - if (ret) 487 - clear_bit_unlock(MOS7840_FLAG_CTRL_BUSY, &mcs->flags); 488 - 489 - return ret; 490 - } 491 367 492 368 static void mos7840_set_led_callback(struct urb *urb) 493 369 { ··· 426 580 } 427 581 428 582 /***************************************************************************** 429 - * mos7840_interrupt_callback 430 - * this is the callback function for when we have received data on the 431 - * interrupt endpoint. 432 - *****************************************************************************/ 433 - 434 - static void mos7840_interrupt_callback(struct urb *urb) 435 - { 436 - int result; 437 - int length; 438 - struct moschip_port *mos7840_port; 439 - struct usb_serial *serial; 440 - __u16 Data; 441 - unsigned char *data; 442 - __u8 sp[5]; 443 - int i, rv = 0; 444 - __u16 wval, wreg = 0; 445 - int status = urb->status; 446 - 447 - switch (status) { 448 - case 0: 449 - /* success */ 450 - break; 451 - case -ECONNRESET: 452 - case -ENOENT: 453 - case -ESHUTDOWN: 454 - /* this urb is terminated, clean up */ 455 - dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", 456 - __func__, status); 457 - return; 458 - default: 459 - dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n", 460 - __func__, status); 461 - goto exit; 462 - } 463 - 464 - length = urb->actual_length; 465 - data = urb->transfer_buffer; 466 - 467 - serial = urb->context; 468 - 469 - /* Moschip get 5 bytes 470 - * Byte 1 IIR Port 1 (port.number is 0) 471 - * Byte 2 IIR Port 2 (port.number is 1) 472 - * Byte 3 IIR Port 3 (port.number is 2) 473 - * Byte 4 IIR Port 4 (port.number is 3) 474 - * Byte 5 FIFO status for both */ 475 - 476 - if (length > 5) { 477 - dev_dbg(&urb->dev->dev, "%s", "Wrong data !!!\n"); 478 - return; 479 - } 480 - 481 - sp[0] = (__u8) data[0]; 482 - sp[1] = (__u8) data[1]; 483 - sp[2] = (__u8) data[2]; 484 - sp[3] = (__u8) data[3]; 485 - 486 - for (i = 0; i < serial->num_ports; i++) { 487 - mos7840_port = mos7840_get_port_private(serial->port[i]); 488 - wval = ((__u16)serial->port[i]->port_number + 1) << 8; 489 - if (mos7840_port->open) { 490 - if (sp[i] & 0x01) { 491 - dev_dbg(&urb->dev->dev, "SP%d No Interrupt !!!\n", i); 492 - } else { 493 - switch (sp[i] & 0x0f) { 494 - case SERIAL_IIR_RLS: 495 - dev_dbg(&urb->dev->dev, "Serial Port %d: Receiver status error or \n", i); 496 - dev_dbg(&urb->dev->dev, "address bit detected in 9-bit mode\n"); 497 - mos7840_port->MsrLsr = 1; 498 - wreg = LINE_STATUS_REGISTER; 499 - break; 500 - case SERIAL_IIR_MS: 501 - dev_dbg(&urb->dev->dev, "Serial Port %d: Modem status change\n", i); 502 - mos7840_port->MsrLsr = 0; 503 - wreg = MODEM_STATUS_REGISTER; 504 - break; 505 - } 506 - rv = mos7840_get_reg(mos7840_port, wval, wreg, &Data); 507 - } 508 - } 509 - } 510 - if (!(rv < 0)) 511 - /* the completion handler for the control urb will resubmit */ 512 - return; 513 - exit: 514 - result = usb_submit_urb(urb, GFP_ATOMIC); 515 - if (result) { 516 - dev_err(&urb->dev->dev, 517 - "%s - Error %d submitting interrupt urb\n", 518 - __func__, result); 519 - } 520 - } 521 - 522 - static int mos7840_port_paranoia_check(struct usb_serial_port *port, 523 - const char *function) 524 - { 525 - if (!port) { 526 - pr_debug("%s - port == NULL\n", function); 527 - return -1; 528 - } 529 - if (!port->serial) { 530 - pr_debug("%s - port->serial == NULL\n", function); 531 - return -1; 532 - } 533 - 534 - return 0; 535 - } 536 - 537 - /* Inline functions to check the sanity of a pointer that is passed to us */ 538 - static int mos7840_serial_paranoia_check(struct usb_serial *serial, 539 - const char *function) 540 - { 541 - if (!serial) { 542 - pr_debug("%s - serial == NULL\n", function); 543 - return -1; 544 - } 545 - if (!serial->type) { 546 - pr_debug("%s - serial->type == NULL!\n", function); 547 - return -1; 548 - } 549 - 550 - return 0; 551 - } 552 - 553 - static struct usb_serial *mos7840_get_usb_serial(struct usb_serial_port *port, 554 - const char *function) 555 - { 556 - /* if no port was specified, or it fails a paranoia check */ 557 - if (!port || 558 - mos7840_port_paranoia_check(port, function) || 559 - mos7840_serial_paranoia_check(port->serial, function)) { 560 - /* then say that we don't have a valid usb_serial thing, 561 - * which will end up genrating -ENODEV return values */ 562 - return NULL; 563 - } 564 - 565 - return port->serial; 566 - } 567 - 568 - /***************************************************************************** 569 583 * mos7840_bulk_in_callback 570 584 * this is the callback function for when we have received data on the 571 585 * bulk in endpoint. ··· 433 727 434 728 static void mos7840_bulk_in_callback(struct urb *urb) 435 729 { 730 + struct moschip_port *mos7840_port = urb->context; 731 + struct usb_serial_port *port = mos7840_port->port; 436 732 int retval; 437 733 unsigned char *data; 438 - struct usb_serial *serial; 439 - struct usb_serial_port *port; 440 - struct moschip_port *mos7840_port; 441 734 int status = urb->status; 442 - 443 - mos7840_port = urb->context; 444 - if (!mos7840_port) 445 - return; 446 735 447 736 if (status) { 448 737 dev_dbg(&urb->dev->dev, "nonzero read bulk status received: %d\n", status); 449 - mos7840_port->read_urb_busy = false; 450 - return; 451 - } 452 - 453 - port = mos7840_port->port; 454 - if (mos7840_port_paranoia_check(port, __func__)) { 455 - mos7840_port->read_urb_busy = false; 456 - return; 457 - } 458 - 459 - serial = mos7840_get_usb_serial(port, __func__); 460 - if (!serial) { 461 738 mos7840_port->read_urb_busy = false; 462 739 return; 463 740 } ··· 454 765 tty_flip_buffer_push(tport); 455 766 port->icount.rx += urb->actual_length; 456 767 dev_dbg(&port->dev, "icount.rx is %d:\n", port->icount.rx); 457 - } 458 - 459 - if (!mos7840_port->read_urb) { 460 - dev_dbg(&port->dev, "%s", "URB KILLED !!!\n"); 461 - mos7840_port->read_urb_busy = false; 462 - return; 463 768 } 464 769 465 770 if (mos7840_port->has_led) ··· 476 793 477 794 static void mos7840_bulk_out_data_callback(struct urb *urb) 478 795 { 479 - struct moschip_port *mos7840_port; 480 - struct usb_serial_port *port; 796 + struct moschip_port *mos7840_port = urb->context; 797 + struct usb_serial_port *port = mos7840_port->port; 481 798 int status = urb->status; 482 799 unsigned long flags; 483 800 int i; 484 801 485 - mos7840_port = urb->context; 486 - port = mos7840_port->port; 487 802 spin_lock_irqsave(&mos7840_port->pool_lock, flags); 488 803 for (i = 0; i < NUM_URBS; i++) { 489 804 if (urb == mos7840_port->write_urb_pool[i]) { ··· 496 815 return; 497 816 } 498 817 499 - if (mos7840_port_paranoia_check(port, __func__)) 500 - return; 501 - 502 - if (mos7840_port->open) 503 - tty_port_tty_wakeup(&port->port); 818 + tty_port_tty_wakeup(&port->port); 504 819 505 820 } 506 821 ··· 513 836 514 837 static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) 515 838 { 839 + struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 840 + struct usb_serial *serial = port->serial; 516 841 int response; 517 842 int j; 518 - struct usb_serial *serial; 519 843 struct urb *urb; 520 844 __u16 Data; 521 845 int status; 522 - struct moschip_port *mos7840_port; 523 - struct moschip_port *port0; 524 - 525 - if (mos7840_port_paranoia_check(port, __func__)) 526 - return -ENODEV; 527 - 528 - serial = port->serial; 529 - 530 - if (mos7840_serial_paranoia_check(serial, __func__)) 531 - return -ENODEV; 532 - 533 - mos7840_port = mos7840_get_port_private(port); 534 - port0 = mos7840_get_port_private(serial->port[0]); 535 - 536 - if (mos7840_port == NULL || port0 == NULL) 537 - return -ENODEV; 538 846 539 847 usb_clear_halt(serial->dev, port->write_urb->pipe); 540 848 usb_clear_halt(serial->dev, port->read_urb->pipe); 541 - port0->open_ports++; 542 849 543 850 /* Initialising the write urb pool */ 544 851 for (j = 0; j < NUM_URBS; ++j) { ··· 673 1012 status = mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, 674 1013 Data); 675 1014 676 - /* Check to see if we've set up our endpoint info yet * 677 - * (can't set it up in mos7840_startup as the structures * 678 - * were not set up at that time.) */ 679 - if (port0->open_ports == 1) { 680 - /* FIXME: Buffer never NULL, so URB is not submitted. */ 681 - if (serial->port[0]->interrupt_in_buffer == NULL) { 682 - /* set up interrupt urb */ 683 - usb_fill_int_urb(serial->port[0]->interrupt_in_urb, 684 - serial->dev, 685 - usb_rcvintpipe(serial->dev, 686 - serial->port[0]->interrupt_in_endpointAddress), 687 - serial->port[0]->interrupt_in_buffer, 688 - serial->port[0]->interrupt_in_urb-> 689 - transfer_buffer_length, 690 - mos7840_interrupt_callback, 691 - serial, 692 - serial->port[0]->interrupt_in_urb->interval); 693 - 694 - /* start interrupt read for mos7840 */ 695 - response = 696 - usb_submit_urb(serial->port[0]->interrupt_in_urb, 697 - GFP_KERNEL); 698 - if (response) { 699 - dev_err(&port->dev, "%s - Error %d submitting " 700 - "interrupt urb\n", __func__, response); 701 - } 702 - 703 - } 704 - 705 - } 706 - 707 - /* see if we've set up our endpoint info yet * 708 - * (can't set it up in mos7840_startup as the * 709 - * structures were not set up at that time.) */ 710 - 711 1015 dev_dbg(&port->dev, "port number is %d\n", port->port_number); 712 1016 dev_dbg(&port->dev, "minor number is %d\n", port->minor); 713 1017 dev_dbg(&port->dev, "Bulkin endpoint is %d\n", port->bulk_in_endpointAddress); ··· 712 1086 /* initialize our port settings */ 713 1087 /* Must set to enable ints! */ 714 1088 mos7840_port->shadowMCR = MCR_MASTER_IE; 715 - /* send a open port command */ 716 - mos7840_port->open = 1; 717 - /* mos7840_change_port_settings(mos7840_port,old_termios); */ 718 1089 719 1090 return 0; 720 1091 err: ··· 738 1115 static int mos7840_chars_in_buffer(struct tty_struct *tty) 739 1116 { 740 1117 struct usb_serial_port *port = tty->driver_data; 1118 + struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 741 1119 int i; 742 1120 int chars = 0; 743 1121 unsigned long flags; 744 - struct moschip_port *mos7840_port; 745 - 746 - if (mos7840_port_paranoia_check(port, __func__)) 747 - return 0; 748 - 749 - mos7840_port = mos7840_get_port_private(port); 750 - if (mos7840_port == NULL) 751 - return 0; 752 1122 753 1123 spin_lock_irqsave(&mos7840_port->pool_lock, flags); 754 1124 for (i = 0; i < NUM_URBS; ++i) { ··· 763 1147 764 1148 static void mos7840_close(struct usb_serial_port *port) 765 1149 { 766 - struct usb_serial *serial; 767 - struct moschip_port *mos7840_port; 768 - struct moschip_port *port0; 1150 + struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 769 1151 int j; 770 1152 __u16 Data; 771 - 772 - if (mos7840_port_paranoia_check(port, __func__)) 773 - return; 774 - 775 - serial = mos7840_get_usb_serial(port, __func__); 776 - if (!serial) 777 - return; 778 - 779 - mos7840_port = mos7840_get_port_private(port); 780 - port0 = mos7840_get_port_private(serial->port[0]); 781 - 782 - if (mos7840_port == NULL || port0 == NULL) 783 - return; 784 1153 785 1154 for (j = 0; j < NUM_URBS; ++j) 786 1155 usb_kill_urb(mos7840_port->write_urb_pool[j]); ··· 781 1180 usb_kill_urb(mos7840_port->read_urb); 782 1181 mos7840_port->read_urb_busy = false; 783 1182 784 - port0->open_ports--; 785 - dev_dbg(&port->dev, "%s in close%d\n", __func__, port0->open_ports); 786 - if (port0->open_ports == 0) { 787 - if (serial->port[0]->interrupt_in_urb) { 788 - dev_dbg(&port->dev, "Shutdown interrupt_in_urb\n"); 789 - usb_kill_urb(serial->port[0]->interrupt_in_urb); 790 - } 791 - } 792 - 793 1183 Data = 0x0; 794 1184 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data); 795 1185 796 1186 Data = 0x00; 797 1187 mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data); 798 - 799 - mos7840_port->open = 0; 800 1188 } 801 1189 802 1190 /***************************************************************************** ··· 795 1205 static void mos7840_break(struct tty_struct *tty, int break_state) 796 1206 { 797 1207 struct usb_serial_port *port = tty->driver_data; 1208 + struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 798 1209 unsigned char data; 799 - struct usb_serial *serial; 800 - struct moschip_port *mos7840_port; 801 - 802 - if (mos7840_port_paranoia_check(port, __func__)) 803 - return; 804 - 805 - serial = mos7840_get_usb_serial(port, __func__); 806 - if (!serial) 807 - return; 808 - 809 - mos7840_port = mos7840_get_port_private(port); 810 - 811 - if (mos7840_port == NULL) 812 - return; 813 1210 814 1211 if (break_state == -1) 815 1212 data = mos7840_port->shadowLCR | LCR_SET_BREAK; ··· 821 1244 static int mos7840_write_room(struct tty_struct *tty) 822 1245 { 823 1246 struct usb_serial_port *port = tty->driver_data; 1247 + struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 824 1248 int i; 825 1249 int room = 0; 826 1250 unsigned long flags; 827 - struct moschip_port *mos7840_port; 828 - 829 - if (mos7840_port_paranoia_check(port, __func__)) 830 - return -1; 831 - 832 - mos7840_port = mos7840_get_port_private(port); 833 - if (mos7840_port == NULL) 834 - return -1; 835 1251 836 1252 spin_lock_irqsave(&mos7840_port->pool_lock, flags); 837 1253 for (i = 0; i < NUM_URBS; ++i) { ··· 850 1280 static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, 851 1281 const unsigned char *data, int count) 852 1282 { 1283 + struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 1284 + struct usb_serial *serial = port->serial; 853 1285 int status; 854 1286 int i; 855 1287 int bytes_sent = 0; 856 1288 int transfer_size; 857 1289 unsigned long flags; 858 - 859 - struct moschip_port *mos7840_port; 860 - struct usb_serial *serial; 861 1290 struct urb *urb; 862 1291 /* __u16 Data; */ 863 1292 const unsigned char *current_position = data; 864 - 865 - if (mos7840_port_paranoia_check(port, __func__)) 866 - return -1; 867 - 868 - serial = port->serial; 869 - if (mos7840_serial_paranoia_check(serial, __func__)) 870 - return -1; 871 - 872 - mos7840_port = mos7840_get_port_private(port); 873 - if (mos7840_port == NULL) 874 - return -1; 875 1293 876 1294 /* try to find a free urb in the list */ 877 1295 urb = NULL; ··· 941 1383 static void mos7840_throttle(struct tty_struct *tty) 942 1384 { 943 1385 struct usb_serial_port *port = tty->driver_data; 944 - struct moschip_port *mos7840_port; 1386 + struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 945 1387 int status; 946 - 947 - if (mos7840_port_paranoia_check(port, __func__)) 948 - return; 949 - 950 - mos7840_port = mos7840_get_port_private(port); 951 - 952 - if (mos7840_port == NULL) 953 - return; 954 - 955 - if (!mos7840_port->open) { 956 - dev_dbg(&port->dev, "%s", "port not opened\n"); 957 - return; 958 - } 959 1388 960 1389 /* if we are implementing XON/XOFF, send the stop character */ 961 1390 if (I_IXOFF(tty)) { ··· 970 1425 static void mos7840_unthrottle(struct tty_struct *tty) 971 1426 { 972 1427 struct usb_serial_port *port = tty->driver_data; 1428 + struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 973 1429 int status; 974 - struct moschip_port *mos7840_port = mos7840_get_port_private(port); 975 - 976 - if (mos7840_port_paranoia_check(port, __func__)) 977 - return; 978 - 979 - if (mos7840_port == NULL) 980 - return; 981 - 982 - if (!mos7840_port->open) { 983 - dev_dbg(&port->dev, "%s - port not opened\n", __func__); 984 - return; 985 - } 986 1430 987 1431 /* if we are implementing XON/XOFF, send the start character */ 988 1432 if (I_IXOFF(tty)) { ··· 994 1460 static int mos7840_tiocmget(struct tty_struct *tty) 995 1461 { 996 1462 struct usb_serial_port *port = tty->driver_data; 997 - struct moschip_port *mos7840_port; 998 1463 unsigned int result; 999 1464 __u16 msr; 1000 1465 __u16 mcr; 1001 1466 int status; 1002 - mos7840_port = mos7840_get_port_private(port); 1003 - 1004 - if (mos7840_port == NULL) 1005 - return -ENODEV; 1006 1467 1007 1468 status = mos7840_get_uart_reg(port, MODEM_STATUS_REGISTER, &msr); 1008 1469 if (status < 0) ··· 1022 1493 unsigned int set, unsigned int clear) 1023 1494 { 1024 1495 struct usb_serial_port *port = tty->driver_data; 1025 - struct moschip_port *mos7840_port; 1496 + struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 1026 1497 unsigned int mcr; 1027 1498 int status; 1028 - 1029 - mos7840_port = mos7840_get_port_private(port); 1030 - 1031 - if (mos7840_port == NULL) 1032 - return -ENODEV; 1033 1499 1034 1500 /* FIXME: What locks the port registers ? */ 1035 1501 mcr = mos7840_port->shadowMCR; ··· 1102 1578 static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, 1103 1579 int baudRate) 1104 1580 { 1581 + struct usb_serial_port *port = mos7840_port->port; 1105 1582 int divisor = 0; 1106 1583 int status; 1107 1584 __u16 Data; 1108 1585 __u16 clk_sel_val; 1109 - struct usb_serial_port *port; 1110 - 1111 - if (mos7840_port == NULL) 1112 - return -1; 1113 - 1114 - port = mos7840_port->port; 1115 - if (mos7840_port_paranoia_check(port, __func__)) 1116 - return -1; 1117 - 1118 - if (mos7840_serial_paranoia_check(port->serial, __func__)) 1119 - return -1; 1120 1586 1121 1587 dev_dbg(&port->dev, "%s - baud = %d\n", __func__, baudRate); 1122 1588 /* reset clk_uart_sel in spregOffset */ ··· 1195 1681 static void mos7840_change_port_settings(struct tty_struct *tty, 1196 1682 struct moschip_port *mos7840_port, struct ktermios *old_termios) 1197 1683 { 1684 + struct usb_serial_port *port = mos7840_port->port; 1198 1685 int baud; 1199 1686 unsigned cflag; 1200 1687 __u8 lData; ··· 1203 1688 __u8 lStop; 1204 1689 int status; 1205 1690 __u16 Data; 1206 - struct usb_serial_port *port; 1207 - 1208 - if (mos7840_port == NULL) 1209 - return; 1210 - 1211 - port = mos7840_port->port; 1212 - 1213 - if (mos7840_port_paranoia_check(port, __func__)) 1214 - return; 1215 - 1216 - if (mos7840_serial_paranoia_check(port->serial, __func__)) 1217 - return; 1218 - 1219 - if (!mos7840_port->open) { 1220 - dev_dbg(&port->dev, "%s - port not opened\n", __func__); 1221 - return; 1222 - } 1223 1691 1224 1692 lData = LCR_BITS_8; 1225 1693 lStop = LCR_STOP_1; ··· 1337 1839 struct usb_serial_port *port, 1338 1840 struct ktermios *old_termios) 1339 1841 { 1842 + struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 1340 1843 int status; 1341 - struct usb_serial *serial; 1342 - struct moschip_port *mos7840_port; 1343 - 1344 - if (mos7840_port_paranoia_check(port, __func__)) 1345 - return; 1346 - 1347 - serial = port->serial; 1348 - 1349 - if (mos7840_serial_paranoia_check(serial, __func__)) 1350 - return; 1351 - 1352 - mos7840_port = mos7840_get_port_private(port); 1353 - 1354 - if (mos7840_port == NULL) 1355 - return; 1356 - 1357 - if (!mos7840_port->open) { 1358 - dev_dbg(&port->dev, "%s - port not opened\n", __func__); 1359 - return; 1360 - } 1361 1844 1362 1845 /* change the port settings to the new ones specified */ 1363 1846 1364 1847 mos7840_change_port_settings(tty, mos7840_port, old_termios); 1365 - 1366 - if (!mos7840_port->read_urb) { 1367 - dev_dbg(&port->dev, "%s", "URB KILLED !!!!!\n"); 1368 - return; 1369 - } 1370 1848 1371 1849 if (!mos7840_port->read_urb_busy) { 1372 1850 mos7840_port->read_urb_busy = true; ··· 1390 1916 struct serial_struct *ss) 1391 1917 { 1392 1918 struct usb_serial_port *port = tty->driver_data; 1393 - struct moschip_port *mos7840_port = mos7840_get_port_private(port); 1919 + struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 1394 1920 1395 1921 ss->type = PORT_16550A; 1396 1922 ss->line = mos7840_port->port->minor; ··· 1413 1939 { 1414 1940 struct usb_serial_port *port = tty->driver_data; 1415 1941 void __user *argp = (void __user *)arg; 1416 - struct moschip_port *mos7840_port; 1417 - 1418 - if (mos7840_port_paranoia_check(port, __func__)) 1419 - return -1; 1420 - 1421 - mos7840_port = mos7840_get_port_private(port); 1422 - 1423 - if (mos7840_port == NULL) 1424 - return -1; 1425 1942 1426 1943 switch (cmd) { 1427 1944 /* return number of bytes available */ ··· 1427 1962 return -ENOIOCTLCMD; 1428 1963 } 1429 1964 1965 + /* 1966 + * Check if GPO (pin 42) is connected to GPI (pin 33) as recommended by ASIX 1967 + * for MCS7810 by bit-banging a 16-bit word. 1968 + * 1969 + * Note that GPO is really RTS of the third port so this will toggle RTS of 1970 + * port two or three on two- and four-port devices. 1971 + */ 1430 1972 static int mos7810_check(struct usb_serial *serial) 1431 1973 { 1432 1974 int i, pass_count = 0; ··· 1491 2019 static int mos7840_probe(struct usb_serial *serial, 1492 2020 const struct usb_device_id *id) 1493 2021 { 1494 - u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); 2022 + unsigned long device_flags = id->driver_info; 1495 2023 u8 *buf; 1496 - int device_type; 1497 2024 1498 - if (product == MOSCHIP_DEVICE_ID_7810 || 1499 - product == MOSCHIP_DEVICE_ID_7820 || 1500 - product == MOSCHIP_DEVICE_ID_7843) { 1501 - device_type = product; 2025 + /* Skip device-type detection if we already have device flags. */ 2026 + if (device_flags) 1502 2027 goto out; 1503 - } 1504 2028 1505 2029 buf = kzalloc(VENDOR_READ_LENGTH, GFP_KERNEL); 1506 2030 if (!buf) ··· 1508 2040 1509 2041 /* For a MCS7840 device GPIO0 must be set to 1 */ 1510 2042 if (buf[0] & 0x01) 1511 - device_type = MOSCHIP_DEVICE_ID_7840; 2043 + device_flags = MCS_PORTS(4); 1512 2044 else if (mos7810_check(serial)) 1513 - device_type = MOSCHIP_DEVICE_ID_7810; 2045 + device_flags = MCS_PORTS(1) | MCS_LED; 1514 2046 else 1515 - device_type = MOSCHIP_DEVICE_ID_7820; 2047 + device_flags = MCS_PORTS(2); 1516 2048 1517 2049 kfree(buf); 1518 2050 out: 1519 - usb_set_serial_data(serial, (void *)(unsigned long)device_type); 2051 + usb_set_serial_data(serial, (void *)device_flags); 1520 2052 1521 2053 return 0; 1522 2054 } ··· 1524 2056 static int mos7840_calc_num_ports(struct usb_serial *serial, 1525 2057 struct usb_serial_endpoints *epds) 1526 2058 { 1527 - int device_type = (unsigned long)usb_get_serial_data(serial); 1528 - int num_ports; 2059 + unsigned long device_flags = (unsigned long)usb_get_serial_data(serial); 2060 + int num_ports = MCS_PORTS(device_flags); 1529 2061 1530 - if (device_type == MOSCHIP_DEVICE_ID_7843) 1531 - num_ports = 3; 1532 - else 1533 - num_ports = (device_type >> 4) & 0x000F; 1534 - 1535 - /* 1536 - * num_ports is currently never zero as device_type is one of 1537 - * MOSCHIP_DEVICE_ID_78{1,2,4}0. 1538 - */ 1539 - if (num_ports == 0) 2062 + if (num_ports == 0 || num_ports > 4) 1540 2063 return -ENODEV; 1541 2064 1542 2065 if (epds->num_bulk_in < num_ports || epds->num_bulk_out < num_ports) { ··· 1538 2079 return num_ports; 1539 2080 } 1540 2081 2082 + static int mos7840_attach(struct usb_serial *serial) 2083 + { 2084 + struct device *dev = &serial->interface->dev; 2085 + int status; 2086 + u16 val; 2087 + 2088 + /* Zero Length flag enable */ 2089 + val = 0x0f; 2090 + status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, val); 2091 + if (status < 0) 2092 + dev_dbg(dev, "Writing ZLP_REG5 failed status-0x%x\n", status); 2093 + else 2094 + dev_dbg(dev, "ZLP_REG5 Writing success status%d\n", status); 2095 + 2096 + return status; 2097 + } 2098 + 1541 2099 static int mos7840_port_probe(struct usb_serial_port *port) 1542 2100 { 1543 2101 struct usb_serial *serial = port->serial; 1544 - int device_type = (unsigned long)usb_get_serial_data(serial); 2102 + unsigned long device_flags = (unsigned long)usb_get_serial_data(serial); 1545 2103 struct moschip_port *mos7840_port; 1546 2104 int status; 1547 2105 int pnum; ··· 1579 2103 * common to all port */ 1580 2104 1581 2105 mos7840_port->port = port; 1582 - mos7840_set_port_private(port, mos7840_port); 1583 2106 spin_lock_init(&mos7840_port->pool_lock); 1584 2107 1585 2108 /* minor is not initialised until later by ··· 1604 2129 mos7840_port->DcrRegOffset = 0x16 + 3 * (phy_num - 2); 1605 2130 } 1606 2131 mos7840_dump_serial_port(port, mos7840_port); 1607 - mos7840_set_port_private(port, mos7840_port); 2132 + usb_set_serial_port_data(port, mos7840_port); 1608 2133 1609 2134 /* enable rx_disable bit in control register */ 1610 2135 status = mos7840_get_reg_sync(port, 1611 2136 mos7840_port->ControlRegOffset, &Data); 1612 2137 if (status < 0) { 1613 2138 dev_dbg(&port->dev, "Reading ControlReg failed status-0x%x\n", status); 1614 - goto out; 2139 + goto error; 1615 2140 } else 1616 2141 dev_dbg(&port->dev, "ControlReg Reading success val is %x, status%d\n", Data, status); 1617 2142 Data |= 0x08; /* setting driver done bit */ ··· 1623 2148 mos7840_port->ControlRegOffset, Data); 1624 2149 if (status < 0) { 1625 2150 dev_dbg(&port->dev, "Writing ControlReg failed(rx_disable) status-0x%x\n", status); 1626 - goto out; 2151 + goto error; 1627 2152 } else 1628 2153 dev_dbg(&port->dev, "ControlReg Writing success(rx_disable) status%d\n", status); 1629 2154 ··· 1634 2159 (__u16) (mos7840_port->DcrRegOffset + 0), Data); 1635 2160 if (status < 0) { 1636 2161 dev_dbg(&port->dev, "Writing DCR0 failed status-0x%x\n", status); 1637 - goto out; 2162 + goto error; 1638 2163 } else 1639 2164 dev_dbg(&port->dev, "DCR0 Writing success status%d\n", status); 1640 2165 ··· 1643 2168 (__u16) (mos7840_port->DcrRegOffset + 1), Data); 1644 2169 if (status < 0) { 1645 2170 dev_dbg(&port->dev, "Writing DCR1 failed status-0x%x\n", status); 1646 - goto out; 2171 + goto error; 1647 2172 } else 1648 2173 dev_dbg(&port->dev, "DCR1 Writing success status%d\n", status); 1649 2174 ··· 1652 2177 (__u16) (mos7840_port->DcrRegOffset + 2), Data); 1653 2178 if (status < 0) { 1654 2179 dev_dbg(&port->dev, "Writing DCR2 failed status-0x%x\n", status); 1655 - goto out; 2180 + goto error; 1656 2181 } else 1657 2182 dev_dbg(&port->dev, "DCR2 Writing success status%d\n", status); 1658 2183 ··· 1661 2186 status = mos7840_set_reg_sync(port, CLK_START_VALUE_REGISTER, Data); 1662 2187 if (status < 0) { 1663 2188 dev_dbg(&port->dev, "Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status); 1664 - goto out; 2189 + goto error; 1665 2190 } else 1666 2191 dev_dbg(&port->dev, "CLK_START_VALUE_REGISTER Writing success status%d\n", status); 1667 2192 ··· 1678 2203 status = mos7840_set_uart_reg(port, SCRATCH_PAD_REGISTER, Data); 1679 2204 if (status < 0) { 1680 2205 dev_dbg(&port->dev, "Writing SCRATCH_PAD_REGISTER failed status-0x%x\n", status); 1681 - goto out; 2206 + goto error; 1682 2207 } else 1683 2208 dev_dbg(&port->dev, "SCRATCH_PAD_REGISTER Writing success status%d\n", status); 1684 2209 ··· 1692 2217 (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num))); 1693 2218 if (status < 0) { 1694 2219 dev_dbg(&port->dev, "Writing ZLP_REG%d failed status-0x%x\n", pnum + 2, status); 1695 - goto out; 2220 + goto error; 1696 2221 } else 1697 2222 dev_dbg(&port->dev, "ZLP_REG%d Writing success status%d\n", pnum + 2, status); 1698 2223 } else { ··· 1704 2229 (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num) - 0x1)); 1705 2230 if (status < 0) { 1706 2231 dev_dbg(&port->dev, "Writing ZLP_REG%d failed status-0x%x\n", pnum + 1, status); 1707 - goto out; 2232 + goto error; 1708 2233 } else 1709 2234 dev_dbg(&port->dev, "ZLP_REG%d Writing success status%d\n", pnum + 1, status); 1710 2235 1711 2236 } 1712 - mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL); 1713 - mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL); 1714 - mos7840_port->dr = kmalloc(sizeof(struct usb_ctrlrequest), 1715 - GFP_KERNEL); 1716 - if (!mos7840_port->control_urb || !mos7840_port->ctrl_buf || 1717 - !mos7840_port->dr) { 1718 - status = -ENOMEM; 1719 - goto error; 1720 - } 1721 2237 1722 - mos7840_port->has_led = false; 2238 + mos7840_port->has_led = device_flags & MCS_LED; 1723 2239 1724 2240 /* Initialize LED timers */ 1725 - if (device_type == MOSCHIP_DEVICE_ID_7810) { 1726 - mos7840_port->has_led = true; 1727 - 2241 + if (mos7840_port->has_led) { 1728 2242 mos7840_port->led_urb = usb_alloc_urb(0, GFP_KERNEL); 1729 2243 mos7840_port->led_dr = kmalloc(sizeof(*mos7840_port->led_dr), 1730 2244 GFP_KERNEL); ··· 1733 2269 /* Turn off LED */ 1734 2270 mos7840_set_led_sync(port, MODEM_CONTROL_REGISTER, 0x0300); 1735 2271 } 1736 - out: 1737 - if (pnum == serial->num_ports - 1) { 1738 - /* Zero Length flag enable */ 1739 - Data = 0x0f; 1740 - status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); 1741 - if (status < 0) { 1742 - dev_dbg(&port->dev, "Writing ZLP_REG5 failed status-0x%x\n", status); 1743 - goto error; 1744 - } else 1745 - dev_dbg(&port->dev, "ZLP_REG5 Writing success status%d\n", status); 1746 2272 1747 - /* setting configuration feature to one */ 1748 - usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 1749 - 0x03, 0x00, 0x01, 0x00, NULL, 0x00, 1750 - MOS_WDR_TIMEOUT); 1751 - } 1752 2273 return 0; 1753 2274 error: 1754 2275 kfree(mos7840_port->led_dr); 1755 2276 usb_free_urb(mos7840_port->led_urb); 1756 - kfree(mos7840_port->dr); 1757 - kfree(mos7840_port->ctrl_buf); 1758 - usb_free_urb(mos7840_port->control_urb); 1759 2277 kfree(mos7840_port); 1760 2278 1761 2279 return status; ··· 1745 2299 1746 2300 static int mos7840_port_remove(struct usb_serial_port *port) 1747 2301 { 1748 - struct moschip_port *mos7840_port; 1749 - 1750 - mos7840_port = mos7840_get_port_private(port); 2302 + struct moschip_port *mos7840_port = usb_get_serial_port_data(port); 1751 2303 1752 2304 if (mos7840_port->has_led) { 1753 2305 /* Turn off LED */ ··· 1758 2314 usb_free_urb(mos7840_port->led_urb); 1759 2315 kfree(mos7840_port->led_dr); 1760 2316 } 1761 - usb_kill_urb(mos7840_port->control_urb); 1762 - usb_free_urb(mos7840_port->control_urb); 1763 - kfree(mos7840_port->ctrl_buf); 1764 - kfree(mos7840_port->dr); 2317 + 1765 2318 kfree(mos7840_port); 1766 2319 1767 2320 return 0; ··· 1781 2340 .unthrottle = mos7840_unthrottle, 1782 2341 .calc_num_ports = mos7840_calc_num_ports, 1783 2342 .probe = mos7840_probe, 2343 + .attach = mos7840_attach, 1784 2344 .ioctl = mos7840_ioctl, 1785 2345 .get_serial = mos7840_get_serial_info, 1786 2346 .set_termios = mos7840_set_termios, 1787 2347 .break_ctl = mos7840_break, 1788 2348 .tiocmget = mos7840_tiocmget, 1789 2349 .tiocmset = mos7840_tiocmset, 1790 - .tiocmiwait = usb_serial_generic_tiocmiwait, 1791 2350 .get_icount = usb_serial_generic_get_icount, 1792 2351 .port_probe = mos7840_port_probe, 1793 2352 .port_remove = mos7840_port_remove, 1794 2353 .read_bulk_callback = mos7840_bulk_in_callback, 1795 - .read_int_callback = mos7840_interrupt_callback, 1796 2354 }; 1797 2355 1798 2356 static struct usb_serial_driver * const serial_drivers[] = {
+7
drivers/usb/serial/option.c
··· 197 197 #define DELL_PRODUCT_5804_MINICARD_ATT 0x819b /* Novatel E371 */ 198 198 199 199 #define DELL_PRODUCT_5821E 0x81d7 200 + #define DELL_PRODUCT_5821E_ESIM 0x81e0 200 201 201 202 #define KYOCERA_VENDOR_ID 0x0c88 202 203 #define KYOCERA_PRODUCT_KPC650 0x17da ··· 1044 1043 { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5800_V2_MINICARD_VZW, 0xff, 0xff, 0xff) }, 1045 1044 { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5804_MINICARD_ATT, 0xff, 0xff, 0xff) }, 1046 1045 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5821E), 1046 + .driver_info = RSVD(0) | RSVD(1) | RSVD(6) }, 1047 + { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5821E_ESIM), 1047 1048 .driver_info = RSVD(0) | RSVD(1) | RSVD(6) }, 1048 1049 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */ 1049 1050 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, ··· 1993 1990 { USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0xa31d, 0xff, 0x06, 0x13) }, 1994 1991 { USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0xa31d, 0xff, 0x06, 0x14) }, 1995 1992 { USB_DEVICE_AND_INTERFACE_INFO(0x03f0, 0xa31d, 0xff, 0x06, 0x1b) }, 1993 + { USB_DEVICE(0x0489, 0xe0b4), /* Foxconn T77W968 */ 1994 + .driver_info = RSVD(0) | RSVD(1) | RSVD(6) }, 1995 + { USB_DEVICE(0x0489, 0xe0b5), /* Foxconn T77W968 ESIM */ 1996 + .driver_info = RSVD(0) | RSVD(1) | RSVD(6) }, 1996 1997 { USB_DEVICE(0x1508, 0x1001), /* Fibocom NL668 */ 1997 1998 .driver_info = RSVD(4) | RSVD(5) | RSVD(6) }, 1998 1999 { USB_DEVICE(0x2cb7, 0x0104), /* Fibocom NL678 series */
+101 -23
drivers/usb/serial/pl2303.c
··· 47 47 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_MOTOROLA) }, 48 48 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ZTEK) }, 49 49 { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_TB) }, 50 + { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GC) }, 51 + { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GB) }, 52 + { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GT) }, 53 + { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GL) }, 54 + { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GE) }, 55 + { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_GS) }, 50 56 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) }, 51 57 { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) }, 52 58 { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID), ··· 136 130 137 131 #define VENDOR_WRITE_REQUEST_TYPE 0x40 138 132 #define VENDOR_WRITE_REQUEST 0x01 133 + #define VENDOR_WRITE_NREQUEST 0x80 139 134 140 135 #define VENDOR_READ_REQUEST_TYPE 0xc0 141 136 #define VENDOR_READ_REQUEST 0x01 137 + #define VENDOR_READ_NREQUEST 0x81 142 138 143 139 #define UART_STATE_INDEX 8 144 140 #define UART_STATE_MSR_MASK 0x8b ··· 156 148 157 149 #define PL2303_FLOWCTRL_MASK 0xf0 158 150 151 + #define PL2303_READ_TYPE_HX_STATUS 0x8080 152 + 153 + #define PL2303_HXN_RESET_REG 0x07 154 + #define PL2303_HXN_RESET_UPSTREAM_PIPE 0x02 155 + #define PL2303_HXN_RESET_DOWNSTREAM_PIPE 0x01 156 + 157 + #define PL2303_HXN_FLOWCTRL_REG 0x0a 158 + #define PL2303_HXN_FLOWCTRL_MASK 0x1c 159 + #define PL2303_HXN_FLOWCTRL_NONE 0x1c 160 + #define PL2303_HXN_FLOWCTRL_RTS_CTS 0x18 161 + #define PL2303_HXN_FLOWCTRL_XON_XOFF 0x0c 162 + 159 163 static void pl2303_set_break(struct usb_serial_port *port, bool enable); 160 164 161 165 enum pl2303_type { 162 166 TYPE_01, /* Type 0 and 1 (difference unknown) */ 163 167 TYPE_HX, /* HX version of the pl2303 chip */ 168 + TYPE_HXN, /* HXN version of the pl2303 chip */ 164 169 TYPE_COUNT 165 170 }; 166 171 ··· 205 184 [TYPE_HX] = { 206 185 .max_baud_rate = 12000000, 207 186 }, 187 + [TYPE_HXN] = { 188 + .max_baud_rate = 12000000, 189 + }, 208 190 }; 209 191 210 192 static int pl2303_vendor_read(struct usb_serial *serial, u16 value, 211 193 unsigned char buf[1]) 212 194 { 195 + struct pl2303_serial_private *spriv = usb_get_serial_data(serial); 213 196 struct device *dev = &serial->interface->dev; 197 + u8 request; 214 198 int res; 215 199 200 + if (spriv->type == &pl2303_type_data[TYPE_HXN]) 201 + request = VENDOR_READ_NREQUEST; 202 + else 203 + request = VENDOR_READ_REQUEST; 204 + 216 205 res = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 217 - VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE, 206 + request, VENDOR_READ_REQUEST_TYPE, 218 207 value, 0, buf, 1, 100); 219 208 if (res != 1) { 220 209 dev_err(dev, "%s - failed to read [%04x]: %d\n", __func__, ··· 242 211 243 212 static int pl2303_vendor_write(struct usb_serial *serial, u16 value, u16 index) 244 213 { 214 + struct pl2303_serial_private *spriv = usb_get_serial_data(serial); 245 215 struct device *dev = &serial->interface->dev; 216 + u8 request; 246 217 int res; 247 218 248 219 dev_dbg(dev, "%s - [%04x] = %02x\n", __func__, value, index); 249 220 221 + if (spriv->type == &pl2303_type_data[TYPE_HXN]) 222 + request = VENDOR_WRITE_NREQUEST; 223 + else 224 + request = VENDOR_WRITE_REQUEST; 225 + 250 226 res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 251 - VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE, 227 + request, VENDOR_WRITE_REQUEST_TYPE, 252 228 value, index, NULL, 0, 100); 253 229 if (res) { 254 230 dev_err(dev, "%s - failed to write [%04x]: %d\n", __func__, ··· 268 230 269 231 static int pl2303_update_reg(struct usb_serial *serial, u8 reg, u8 mask, u8 val) 270 232 { 233 + struct pl2303_serial_private *spriv = usb_get_serial_data(serial); 271 234 int ret = 0; 272 235 u8 *buf; 273 236 ··· 276 237 if (!buf) 277 238 return -ENOMEM; 278 239 279 - ret = pl2303_vendor_read(serial, reg | 0x80, buf); 240 + if (spriv->type == &pl2303_type_data[TYPE_HXN]) 241 + ret = pl2303_vendor_read(serial, reg, buf); 242 + else 243 + ret = pl2303_vendor_read(serial, reg | 0x80, buf); 244 + 280 245 if (ret) 281 246 goto out_free; 282 247 ··· 363 320 struct pl2303_serial_private *spriv; 364 321 enum pl2303_type type = TYPE_01; 365 322 unsigned char *buf; 323 + int res; 366 324 367 325 spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); 368 326 if (!spriv) ··· 385 341 type = TYPE_01; /* type 1 */ 386 342 dev_dbg(&serial->interface->dev, "device type: %d\n", type); 387 343 344 + if (type == TYPE_HX) { 345 + res = usb_control_msg(serial->dev, 346 + usb_rcvctrlpipe(serial->dev, 0), 347 + VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE, 348 + PL2303_READ_TYPE_HX_STATUS, 0, buf, 1, 100); 349 + if (res != 1) 350 + type = TYPE_HXN; 351 + } 352 + 388 353 spriv->type = &pl2303_type_data[type]; 389 354 spriv->quirks = (unsigned long)usb_get_serial_data(serial); 390 355 spriv->quirks |= spriv->type->quirks; 391 356 392 357 usb_set_serial_data(serial, spriv); 393 358 394 - pl2303_vendor_read(serial, 0x8484, buf); 395 - pl2303_vendor_write(serial, 0x0404, 0); 396 - pl2303_vendor_read(serial, 0x8484, buf); 397 - pl2303_vendor_read(serial, 0x8383, buf); 398 - pl2303_vendor_read(serial, 0x8484, buf); 399 - pl2303_vendor_write(serial, 0x0404, 1); 400 - pl2303_vendor_read(serial, 0x8484, buf); 401 - pl2303_vendor_read(serial, 0x8383, buf); 402 - pl2303_vendor_write(serial, 0, 1); 403 - pl2303_vendor_write(serial, 1, 0); 404 - if (spriv->quirks & PL2303_QUIRK_LEGACY) 405 - pl2303_vendor_write(serial, 2, 0x24); 406 - else 407 - pl2303_vendor_write(serial, 2, 0x44); 359 + if (type != TYPE_HXN) { 360 + pl2303_vendor_read(serial, 0x8484, buf); 361 + pl2303_vendor_write(serial, 0x0404, 0); 362 + pl2303_vendor_read(serial, 0x8484, buf); 363 + pl2303_vendor_read(serial, 0x8383, buf); 364 + pl2303_vendor_read(serial, 0x8484, buf); 365 + pl2303_vendor_write(serial, 0x0404, 1); 366 + pl2303_vendor_read(serial, 0x8484, buf); 367 + pl2303_vendor_read(serial, 0x8383, buf); 368 + pl2303_vendor_write(serial, 0, 1); 369 + pl2303_vendor_write(serial, 1, 0); 370 + if (spriv->quirks & PL2303_QUIRK_LEGACY) 371 + pl2303_vendor_write(serial, 2, 0x24); 372 + else 373 + pl2303_vendor_write(serial, 2, 0x44); 374 + } 408 375 409 376 kfree(buf); 410 377 ··· 774 719 } 775 720 776 721 if (C_CRTSCTS(tty)) { 777 - if (spriv->quirks & PL2303_QUIRK_LEGACY) 722 + if (spriv->quirks & PL2303_QUIRK_LEGACY) { 778 723 pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0x40); 779 - else 724 + } else if (spriv->type == &pl2303_type_data[TYPE_HXN]) { 725 + pl2303_update_reg(serial, PL2303_HXN_FLOWCTRL_REG, 726 + PL2303_HXN_FLOWCTRL_MASK, 727 + PL2303_HXN_FLOWCTRL_RTS_CTS); 728 + } else { 780 729 pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0x60); 730 + } 781 731 } else if (pl2303_enable_xonxoff(tty, spriv->type)) { 782 - pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0xc0); 732 + if (spriv->type == &pl2303_type_data[TYPE_HXN]) { 733 + pl2303_update_reg(serial, PL2303_HXN_FLOWCTRL_REG, 734 + PL2303_HXN_FLOWCTRL_MASK, 735 + PL2303_HXN_FLOWCTRL_XON_XOFF); 736 + } else { 737 + pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0xc0); 738 + } 783 739 } else { 784 - pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0); 740 + if (spriv->type == &pl2303_type_data[TYPE_HXN]) { 741 + pl2303_update_reg(serial, PL2303_HXN_FLOWCTRL_REG, 742 + PL2303_HXN_FLOWCTRL_MASK, 743 + PL2303_HXN_FLOWCTRL_NONE); 744 + } else { 745 + pl2303_update_reg(serial, 0, PL2303_FLOWCTRL_MASK, 0); 746 + } 785 747 } 786 748 787 749 kfree(buf); ··· 839 767 usb_clear_halt(serial->dev, port->read_urb->pipe); 840 768 } else { 841 769 /* reset upstream data pipes */ 842 - pl2303_vendor_write(serial, 8, 0); 843 - pl2303_vendor_write(serial, 9, 0); 770 + if (spriv->type == &pl2303_type_data[TYPE_HXN]) { 771 + pl2303_vendor_write(serial, PL2303_HXN_RESET_REG, 772 + PL2303_HXN_RESET_UPSTREAM_PIPE | 773 + PL2303_HXN_RESET_DOWNSTREAM_PIPE); 774 + } else { 775 + pl2303_vendor_write(serial, 8, 0); 776 + pl2303_vendor_write(serial, 9, 0); 777 + } 844 778 } 845 779 846 780 /* Setup termios */
+6
drivers/usb/serial/pl2303.h
··· 9 9 #define PL2303_VENDOR_ID 0x067b 10 10 #define PL2303_PRODUCT_ID 0x2303 11 11 #define PL2303_PRODUCT_ID_TB 0x2304 12 + #define PL2303_PRODUCT_ID_GC 0x23a3 13 + #define PL2303_PRODUCT_ID_GB 0x23b3 14 + #define PL2303_PRODUCT_ID_GT 0x23c3 15 + #define PL2303_PRODUCT_ID_GL 0x23d3 16 + #define PL2303_PRODUCT_ID_GE 0x23e3 17 + #define PL2303_PRODUCT_ID_GS 0x23f3 12 18 #define PL2303_PRODUCT_ID_RSAQ2 0x04bb 13 19 #define PL2303_PRODUCT_ID_DCU11 0x1234 14 20 #define PL2303_PRODUCT_ID_PHAROS 0xaaa0