Lines Matching +full:my +full:- +full:dma +full:- +full:window
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()
142 /* disable DMA */ 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()
185 /* device is closed, so URBs and DMA should be down */ in ark3116_port_remove()
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()
218 dev_dbg(&port->dev, "%s - setting bps to %d\n", __func__, bps); in ark3116_set_termios()
240 mutex_lock(&priv->hw_lock); in ark3116_set_termios()
243 lcr |= (priv->lcr & UART_LCR_SBC); in ark3116_set_termios()
245 dev_dbg(&port->dev, "%s - setting hcr:0x%02x,lcr:0x%02x,quot:%d\n", in ark3116_set_termios()
249 if (priv->hcr != hcr) { in ark3116_set_termios()
250 priv->hcr = hcr; in ark3116_set_termios()
255 if (priv->quot != quot) { in ark3116_set_termios()
256 priv->quot = quot; in ark3116_set_termios()
257 priv->lcr = lcr; /* need to write lcr anyway */ in ark3116_set_termios()
259 /* disable DMA since transmit/receive is in ark3116_set_termios()
276 /* enable DMA */ in ark3116_set_termios()
278 } else if (priv->lcr != lcr) { in ark3116_set_termios()
279 priv->lcr = lcr; in ark3116_set_termios()
283 mutex_unlock(&priv->hw_lock); in ark3116_set_termios()
287 dev_warn(&port->dev, in ark3116_set_termios()
298 struct usb_serial *serial = port->serial; in ark3116_close()
300 /* disable DMA */ in ark3116_close()
308 usb_kill_urb(port->interrupt_in_urb); in ark3116_close()
314 struct usb_serial *serial = port->serial; in ark3116_open()
320 return -ENOMEM; in ark3116_open()
324 dev_dbg(&port->dev, in ark3116_open()
325 "%s - usb_serial_generic_open failed: %d\n", in ark3116_open()
337 priv->msr = *buf; in ark3116_open()
343 priv->lsr = *buf; in ark3116_open()
345 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); in ark3116_open()
347 dev_err(&port->dev, "submit irq_in urb failed %d\n", in ark3116_open()
353 ark3116_write_reg(port->serial, UART_IER, UART_IER_MSI|UART_IER_RLSI); in ark3116_open()
355 /* enable DMA */ in ark3116_open()
356 ark3116_write_reg(port->serial, UART_FCR, UART_FCR_DMA_SELECT); in ark3116_open()
376 struct usb_serial_port *port = tty->driver_data; in ark3116_tiocmget()
382 mutex_lock(&priv->hw_lock); in ark3116_tiocmget()
383 ctrl = priv->mcr; in ark3116_tiocmget()
384 mutex_unlock(&priv->hw_lock); in ark3116_tiocmget()
386 spin_lock_irqsave(&priv->status_lock, flags); in ark3116_tiocmget()
387 status = priv->msr; in ark3116_tiocmget()
388 spin_unlock_irqrestore(&priv->status_lock, flags); in ark3116_tiocmget()
403 struct usb_serial_port *port = tty->driver_data; in ark3116_tiocmset()
407 * in priv->mcr is actually the one that is in the hardware in ark3116_tiocmset()
410 mutex_lock(&priv->hw_lock); in ark3116_tiocmset()
413 priv->mcr |= UART_MCR_RTS; in ark3116_tiocmset()
415 priv->mcr |= UART_MCR_DTR; in ark3116_tiocmset()
417 priv->mcr |= UART_MCR_OUT1; in ark3116_tiocmset()
419 priv->mcr |= UART_MCR_OUT2; in ark3116_tiocmset()
421 priv->mcr &= ~UART_MCR_RTS; in ark3116_tiocmset()
423 priv->mcr &= ~UART_MCR_DTR; in ark3116_tiocmset()
425 priv->mcr &= ~UART_MCR_OUT1; in ark3116_tiocmset()
427 priv->mcr &= ~UART_MCR_OUT2; in ark3116_tiocmset()
429 ark3116_write_reg(port->serial, UART_MCR, priv->mcr); in ark3116_tiocmset()
431 mutex_unlock(&priv->hw_lock); in ark3116_tiocmset()
438 struct usb_serial_port *port = tty->driver_data; in ark3116_break_ctl()
443 mutex_lock(&priv->hw_lock); in ark3116_break_ctl()
446 priv->lcr |= UART_LCR_SBC; in ark3116_break_ctl()
448 priv->lcr &= ~UART_LCR_SBC; in ark3116_break_ctl()
450 ret = ark3116_write_reg(port->serial, UART_LCR, priv->lcr); in ark3116_break_ctl()
452 mutex_unlock(&priv->hw_lock); in ark3116_break_ctl()
462 spin_lock_irqsave(&priv->status_lock, flags); in ark3116_update_msr()
463 priv->msr = msr; in ark3116_update_msr()
464 spin_unlock_irqrestore(&priv->status_lock, flags); in ark3116_update_msr()
469 port->icount.cts++; in ark3116_update_msr()
471 port->icount.dsr++; in ark3116_update_msr()
473 port->icount.dcd++; in ark3116_update_msr()
475 port->icount.rng++; in ark3116_update_msr()
476 wake_up_interruptible(&port->port.delta_msr_wait); in ark3116_update_msr()
485 spin_lock_irqsave(&priv->status_lock, flags); in ark3116_update_lsr()
487 priv->lsr |= lsr; in ark3116_update_lsr()
488 spin_unlock_irqrestore(&priv->status_lock, flags); in ark3116_update_lsr()
492 port->icount.brk++; in ark3116_update_lsr()
494 port->icount.frame++; in ark3116_update_lsr()
496 port->icount.parity++; in ark3116_update_lsr()
498 port->icount.overrun++; in ark3116_update_lsr()
504 struct usb_serial_port *port = urb->context; in ark3116_read_int_callback()
505 int status = urb->status; in ark3116_read_int_callback()
506 const __u8 *data = urb->transfer_buffer; in ark3116_read_int_callback()
510 case -ECONNRESET: in ark3116_read_int_callback()
511 case -ENOENT: in ark3116_read_int_callback()
512 case -ESHUTDOWN: in ark3116_read_int_callback()
514 dev_dbg(&port->dev, "%s - urb shutting down with status: %d\n", in ark3116_read_int_callback()
518 dev_dbg(&port->dev, "%s - nonzero urb status received: %d\n", in ark3116_read_int_callback()
523 if ((urb->actual_length == 4) && (data[0] == 0xe8)) { in ark3116_read_int_callback()
525 dev_dbg(&port->dev, "%s: iir=%02x\n", __func__, data[1]); in ark3116_read_int_callback()
527 dev_dbg(&port->dev, "%s: msr=%02x\n", in ark3116_read_int_callback()
532 dev_dbg(&port->dev, "%s: lsr=%02x\n", in ark3116_read_int_callback()
541 usb_serial_debug_data(&port->dev, __func__, in ark3116_read_int_callback()
542 urb->actual_length, in ark3116_read_int_callback()
543 urb->transfer_buffer); in ark3116_read_int_callback()
549 dev_err(&port->dev, "failed to resubmit interrupt urb: %d\n", in ark3116_read_int_callback()
558 * Actually, there might even be a window between the bulk data leaving the
567 struct usb_serial_port *port = urb->context; in ark3116_process_read_urb()
569 unsigned char *data = urb->transfer_buffer; in ark3116_process_read_urb()
575 spin_lock_irqsave(&priv->status_lock, flags); in ark3116_process_read_urb()
576 lsr = priv->lsr; in ark3116_process_read_urb()
577 priv->lsr &= ~UART_LSR_BRK_ERROR_BITS; in ark3116_process_read_urb()
578 spin_unlock_irqrestore(&priv->status_lock, flags); in ark3116_process_read_urb()
580 if (!urb->actual_length) in ark3116_process_read_urb()
593 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); in ark3116_process_read_urb()
595 tty_insert_flip_string_fixed_flag(&port->port, data, tty_flag, in ark3116_process_read_urb()
596 urb->actual_length); in ark3116_process_read_urb()
597 tty_flip_buffer_push(&port->port); in ark3116_process_read_urb()
645 * through the MCR. Since the pins are not available on my hardware,
647 * Also, it states there is "on-chip hardware flow control". I have
654 * I got my ark3116 as part of a mobile phone adapter cable. On the
657 * 1:- +5V
665 * 10:- 0V
668 * On my chip, all signals seem to be 3.3V, but 5V tolerant. But that
669 * may be different for the one you have ;-).
671 * The windows driver limits the registers to 0-F, so I assume there
678 * 4-times subsampling. So quot=12e6/(4*baud). Also see description
681 * Registers 0-7:
684 * the UART and the USB bridge/DMA engine.
695 * https://lore.kernel.org/lkml/200907261419.50702.linux@rainbow-software.org
698 * speculate ;-).
700 * - IrDA encodes data differently than RS232. Most likely, one of
702 * - Depending on the IR transceiver, the input and output need to be
704 * - IrDA is half-duplex, so there should be a bit for selecting that.