Lines Matching +full:flow +full:- +full:ctrl
1 // SPDX-License-Identifier: GPL-2.0
10 * Copyright (C) 2008 Gilead Kutnick <kutnickg@zin-tech.com>
74 unsigned int max_chars = port->fifosize; in apbuart_rx_chars()
78 while (UART_RX_DATA(status) && (max_chars--)) { in apbuart_rx_chars()
83 port->icount.rx++; in apbuart_rx_chars()
91 port->icount.brk++; in apbuart_rx_chars()
95 port->icount.parity++; in apbuart_rx_chars()
97 port->icount.frame++; in apbuart_rx_chars()
100 port->icount.overrun++; in apbuart_rx_chars()
102 rsr &= port->read_status_mask; in apbuart_rx_chars()
120 spin_unlock(&port->lock); in apbuart_rx_chars()
121 tty_flip_buffer_push(&port->state->port); in apbuart_rx_chars()
122 spin_lock(&port->lock); in apbuart_rx_chars()
127 struct circ_buf *xmit = &port->state->xmit; in apbuart_tx_chars()
130 if (port->x_char) { in apbuart_tx_chars()
131 UART_PUT_CHAR(port, port->x_char); in apbuart_tx_chars()
132 port->icount.tx++; in apbuart_tx_chars()
133 port->x_char = 0; in apbuart_tx_chars()
143 count = port->fifosize >> 1; in apbuart_tx_chars()
145 UART_PUT_CHAR(port, xmit->buf[xmit->tail]); in apbuart_tx_chars()
146 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); in apbuart_tx_chars()
147 port->icount.tx++; in apbuart_tx_chars()
150 } while (--count > 0); in apbuart_tx_chars()
164 spin_lock(&port->lock); in apbuart_int()
172 spin_unlock(&port->lock); in apbuart_int()
185 /* The GRLIB APBUART handles flow control in hardware */ in apbuart_get_mctrl()
191 /* The GRLIB APBUART handles flow control in hardware */ in apbuart_set_mctrl()
205 retval = request_irq(port->irq, apbuart_int, 0, "apbuart", port); in apbuart_startup()
229 free_irq(port->irq, port); in apbuart_shutdown()
240 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); in apbuart_set_termios()
242 panic("invalid baudrate %i\n", port->uartclk / 16); in apbuart_set_termios()
249 if (termios->c_cflag & PARENB) { in apbuart_set_termios()
251 if ((termios->c_cflag & PARODD)) in apbuart_set_termios()
255 /* Enable flow control. */ in apbuart_set_termios()
256 if (termios->c_cflag & CRTSCTS) in apbuart_set_termios()
259 spin_lock_irqsave(&port->lock, flags); in apbuart_set_termios()
261 /* Update the per-port timeout. */ in apbuart_set_termios()
262 uart_update_timeout(port, termios->c_cflag, baud); in apbuart_set_termios()
264 port->read_status_mask = UART_STATUS_OE; in apbuart_set_termios()
265 if (termios->c_iflag & INPCK) in apbuart_set_termios()
266 port->read_status_mask |= UART_STATUS_FE | UART_STATUS_PE; in apbuart_set_termios()
269 port->ignore_status_mask = 0; in apbuart_set_termios()
270 if (termios->c_iflag & IGNPAR) in apbuart_set_termios()
271 port->ignore_status_mask |= UART_STATUS_FE | UART_STATUS_PE; in apbuart_set_termios()
274 if ((termios->c_cflag & CREAD) == 0) in apbuart_set_termios()
275 port->ignore_status_mask |= UART_DUMMY_RSR_RX; in apbuart_set_termios()
278 quot -= 1; in apbuart_set_termios()
282 spin_unlock_irqrestore(&port->lock, flags); in apbuart_set_termios()
287 return port->type == PORT_APBUART ? "GRLIB/APBUART" : NULL; in apbuart_type()
292 release_mem_region(port->mapbase, 0x100); in apbuart_release_port()
297 return request_mem_region(port->mapbase, 0x100, "grlib-apbuart") in apbuart_request_port()
298 != NULL ? 0 : -EBUSY; in apbuart_request_port()
306 port->type = PORT_APBUART; in apbuart_config_port()
316 if (ser->type != PORT_UNKNOWN && ser->type != PORT_APBUART) in apbuart_verify_port()
317 ret = -EINVAL; in apbuart_verify_port()
318 if (ser->irq < 0 || ser->irq >= NR_IRQS) in apbuart_verify_port()
319 ret = -EINVAL; in apbuart_verify_port()
320 if (ser->baud_base < 9600) in apbuart_verify_port()
321 ret = -EINVAL; in apbuart_verify_port()
348 int ctrl, loop = 0; in apbuart_scan_fifo_size() local
353 ctrl = UART_GET_CTRL(port); in apbuart_scan_fifo_size()
364 UART_PUT_CTRL(port, ctrl | UART_CTRL_TE); in apbuart_scan_fifo_size()
374 UART_PUT_CTRL(port, ctrl & ~(UART_CTRL_TE)); in apbuart_scan_fifo_size()
392 fifosize--; in apbuart_scan_fifo_size()
394 UART_PUT_CTRL(port, ctrl); in apbuart_scan_fifo_size()
407 for (i = 0; i < port->fifosize; i++) in apbuart_flush_fifo()
430 struct uart_port *port = &grlib_apbuart_ports[co->index]; in apbuart_console_write()
469 *baud = port->uartclk / (16 * (quot + 1)); in apbuart_console_get_options()
479 int flow = 'n'; in apbuart_console_setup() local
481 pr_debug("apbuart_console_setup co=%p, co->index=%i, options=%s\n", in apbuart_console_setup()
482 co, co->index, options); in apbuart_console_setup()
489 if (co->index >= grlib_apbuart_port_nr) in apbuart_console_setup()
490 co->index = 0; in apbuart_console_setup()
492 port = &grlib_apbuart_ports[co->index]; in apbuart_console_setup()
494 spin_lock_init(&port->lock); in apbuart_console_setup()
497 uart_parse_options(options, &baud, &parity, &bits, &flow); in apbuart_console_setup()
501 return uart_set_options(port, co, baud, parity, bits, flow); in apbuart_console_setup()
512 .index = -1,
522 return -ENODEV; in apbuart_console_init()
555 if (op->dev.of_node == grlib_apbuart_nodes[i]) in apbuart_probe()
560 port->dev = &op->dev; in apbuart_probe()
561 port->irq = op->archdata.irqs[0]; in apbuart_probe()
567 printk(KERN_INFO "grlib-apbuart at 0x%llx, irq %d\n", in apbuart_probe()
568 (unsigned long long) port->mapbase, port->irq); in apbuart_probe()
586 .name = "grlib-apbuart",
616 addr = regs->phys_addr; in grlib_apbuart_configure()
620 port->mapbase = addr; in grlib_apbuart_configure()
621 port->membase = ioremap(addr, sizeof(struct grlib_apbuart_regs_map)); in grlib_apbuart_configure()
622 port->irq = 0; in grlib_apbuart_configure()
623 port->iotype = UPIO_MEM; in grlib_apbuart_configure()
624 port->ops = &grlib_apbuart_ops; in grlib_apbuart_configure()
625 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE); in grlib_apbuart_configure()
626 port->flags = UPF_BOOT_AUTOCONF; in grlib_apbuart_configure()
627 port->line = line; in grlib_apbuart_configure()
628 port->uartclk = *freq_hz; in grlib_apbuart_configure()
629 port->fifosize = apbuart_scan_fifo_size((struct uart_port *) port, line); in grlib_apbuart_configure()
638 return line ? 0 : -ENODEV; in grlib_apbuart_configure()