1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Copyright (C) 2009 by Bart Hartgers (bart.hartgers+ark3116@gmail.com) 4 * Original version: 5 * Copyright (C) 2006 6 * Simon Schulz (ark3116_driver <at> auctionant.de) 7 * 8 * ark3116 9 * - implements a driver for the arkmicro ark3116 chipset (vendor=0x6547, 10 * productid=0x0232) (used in a datacable called KQ-U8A) 11 * 12 * Supports full modem status lines, break, hardware flow control. Does not 13 * support software flow control, since I do not know how to enable it in hw. 14 * 15 * This driver is a essentially new implementation. I initially dug 16 * into the old ark3116.c driver and suddenly realized the ark3116 is 17 * a 16450 with a USB interface glued to it. See comments at the 18 * bottom of this file. 19 */ 20 21 #include <linux/kernel.h> 22 #include <linux/ioctl.h> 23 #include <linux/tty.h> 24 #include <linux/slab.h> 25 #include <linux/tty_flip.h> 26 #include <linux/module.h> 27 #include <linux/usb.h> 28 #include <linux/usb/serial.h> 29 #include <linux/serial.h> 30 #include <linux/serial_reg.h> 31 #include <linux/mutex.h> 32 #include <linux/spinlock.h> 33 34 #define DRIVER_AUTHOR "Bart Hartgers <bart.hartgers+ark3116@gmail.com>" 35 #define DRIVER_DESC "USB ARK3116 serial/IrDA driver" 36 #define DRIVER_DEV_DESC "ARK3116 RS232/IrDA" 37 #define DRIVER_NAME "ark3116" 38 39 /* usb timeout of 1 second */ 40 #define ARK_TIMEOUT 1000 41 42 static const struct usb_device_id id_table[] = { 43 { USB_DEVICE(0x6547, 0x0232) }, 44 { USB_DEVICE(0x18ec, 0x3118) }, /* USB to IrDA adapter */ 45 { }, 46 }; 47 MODULE_DEVICE_TABLE(usb, id_table); 48 49 static int is_irda(struct usb_serial *serial) 50 { 51 struct usb_device *dev = serial->dev; 52 if (le16_to_cpu(dev->descriptor.idVendor) == 0x18ec && 53 le16_to_cpu(dev->descriptor.idProduct) == 0x3118) 54 return 1; 55 return 0; 56 } 57 58 struct ark3116_private { 59 int irda; /* 1 for irda device */ 60 61 /* protects hw register updates */ 62 struct mutex hw_lock; 63 64 int quot; /* baudrate divisor */ 65 __u32 lcr; /* line control register value */ 66 __u32 hcr; /* handshake control register (0x8) 67 * value */ 68 __u32 mcr; /* modem control register value */ 69 70 /* protects the status values below */ 71 spinlock_t status_lock; 72 __u32 msr; /* modem status register value */ 73 __u32 lsr; /* line status register value */ 74 }; 75 76 static int ark3116_write_reg(struct usb_serial *serial, 77 unsigned reg, __u8 val) 78 { 79 int result; 80 /* 0xfe 0x40 are magic values taken from original driver */ 81 result = usb_control_msg(serial->dev, 82 usb_sndctrlpipe(serial->dev, 0), 83 0xfe, 0x40, val, reg, 84 NULL, 0, ARK_TIMEOUT); 85 if (result) 86 return result; 87 88 return 0; 89 } 90 91 static int ark3116_read_reg(struct usb_serial *serial, 92 unsigned reg, unsigned char *buf) 93 { 94 int result; 95 /* 0xfe 0xc0 are magic values taken from original driver */ 96 result = usb_control_msg(serial->dev, 97 usb_rcvctrlpipe(serial->dev, 0), 98 0xfe, 0xc0, 0, reg, 99 buf, 1, ARK_TIMEOUT); 100 if (result < 1) { 101 dev_err(&serial->interface->dev, 102 "failed to read register %u: %d\n", 103 reg, result); 104 if (result >= 0) 105 result = -EIO; 106 107 return result; 108 } 109 110 return 0; 111 } 112 113 static inline int calc_divisor(int bps) 114 { 115 /* Original ark3116 made some exceptions in rounding here 116 * because windows did the same. Assume that is not really 117 * necessary. 118 * Crystal is 12MHz, probably because of USB, but we divide by 4? 119 */ 120 return (12000000 + 2*bps) / (4*bps); 121 } 122 123 static int ark3116_port_probe(struct usb_serial_port *port) 124 { 125 struct usb_serial *serial = port->serial; 126 struct ark3116_private *priv; 127 128 priv = kzalloc_obj(*priv); 129 if (!priv) 130 return -ENOMEM; 131 132 mutex_init(&priv->hw_lock); 133 spin_lock_init(&priv->status_lock); 134 135 priv->irda = is_irda(serial); 136 137 usb_set_serial_port_data(port, priv); 138 139 /* setup the hardware */ 140 ark3116_write_reg(serial, UART_IER, 0); 141 /* disable DMA */ 142 ark3116_write_reg(serial, UART_FCR, 0); 143 /* handshake control */ 144 priv->hcr = 0; 145 ark3116_write_reg(serial, 0x8 , 0); 146 /* modem control */ 147 priv->mcr = 0; 148 ark3116_write_reg(serial, UART_MCR, 0); 149 150 if (!(priv->irda)) { 151 ark3116_write_reg(serial, 0xb , 0); 152 } else { 153 ark3116_write_reg(serial, 0xb , 1); 154 ark3116_write_reg(serial, 0xc , 0); 155 ark3116_write_reg(serial, 0xd , 0x41); 156 ark3116_write_reg(serial, 0xa , 1); 157 } 158 159 /* setup baudrate */ 160 ark3116_write_reg(serial, UART_LCR, UART_LCR_DLAB); 161 162 /* setup for 9600 8N1 */ 163 priv->quot = calc_divisor(9600); 164 ark3116_write_reg(serial, UART_DLL, priv->quot & 0xff); 165 ark3116_write_reg(serial, UART_DLM, (priv->quot>>8) & 0xff); 166 167 priv->lcr = UART_LCR_WLEN8; 168 ark3116_write_reg(serial, UART_LCR, UART_LCR_WLEN8); 169 170 ark3116_write_reg(serial, 0xe, 0); 171 172 if (priv->irda) 173 ark3116_write_reg(serial, 0x9, 0); 174 175 dev_info(&port->dev, "using %s mode\n", priv->irda ? "IrDA" : "RS232"); 176 177 return 0; 178 } 179 180 static void ark3116_port_remove(struct usb_serial_port *port) 181 { 182 struct ark3116_private *priv = usb_get_serial_port_data(port); 183 184 /* device is closed, so URBs and DMA should be down */ 185 mutex_destroy(&priv->hw_lock); 186 kfree(priv); 187 } 188 189 static void ark3116_set_termios(struct tty_struct *tty, 190 struct usb_serial_port *port, 191 const struct ktermios *old_termios) 192 { 193 struct usb_serial *serial = port->serial; 194 struct ark3116_private *priv = usb_get_serial_port_data(port); 195 struct ktermios *termios = &tty->termios; 196 unsigned int cflag = termios->c_cflag; 197 int bps = tty_get_baud_rate(tty); 198 int quot; 199 __u8 lcr, hcr, eval; 200 201 /* set data bit count */ 202 lcr = UART_LCR_WLEN(tty_get_char_size(cflag)); 203 204 if (cflag & CSTOPB) 205 lcr |= UART_LCR_STOP; 206 if (cflag & PARENB) 207 lcr |= UART_LCR_PARITY; 208 if (!(cflag & PARODD)) 209 lcr |= UART_LCR_EPAR; 210 if (cflag & CMSPAR) 211 lcr |= UART_LCR_SPAR; 212 213 /* handshake control */ 214 hcr = (cflag & CRTSCTS) ? 0x03 : 0x00; 215 216 /* calc baudrate */ 217 dev_dbg(&port->dev, "%s - setting bps to %d\n", __func__, bps); 218 eval = 0; 219 switch (bps) { 220 case 0: 221 quot = calc_divisor(9600); 222 break; 223 default: 224 if ((bps < 75) || (bps > 3000000)) 225 bps = 9600; 226 quot = calc_divisor(bps); 227 break; 228 case 460800: 229 eval = 1; 230 quot = calc_divisor(bps); 231 break; 232 case 921600: 233 eval = 2; 234 quot = calc_divisor(bps); 235 break; 236 } 237 238 /* Update state: synchronize */ 239 mutex_lock(&priv->hw_lock); 240 241 /* keep old LCR_SBC bit */ 242 lcr |= (priv->lcr & UART_LCR_SBC); 243 244 dev_dbg(&port->dev, "%s - setting hcr:0x%02x,lcr:0x%02x,quot:%d\n", 245 __func__, hcr, lcr, quot); 246 247 /* handshake control */ 248 if (priv->hcr != hcr) { 249 priv->hcr = hcr; 250 ark3116_write_reg(serial, 0x8, hcr); 251 } 252 253 /* baudrate */ 254 if (priv->quot != quot) { 255 priv->quot = quot; 256 priv->lcr = lcr; /* need to write lcr anyway */ 257 258 /* disable DMA since transmit/receive is 259 * shadowed by UART_DLL 260 */ 261 ark3116_write_reg(serial, UART_FCR, 0); 262 263 ark3116_write_reg(serial, UART_LCR, 264 lcr|UART_LCR_DLAB); 265 ark3116_write_reg(serial, UART_DLL, quot & 0xff); 266 ark3116_write_reg(serial, UART_DLM, (quot>>8) & 0xff); 267 268 /* restore lcr */ 269 ark3116_write_reg(serial, UART_LCR, lcr); 270 /* magic baudrate thingy: not sure what it does, 271 * but windows does this as well. 272 */ 273 ark3116_write_reg(serial, 0xe, eval); 274 275 /* enable DMA */ 276 ark3116_write_reg(serial, UART_FCR, UART_FCR_DMA_SELECT); 277 } else if (priv->lcr != lcr) { 278 priv->lcr = lcr; 279 ark3116_write_reg(serial, UART_LCR, lcr); 280 } 281 282 mutex_unlock(&priv->hw_lock); 283 284 /* check for software flow control */ 285 if (I_IXOFF(tty) || I_IXON(tty)) { 286 dev_warn(&port->dev, 287 "software flow control not implemented\n"); 288 } 289 290 /* Don't rewrite B0 */ 291 if (tty_termios_baud_rate(termios)) 292 tty_termios_encode_baud_rate(termios, bps, bps); 293 } 294 295 static void ark3116_close(struct usb_serial_port *port) 296 { 297 struct usb_serial *serial = port->serial; 298 299 /* disable DMA */ 300 ark3116_write_reg(serial, UART_FCR, 0); 301 302 /* deactivate interrupts */ 303 ark3116_write_reg(serial, UART_IER, 0); 304 305 usb_serial_generic_close(port); 306 307 usb_kill_urb(port->interrupt_in_urb); 308 } 309 310 static int ark3116_open(struct tty_struct *tty, struct usb_serial_port *port) 311 { 312 struct ark3116_private *priv = usb_get_serial_port_data(port); 313 struct usb_serial *serial = port->serial; 314 unsigned char *buf; 315 int result; 316 317 buf = kmalloc(1, GFP_KERNEL); 318 if (buf == NULL) 319 return -ENOMEM; 320 321 result = usb_serial_generic_open(tty, port); 322 if (result) { 323 dev_dbg(&port->dev, 324 "%s - usb_serial_generic_open failed: %d\n", 325 __func__, result); 326 goto err_free; 327 } 328 329 /* remove any data still left: also clears error state */ 330 ark3116_read_reg(serial, UART_RX, buf); 331 332 /* read modem status */ 333 result = ark3116_read_reg(serial, UART_MSR, buf); 334 if (result) 335 goto err_close; 336 priv->msr = *buf; 337 338 /* read line status */ 339 result = ark3116_read_reg(serial, UART_LSR, buf); 340 if (result) 341 goto err_close; 342 priv->lsr = *buf; 343 344 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 345 if (result) { 346 dev_err(&port->dev, "submit irq_in urb failed %d\n", 347 result); 348 goto err_close; 349 } 350 351 /* activate interrupts */ 352 ark3116_write_reg(port->serial, UART_IER, UART_IER_MSI|UART_IER_RLSI); 353 354 /* enable DMA */ 355 ark3116_write_reg(port->serial, UART_FCR, UART_FCR_DMA_SELECT); 356 357 /* setup termios */ 358 if (tty) 359 ark3116_set_termios(tty, port, NULL); 360 361 kfree(buf); 362 363 return 0; 364 365 err_close: 366 usb_serial_generic_close(port); 367 err_free: 368 kfree(buf); 369 370 return result; 371 } 372 373 static int ark3116_tiocmget(struct tty_struct *tty) 374 { 375 struct usb_serial_port *port = tty->driver_data; 376 struct ark3116_private *priv = usb_get_serial_port_data(port); 377 __u32 status; 378 __u32 ctrl; 379 unsigned long flags; 380 381 mutex_lock(&priv->hw_lock); 382 ctrl = priv->mcr; 383 mutex_unlock(&priv->hw_lock); 384 385 spin_lock_irqsave(&priv->status_lock, flags); 386 status = priv->msr; 387 spin_unlock_irqrestore(&priv->status_lock, flags); 388 389 return (status & UART_MSR_DSR ? TIOCM_DSR : 0) | 390 (status & UART_MSR_CTS ? TIOCM_CTS : 0) | 391 (status & UART_MSR_RI ? TIOCM_RI : 0) | 392 (status & UART_MSR_DCD ? TIOCM_CD : 0) | 393 (ctrl & UART_MCR_DTR ? TIOCM_DTR : 0) | 394 (ctrl & UART_MCR_RTS ? TIOCM_RTS : 0) | 395 (ctrl & UART_MCR_OUT1 ? TIOCM_OUT1 : 0) | 396 (ctrl & UART_MCR_OUT2 ? TIOCM_OUT2 : 0); 397 } 398 399 static int ark3116_tiocmset(struct tty_struct *tty, 400 unsigned set, unsigned clr) 401 { 402 struct usb_serial_port *port = tty->driver_data; 403 struct ark3116_private *priv = usb_get_serial_port_data(port); 404 405 /* we need to take the mutex here, to make sure that the value 406 * in priv->mcr is actually the one that is in the hardware 407 */ 408 409 mutex_lock(&priv->hw_lock); 410 411 if (set & TIOCM_RTS) 412 priv->mcr |= UART_MCR_RTS; 413 if (set & TIOCM_DTR) 414 priv->mcr |= UART_MCR_DTR; 415 if (set & TIOCM_OUT1) 416 priv->mcr |= UART_MCR_OUT1; 417 if (set & TIOCM_OUT2) 418 priv->mcr |= UART_MCR_OUT2; 419 if (clr & TIOCM_RTS) 420 priv->mcr &= ~UART_MCR_RTS; 421 if (clr & TIOCM_DTR) 422 priv->mcr &= ~UART_MCR_DTR; 423 if (clr & TIOCM_OUT1) 424 priv->mcr &= ~UART_MCR_OUT1; 425 if (clr & TIOCM_OUT2) 426 priv->mcr &= ~UART_MCR_OUT2; 427 428 ark3116_write_reg(port->serial, UART_MCR, priv->mcr); 429 430 mutex_unlock(&priv->hw_lock); 431 432 return 0; 433 } 434 435 static int ark3116_break_ctl(struct tty_struct *tty, int break_state) 436 { 437 struct usb_serial_port *port = tty->driver_data; 438 struct ark3116_private *priv = usb_get_serial_port_data(port); 439 int ret; 440 441 /* LCR is also used for other things: protect access */ 442 mutex_lock(&priv->hw_lock); 443 444 if (break_state) 445 priv->lcr |= UART_LCR_SBC; 446 else 447 priv->lcr &= ~UART_LCR_SBC; 448 449 ret = ark3116_write_reg(port->serial, UART_LCR, priv->lcr); 450 451 mutex_unlock(&priv->hw_lock); 452 453 return ret; 454 } 455 456 static void ark3116_update_msr(struct usb_serial_port *port, __u8 msr) 457 { 458 struct ark3116_private *priv = usb_get_serial_port_data(port); 459 unsigned long flags; 460 461 spin_lock_irqsave(&priv->status_lock, flags); 462 priv->msr = msr; 463 spin_unlock_irqrestore(&priv->status_lock, flags); 464 465 if (msr & UART_MSR_ANY_DELTA) { 466 /* update input line counters */ 467 if (msr & UART_MSR_DCTS) 468 port->icount.cts++; 469 if (msr & UART_MSR_DDSR) 470 port->icount.dsr++; 471 if (msr & UART_MSR_DDCD) 472 port->icount.dcd++; 473 if (msr & UART_MSR_TERI) 474 port->icount.rng++; 475 wake_up_interruptible(&port->port.delta_msr_wait); 476 } 477 } 478 479 static void ark3116_update_lsr(struct usb_serial_port *port, __u8 lsr) 480 { 481 struct ark3116_private *priv = usb_get_serial_port_data(port); 482 unsigned long flags; 483 484 spin_lock_irqsave(&priv->status_lock, flags); 485 /* combine bits */ 486 priv->lsr |= lsr; 487 spin_unlock_irqrestore(&priv->status_lock, flags); 488 489 if (lsr&UART_LSR_BRK_ERROR_BITS) { 490 if (lsr & UART_LSR_BI) 491 port->icount.brk++; 492 if (lsr & UART_LSR_FE) 493 port->icount.frame++; 494 if (lsr & UART_LSR_PE) 495 port->icount.parity++; 496 if (lsr & UART_LSR_OE) 497 port->icount.overrun++; 498 } 499 } 500 501 static void ark3116_read_int_callback(struct urb *urb) 502 { 503 struct usb_serial_port *port = urb->context; 504 int status = urb->status; 505 const __u8 *data = urb->transfer_buffer; 506 int result; 507 508 switch (status) { 509 case -ECONNRESET: 510 case -ENOENT: 511 case -ESHUTDOWN: 512 /* this urb is terminated, clean up */ 513 dev_dbg(&port->dev, "%s - urb shutting down with status: %d\n", 514 __func__, status); 515 return; 516 default: 517 dev_dbg(&port->dev, "%s - nonzero urb status received: %d\n", 518 __func__, status); 519 break; 520 case 0: /* success */ 521 /* discovered this by trail and error... */ 522 if ((urb->actual_length == 4) && (data[0] == 0xe8)) { 523 const __u8 id = data[1]&UART_IIR_ID; 524 dev_dbg(&port->dev, "%s: iir=%02x\n", __func__, data[1]); 525 if (id == UART_IIR_MSI) { 526 dev_dbg(&port->dev, "%s: msr=%02x\n", 527 __func__, data[3]); 528 ark3116_update_msr(port, data[3]); 529 break; 530 } else if (id == UART_IIR_RLSI) { 531 dev_dbg(&port->dev, "%s: lsr=%02x\n", 532 __func__, data[2]); 533 ark3116_update_lsr(port, data[2]); 534 break; 535 } 536 } 537 /* 538 * Not sure what this data meant... 539 */ 540 usb_serial_debug_data(&port->dev, __func__, 541 urb->actual_length, 542 urb->transfer_buffer); 543 break; 544 } 545 546 result = usb_submit_urb(urb, GFP_ATOMIC); 547 if (result) 548 dev_err(&port->dev, "failed to resubmit interrupt urb: %d\n", 549 result); 550 } 551 552 553 /* Data comes in via the bulk (data) URB, errors/interrupts via the int URB. 554 * This means that we cannot be sure which data byte has an associated error 555 * condition, so we report an error for all data in the next bulk read. 556 * 557 * Actually, there might even be a window between the bulk data leaving the 558 * ark and reading/resetting the lsr in the read_bulk_callback where an 559 * interrupt for the next data block could come in. 560 * Without somekind of ordering on the ark, we would have to report the 561 * error for the next block of data as well... 562 * For now, let's pretend this can't happen. 563 */ 564 static void ark3116_process_read_urb(struct urb *urb) 565 { 566 struct usb_serial_port *port = urb->context; 567 struct ark3116_private *priv = usb_get_serial_port_data(port); 568 unsigned char *data = urb->transfer_buffer; 569 char tty_flag = TTY_NORMAL; 570 unsigned long flags; 571 __u32 lsr; 572 573 /* update line status */ 574 spin_lock_irqsave(&priv->status_lock, flags); 575 lsr = priv->lsr; 576 priv->lsr &= ~UART_LSR_BRK_ERROR_BITS; 577 spin_unlock_irqrestore(&priv->status_lock, flags); 578 579 if (!urb->actual_length) 580 return; 581 582 if (lsr & UART_LSR_BRK_ERROR_BITS) { 583 if (lsr & UART_LSR_BI) 584 tty_flag = TTY_BREAK; 585 else if (lsr & UART_LSR_PE) 586 tty_flag = TTY_PARITY; 587 else if (lsr & UART_LSR_FE) 588 tty_flag = TTY_FRAME; 589 590 /* overrun is special, not associated with a char */ 591 if (lsr & UART_LSR_OE) 592 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); 593 } 594 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, 595 urb->actual_length); 596 tty_flip_buffer_push(&port->port); 597 } 598 599 static struct usb_serial_driver ark3116_device = { 600 .driver = { 601 .name = "ark3116", 602 }, 603 .id_table = id_table, 604 .num_ports = 1, 605 .num_bulk_in = 1, 606 .num_bulk_out = 1, 607 .num_interrupt_in = 1, 608 .port_probe = ark3116_port_probe, 609 .port_remove = ark3116_port_remove, 610 .set_termios = ark3116_set_termios, 611 .tiocmget = ark3116_tiocmget, 612 .tiocmset = ark3116_tiocmset, 613 .tiocmiwait = usb_serial_generic_tiocmiwait, 614 .get_icount = usb_serial_generic_get_icount, 615 .open = ark3116_open, 616 .close = ark3116_close, 617 .break_ctl = ark3116_break_ctl, 618 .read_int_callback = ark3116_read_int_callback, 619 .process_read_urb = ark3116_process_read_urb, 620 }; 621 622 static struct usb_serial_driver * const serial_drivers[] = { 623 &ark3116_device, NULL 624 }; 625 626 module_usb_serial_driver(serial_drivers, id_table); 627 628 MODULE_LICENSE("GPL"); 629 630 MODULE_AUTHOR(DRIVER_AUTHOR); 631 MODULE_DESCRIPTION(DRIVER_DESC); 632 633 /* 634 * The following describes what I learned from studying the old 635 * ark3116.c driver, disassembling the windows driver, and some lucky 636 * guesses. Since I do not have any datasheet or other 637 * documentation, inaccuracies are almost guaranteed. 638 * 639 * Some specs for the ARK3116 can be found here: 640 * http://web.archive.org/web/20060318000438/ 641 * www.arkmicro.com/en/products/view.php?id=10 642 * On that page, 2 GPIO pins are mentioned: I assume these are the 643 * OUT1 and OUT2 pins of the UART, so I added support for those 644 * through the MCR. Since the pins are not available on my hardware, 645 * I could not verify this. 646 * Also, it states there is "on-chip hardware flow control". I have 647 * discovered how to enable that. Unfortunately, I do not know how to 648 * enable XON/XOFF (software) flow control, which would need support 649 * from the chip as well to work. Because of the wording on the web 650 * page there is a real possibility the chip simply does not support 651 * software flow control. 652 * 653 * I got my ark3116 as part of a mobile phone adapter cable. On the 654 * PCB, the following numbered contacts are present: 655 * 656 * 1:- +5V 657 * 2:o DTR 658 * 3:i RX 659 * 4:i DCD 660 * 5:o RTS 661 * 6:o TX 662 * 7:i RI 663 * 8:i DSR 664 * 10:- 0V 665 * 11:i CTS 666 * 667 * On my chip, all signals seem to be 3.3V, but 5V tolerant. But that 668 * may be different for the one you have ;-). 669 * 670 * The windows driver limits the registers to 0-F, so I assume there 671 * are actually 16 present on the device. 672 * 673 * On an UART interrupt, 4 bytes of data come in on the interrupt 674 * endpoint. The bytes are 0xe8 IIR LSR MSR. 675 * 676 * The baudrate seems to be generated from the 12MHz crystal, using 677 * 4-times subsampling. So quot=12e6/(4*baud). Also see description 678 * of register E. 679 * 680 * Registers 0-7: 681 * These seem to be the same as for a regular 16450. The FCR is set 682 * to UART_FCR_DMA_SELECT (0x8), I guess to enable transfers between 683 * the UART and the USB bridge/DMA engine. 684 * 685 * Register 8: 686 * By trial and error, I found out that bit 0 enables hardware CTS, 687 * stopping TX when CTS is +5V. Bit 1 does the same for RTS, making 688 * RTS +5V when the 3116 cannot transfer the data to the USB bus 689 * (verified by disabling the reading URB). Note that as far as I can 690 * tell, the windows driver does NOT use this, so there might be some 691 * hardware bug or something. 692 * 693 * According to a patch provided here 694 * https://lore.kernel.org/lkml/200907261419.50702.linux@rainbow-software.org 695 * the ARK3116 can also be used as an IrDA dongle. Since I do not have 696 * such a thing, I could not investigate that aspect. However, I can 697 * speculate ;-). 698 * 699 * - IrDA encodes data differently than RS232. Most likely, one of 700 * the bits in registers 9..E enables the IR ENDEC (encoder/decoder). 701 * - Depending on the IR transceiver, the input and output need to be 702 * inverted, so there are probably bits for that as well. 703 * - IrDA is half-duplex, so there should be a bit for selecting that. 704 * 705 * This still leaves at least two registers unaccounted for. Perhaps 706 * The chip can do XON/XOFF or CRC in HW? 707 * 708 * Register 9: 709 * Set to 0x00 for IrDA, when the baudrate is initialised. 710 * 711 * Register A: 712 * Set to 0x01 for IrDA, at init. 713 * 714 * Register B: 715 * Set to 0x01 for IrDA, 0x00 for RS232, at init. 716 * 717 * Register C: 718 * Set to 00 for IrDA, at init. 719 * 720 * Register D: 721 * Set to 0x41 for IrDA, at init. 722 * 723 * Register E: 724 * Somekind of baudrate override. The windows driver seems to set 725 * this to 0x00 for normal baudrates, 0x01 for 460800, 0x02 for 921600. 726 * Since 460800 and 921600 cannot be obtained by dividing 3MHz by an integer, 727 * it could be somekind of subdivisor thingy. 728 * However,it does not seem to do anything: selecting 921600 (divisor 3, 729 * reg E=2), still gets 1 MHz. I also checked if registers 9, C or F would 730 * work, but they don't. 731 * 732 * Register F: unknown 733 */ 734