Lines Matching +full:dcd +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 ktermios *termios = &tty->termios; in ark3116_init_termios()
196 termios->c_cflag = B9600 | CS8 in ark3116_init_termios()
198 termios->c_ispeed = 9600; in ark3116_init_termios()
199 termios->c_ospeed = 9600; in ark3116_init_termios()
206 struct usb_serial *serial = port->serial; in ark3116_set_termios()
208 struct ktermios *termios = &tty->termios; in ark3116_set_termios()
209 unsigned int cflag = termios->c_cflag; in ark3116_set_termios()
244 dev_dbg(&port->dev, "%s - setting bps to %d\n", __func__, bps); in ark3116_set_termios()
266 mutex_lock(&priv->hw_lock); in ark3116_set_termios()
269 lcr |= (priv->lcr & UART_LCR_SBC); in ark3116_set_termios()
271 dev_dbg(&port->dev, "%s - setting hcr:0x%02x,lcr:0x%02x,quot:%d\n", in ark3116_set_termios()
275 if (priv->hcr != hcr) { in ark3116_set_termios()
276 priv->hcr = hcr; in ark3116_set_termios()
281 if (priv->quot != quot) { in ark3116_set_termios()
282 priv->quot = quot; in ark3116_set_termios()
283 priv->lcr = lcr; /* need to write lcr anyway */ in ark3116_set_termios()
304 } else if (priv->lcr != lcr) { in ark3116_set_termios()
305 priv->lcr = lcr; in ark3116_set_termios()
309 mutex_unlock(&priv->hw_lock); in ark3116_set_termios()
313 dev_warn(&port->dev, in ark3116_set_termios()
324 struct usb_serial *serial = port->serial; in ark3116_close()
334 usb_kill_urb(port->interrupt_in_urb); in ark3116_close()
340 struct usb_serial *serial = port->serial; in ark3116_open()
346 return -ENOMEM; in ark3116_open()
350 dev_dbg(&port->dev, in ark3116_open()
351 "%s - usb_serial_generic_open failed: %d\n", in ark3116_open()
363 priv->msr = *buf; in ark3116_open()
369 priv->lsr = *buf; in ark3116_open()
371 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); in ark3116_open()
373 dev_err(&port->dev, "submit irq_in urb failed %d\n", in ark3116_open()
379 ark3116_write_reg(port->serial, UART_IER, UART_IER_MSI|UART_IER_RLSI); in ark3116_open()
382 ark3116_write_reg(port->serial, UART_FCR, UART_FCR_DMA_SELECT); in ark3116_open()
408 tmp.line = port->minor; in ark3116_get_serial_info()
409 tmp.port = port->port_number; in ark3116_get_serial_info()
413 return -EFAULT; in ark3116_get_serial_info()
421 struct usb_serial_port *port = tty->driver_data; in ark3116_ioctl()
431 return -ENOIOCTLCMD; in ark3116_ioctl()
436 struct usb_serial_port *port = tty->driver_data; in ark3116_tiocmget()
442 mutex_lock(&priv->hw_lock); in ark3116_tiocmget()
443 ctrl = priv->mcr; in ark3116_tiocmget()
444 mutex_unlock(&priv->hw_lock); in ark3116_tiocmget()
446 spin_lock_irqsave(&priv->status_lock, flags); in ark3116_tiocmget()
447 status = priv->msr; in ark3116_tiocmget()
448 spin_unlock_irqrestore(&priv->status_lock, flags); in ark3116_tiocmget()
463 struct usb_serial_port *port = tty->driver_data; in ark3116_tiocmset()
467 * in priv->mcr is actually the one that is in the hardware in ark3116_tiocmset()
470 mutex_lock(&priv->hw_lock); in ark3116_tiocmset()
473 priv->mcr |= UART_MCR_RTS; in ark3116_tiocmset()
475 priv->mcr |= UART_MCR_DTR; in ark3116_tiocmset()
477 priv->mcr |= UART_MCR_OUT1; in ark3116_tiocmset()
479 priv->mcr |= UART_MCR_OUT2; in ark3116_tiocmset()
481 priv->mcr &= ~UART_MCR_RTS; in ark3116_tiocmset()
483 priv->mcr &= ~UART_MCR_DTR; in ark3116_tiocmset()
485 priv->mcr &= ~UART_MCR_OUT1; in ark3116_tiocmset()
487 priv->mcr &= ~UART_MCR_OUT2; in ark3116_tiocmset()
489 ark3116_write_reg(port->serial, UART_MCR, priv->mcr); in ark3116_tiocmset()
491 mutex_unlock(&priv->hw_lock); in ark3116_tiocmset()
498 struct usb_serial_port *port = tty->driver_data; in ark3116_break_ctl()
502 mutex_lock(&priv->hw_lock); in ark3116_break_ctl()
505 priv->lcr |= UART_LCR_SBC; in ark3116_break_ctl()
507 priv->lcr &= ~UART_LCR_SBC; in ark3116_break_ctl()
509 ark3116_write_reg(port->serial, UART_LCR, priv->lcr); in ark3116_break_ctl()
511 mutex_unlock(&priv->hw_lock); in ark3116_break_ctl()
519 spin_lock_irqsave(&priv->status_lock, flags); in ark3116_update_msr()
520 priv->msr = msr; in ark3116_update_msr()
521 spin_unlock_irqrestore(&priv->status_lock, flags); in ark3116_update_msr()
526 port->icount.cts++; in ark3116_update_msr()
528 port->icount.dsr++; in ark3116_update_msr()
530 port->icount.dcd++; in ark3116_update_msr()
532 port->icount.rng++; in ark3116_update_msr()
533 wake_up_interruptible(&port->port.delta_msr_wait); in ark3116_update_msr()
542 spin_lock_irqsave(&priv->status_lock, flags); in ark3116_update_lsr()
544 priv->lsr |= lsr; in ark3116_update_lsr()
545 spin_unlock_irqrestore(&priv->status_lock, flags); in ark3116_update_lsr()
549 port->icount.brk++; in ark3116_update_lsr()
551 port->icount.frame++; in ark3116_update_lsr()
553 port->icount.parity++; in ark3116_update_lsr()
555 port->icount.overrun++; in ark3116_update_lsr()
561 struct usb_serial_port *port = urb->context; in ark3116_read_int_callback()
562 int status = urb->status; in ark3116_read_int_callback()
563 const __u8 *data = urb->transfer_buffer; in ark3116_read_int_callback()
567 case -ECONNRESET: in ark3116_read_int_callback()
568 case -ENOENT: in ark3116_read_int_callback()
569 case -ESHUTDOWN: in ark3116_read_int_callback()
571 dev_dbg(&port->dev, "%s - urb shutting down with status: %d\n", in ark3116_read_int_callback()
575 dev_dbg(&port->dev, "%s - nonzero urb status received: %d\n", in ark3116_read_int_callback()
580 if ((urb->actual_length == 4) && (data[0] == 0xe8)) { in ark3116_read_int_callback()
582 dev_dbg(&port->dev, "%s: iir=%02x\n", __func__, data[1]); in ark3116_read_int_callback()
584 dev_dbg(&port->dev, "%s: msr=%02x\n", in ark3116_read_int_callback()
589 dev_dbg(&port->dev, "%s: lsr=%02x\n", in ark3116_read_int_callback()
598 usb_serial_debug_data(&port->dev, __func__, in ark3116_read_int_callback()
599 urb->actual_length, in ark3116_read_int_callback()
600 urb->transfer_buffer); in ark3116_read_int_callback()
606 dev_err(&port->dev, "failed to resubmit interrupt urb: %d\n", in ark3116_read_int_callback()
624 struct usb_serial_port *port = urb->context; in ark3116_process_read_urb()
626 unsigned char *data = urb->transfer_buffer; in ark3116_process_read_urb()
632 spin_lock_irqsave(&priv->status_lock, flags); in ark3116_process_read_urb()
633 lsr = priv->lsr; in ark3116_process_read_urb()
634 priv->lsr &= ~UART_LSR_BRK_ERROR_BITS; in ark3116_process_read_urb()
635 spin_unlock_irqrestore(&priv->status_lock, flags); in ark3116_process_read_urb()
637 if (!urb->actual_length) in ark3116_process_read_urb()
650 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); in ark3116_process_read_urb()
652 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, in ark3116_process_read_urb()
653 urb->actual_length); in ark3116_process_read_urb()
654 tty_flip_buffer_push(&port->port); in ark3116_process_read_urb()
707 * Also, it states there is "on-chip hardware flow control". I have
717 * 1:- +5V
720 * 4:i DCD
725 * 10:- 0V
729 * may be different for the one you have ;-).
731 * The windows driver limits the registers to 0-F, so I assume there
738 * 4-times subsampling. So quot=12e6/(4*baud). Also see description
741 * Registers 0-7:
757 * investigate that aspect. However, I can speculate ;-).
759 * - IrDA encodes data differently than RS232. Most likely, one of
761 * - Depending on the IR transceiver, the input and output need to be
763 * - IrDA is half-duplex, so there should be a bit for selecting that.
784 * Somekind of baudrate override. The windows driver seems to set