Lines Matching +full:cts +full:- +full:override
1 // SPDX-License-Identifier: GPL-2.0+
9 * - implements a driver for the arkmicro ark3116 chipset (vendor=0x6547,
10 * productid=0x0232) (used in a datacable called KQ-U8A)
52 struct usb_device *dev = serial->dev; in is_irda()
53 if (le16_to_cpu(dev->descriptor.idVendor) == 0x18ec && in is_irda()
54 le16_to_cpu(dev->descriptor.idProduct) == 0x3118) in is_irda()
82 result = usb_control_msg(serial->dev, in ark3116_write_reg()
83 usb_sndctrlpipe(serial->dev, 0), in ark3116_write_reg()
97 result = usb_control_msg(serial->dev, in ark3116_read_reg()
98 usb_rcvctrlpipe(serial->dev, 0), in ark3116_read_reg()
102 dev_err(&serial->interface->dev, in ark3116_read_reg()
106 result = -EIO; in ark3116_read_reg()
126 struct usb_serial *serial = port->serial; in ark3116_port_probe()
131 return -ENOMEM; in ark3116_port_probe()
133 mutex_init(&priv->hw_lock); in ark3116_port_probe()
134 spin_lock_init(&priv->status_lock); in ark3116_port_probe()
136 priv->irda = is_irda(serial); in ark3116_port_probe()
145 priv->hcr = 0; in ark3116_port_probe()
148 priv->mcr = 0; in ark3116_port_probe()
151 if (!(priv->irda)) { in ark3116_port_probe()
164 priv->quot = calc_divisor(9600); in ark3116_port_probe()
165 ark3116_write_reg(serial, UART_DLL, priv->quot & 0xff); in ark3116_port_probe()
166 ark3116_write_reg(serial, UART_DLM, (priv->quot>>8) & 0xff); in ark3116_port_probe()
168 priv->lcr = UART_LCR_WLEN8; in ark3116_port_probe()
173 if (priv->irda) in ark3116_port_probe()
176 dev_info(&port->dev, "using %s mode\n", priv->irda ? "IrDA" : "RS232"); in ark3116_port_probe()
186 mutex_destroy(&priv->hw_lock); in ark3116_port_remove()
194 struct usb_serial *serial = port->serial; in ark3116_set_termios()
196 struct ktermios *termios = &tty->termios; in ark3116_set_termios()
197 unsigned int cflag = termios->c_cflag; in ark3116_set_termios()
232 dev_dbg(&port->dev, "%s - setting bps to %d\n", __func__, bps); in ark3116_set_termios()
254 mutex_lock(&priv->hw_lock); in ark3116_set_termios()
257 lcr |= (priv->lcr & UART_LCR_SBC); in ark3116_set_termios()
259 dev_dbg(&port->dev, "%s - setting hcr:0x%02x,lcr:0x%02x,quot:%d\n", in ark3116_set_termios()
263 if (priv->hcr != hcr) { in ark3116_set_termios()
264 priv->hcr = hcr; in ark3116_set_termios()
269 if (priv->quot != quot) { in ark3116_set_termios()
270 priv->quot = quot; in ark3116_set_termios()
271 priv->lcr = lcr; /* need to write lcr anyway */ in ark3116_set_termios()
292 } else if (priv->lcr != lcr) { in ark3116_set_termios()
293 priv->lcr = lcr; in ark3116_set_termios()
297 mutex_unlock(&priv->hw_lock); in ark3116_set_termios()
301 dev_warn(&port->dev, in ark3116_set_termios()
312 struct usb_serial *serial = port->serial; in ark3116_close()
322 usb_kill_urb(port->interrupt_in_urb); in ark3116_close()
328 struct usb_serial *serial = port->serial; in ark3116_open()
334 return -ENOMEM; in ark3116_open()
338 dev_dbg(&port->dev, in ark3116_open()
339 "%s - usb_serial_generic_open failed: %d\n", in ark3116_open()
351 priv->msr = *buf; in ark3116_open()
357 priv->lsr = *buf; in ark3116_open()
359 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); in ark3116_open()
361 dev_err(&port->dev, "submit irq_in urb failed %d\n", in ark3116_open()
367 ark3116_write_reg(port->serial, UART_IER, UART_IER_MSI|UART_IER_RLSI); in ark3116_open()
370 ark3116_write_reg(port->serial, UART_FCR, UART_FCR_DMA_SELECT); in ark3116_open()
390 struct usb_serial_port *port = tty->driver_data; in ark3116_tiocmget()
396 mutex_lock(&priv->hw_lock); in ark3116_tiocmget()
397 ctrl = priv->mcr; in ark3116_tiocmget()
398 mutex_unlock(&priv->hw_lock); in ark3116_tiocmget()
400 spin_lock_irqsave(&priv->status_lock, flags); in ark3116_tiocmget()
401 status = priv->msr; in ark3116_tiocmget()
402 spin_unlock_irqrestore(&priv->status_lock, flags); in ark3116_tiocmget()
417 struct usb_serial_port *port = tty->driver_data; in ark3116_tiocmset()
421 * in priv->mcr is actually the one that is in the hardware in ark3116_tiocmset()
424 mutex_lock(&priv->hw_lock); in ark3116_tiocmset()
427 priv->mcr |= UART_MCR_RTS; in ark3116_tiocmset()
429 priv->mcr |= UART_MCR_DTR; in ark3116_tiocmset()
431 priv->mcr |= UART_MCR_OUT1; in ark3116_tiocmset()
433 priv->mcr |= UART_MCR_OUT2; in ark3116_tiocmset()
435 priv->mcr &= ~UART_MCR_RTS; in ark3116_tiocmset()
437 priv->mcr &= ~UART_MCR_DTR; in ark3116_tiocmset()
439 priv->mcr &= ~UART_MCR_OUT1; in ark3116_tiocmset()
441 priv->mcr &= ~UART_MCR_OUT2; in ark3116_tiocmset()
443 ark3116_write_reg(port->serial, UART_MCR, priv->mcr); in ark3116_tiocmset()
445 mutex_unlock(&priv->hw_lock); in ark3116_tiocmset()
452 struct usb_serial_port *port = tty->driver_data; in ark3116_break_ctl()
456 mutex_lock(&priv->hw_lock); in ark3116_break_ctl()
459 priv->lcr |= UART_LCR_SBC; in ark3116_break_ctl()
461 priv->lcr &= ~UART_LCR_SBC; in ark3116_break_ctl()
463 ark3116_write_reg(port->serial, UART_LCR, priv->lcr); in ark3116_break_ctl()
465 mutex_unlock(&priv->hw_lock); in ark3116_break_ctl()
473 spin_lock_irqsave(&priv->status_lock, flags); in ark3116_update_msr()
474 priv->msr = msr; in ark3116_update_msr()
475 spin_unlock_irqrestore(&priv->status_lock, flags); in ark3116_update_msr()
480 port->icount.cts++; in ark3116_update_msr()
482 port->icount.dsr++; in ark3116_update_msr()
484 port->icount.dcd++; in ark3116_update_msr()
486 port->icount.rng++; in ark3116_update_msr()
487 wake_up_interruptible(&port->port.delta_msr_wait); in ark3116_update_msr()
496 spin_lock_irqsave(&priv->status_lock, flags); in ark3116_update_lsr()
498 priv->lsr |= lsr; in ark3116_update_lsr()
499 spin_unlock_irqrestore(&priv->status_lock, flags); in ark3116_update_lsr()
503 port->icount.brk++; in ark3116_update_lsr()
505 port->icount.frame++; in ark3116_update_lsr()
507 port->icount.parity++; in ark3116_update_lsr()
509 port->icount.overrun++; in ark3116_update_lsr()
515 struct usb_serial_port *port = urb->context; in ark3116_read_int_callback()
516 int status = urb->status; in ark3116_read_int_callback()
517 const __u8 *data = urb->transfer_buffer; in ark3116_read_int_callback()
521 case -ECONNRESET: in ark3116_read_int_callback()
522 case -ENOENT: in ark3116_read_int_callback()
523 case -ESHUTDOWN: in ark3116_read_int_callback()
525 dev_dbg(&port->dev, "%s - urb shutting down with status: %d\n", in ark3116_read_int_callback()
529 dev_dbg(&port->dev, "%s - nonzero urb status received: %d\n", in ark3116_read_int_callback()
534 if ((urb->actual_length == 4) && (data[0] == 0xe8)) { in ark3116_read_int_callback()
536 dev_dbg(&port->dev, "%s: iir=%02x\n", __func__, data[1]); in ark3116_read_int_callback()
538 dev_dbg(&port->dev, "%s: msr=%02x\n", in ark3116_read_int_callback()
543 dev_dbg(&port->dev, "%s: lsr=%02x\n", in ark3116_read_int_callback()
552 usb_serial_debug_data(&port->dev, __func__, in ark3116_read_int_callback()
553 urb->actual_length, in ark3116_read_int_callback()
554 urb->transfer_buffer); in ark3116_read_int_callback()
560 dev_err(&port->dev, "failed to resubmit interrupt urb: %d\n", in ark3116_read_int_callback()
578 struct usb_serial_port *port = urb->context; in ark3116_process_read_urb()
580 unsigned char *data = urb->transfer_buffer; in ark3116_process_read_urb()
586 spin_lock_irqsave(&priv->status_lock, flags); in ark3116_process_read_urb()
587 lsr = priv->lsr; in ark3116_process_read_urb()
588 priv->lsr &= ~UART_LSR_BRK_ERROR_BITS; in ark3116_process_read_urb()
589 spin_unlock_irqrestore(&priv->status_lock, flags); in ark3116_process_read_urb()
591 if (!urb->actual_length) in ark3116_process_read_urb()
604 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); in ark3116_process_read_urb()
606 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, in ark3116_process_read_urb()
607 urb->actual_length); in ark3116_process_read_urb()
608 tty_flip_buffer_push(&port->port); in ark3116_process_read_urb()
659 * Also, it states there is "on-chip hardware flow control". I have
669 * 1:- +5V
677 * 10:- 0V
678 * 11:i CTS
681 * may be different for the one you have ;-).
683 * The windows driver limits the registers to 0-F, so I assume there
690 * 4-times subsampling. So quot=12e6/(4*baud). Also see description
693 * Registers 0-7:
699 * By trial and error, I found out that bit 0 enables hardware CTS,
700 * stopping TX when CTS is +5V. Bit 1 does the same for RTS, making
707 * https://lore.kernel.org/lkml/200907261419.50702.linux@rainbow-software.org
710 * speculate ;-).
712 * - IrDA encodes data differently than RS232. Most likely, one of
714 * - Depending on the IR transceiver, the input and output need to be
716 * - IrDA is half-duplex, so there should be a bit for selecting that.
737 * Somekind of baudrate override. The windows driver seems to set