Lines Matching +full:cts +full:- +full:override
1 // SPDX-License-Identifier: GPL-2.0+
3 * altera_uart.c -- Altera UART driver
5 * Based on mcf.c -- Freescale ColdFire UART driver
7 * (C) Copyright 2003-2007, Greg Ungerer <gerg@snapgear.com>
54 #define ALTERA_UART_STATUS_DCTS_MSK 0x0400 /* CTS logic-level change */
55 #define ALTERA_UART_STATUS_CTS_MSK 0x0800 /* CTS logic state */
70 #define ALTERA_UART_CONTROL_DCTS_MSK 0x0400 /* Interrupt on CTS change */
75 * Local per-uart structure.
86 return readl(port->membase + (reg << port->regshift)); in altera_uart_readl()
91 writel(dat, port->membase + (reg << port->regshift)); in altera_uart_writel()
107 sigs |= (pp->sigs & TIOCM_RTS); in altera_uart_get_mctrl()
114 unsigned short imr = pp->imr; in altera_uart_update_ctrl_reg()
120 if (!pp->port.irq) in altera_uart_update_ctrl_reg()
123 altera_uart_writel(&pp->port, imr, ALTERA_UART_CONTROL_REG); in altera_uart_update_ctrl_reg()
130 pp->sigs = sigs; in altera_uart_set_mctrl()
132 pp->imr |= ALTERA_UART_CONTROL_RTS_MSK; in altera_uart_set_mctrl()
134 pp->imr &= ~ALTERA_UART_CONTROL_RTS_MSK; in altera_uart_set_mctrl()
142 pp->imr |= ALTERA_UART_CONTROL_TRDY_MSK; in altera_uart_start_tx()
150 pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK; in altera_uart_stop_tx()
158 pp->imr &= ~ALTERA_UART_CONTROL_RRDY_MSK; in altera_uart_stop_rx()
167 spin_lock_irqsave(&port->lock, flags); in altera_uart_break_ctl()
168 if (break_state == -1) in altera_uart_break_ctl()
169 pp->imr |= ALTERA_UART_CONTROL_TRBK_MSK; in altera_uart_break_ctl()
171 pp->imr &= ~ALTERA_UART_CONTROL_TRBK_MSK; in altera_uart_break_ctl()
173 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_break_ctl()
184 baudclk = port->uartclk / baud; in altera_uart_set_termios()
190 spin_lock_irqsave(&port->lock, flags); in altera_uart_set_termios()
191 uart_update_timeout(port, termios->c_cflag, baud); in altera_uart_set_termios()
193 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_set_termios()
196 * FIXME: port->read_status_mask and port->ignore_status_mask in altera_uart_set_termios()
204 struct uart_port *port = &pp->port; in altera_uart_rx_chars()
212 port->icount.rx++; in altera_uart_rx_chars()
219 port->icount.brk++; in altera_uart_rx_chars()
223 port->icount.parity++; in altera_uart_rx_chars()
225 port->icount.overrun++; in altera_uart_rx_chars()
227 port->icount.frame++; in altera_uart_rx_chars()
230 status &= port->read_status_mask; in altera_uart_rx_chars()
246 tty_flip_buffer_push(&port->state->port); in altera_uart_rx_chars()
251 struct uart_port *port = &pp->port; in altera_uart_tx_chars()
252 struct circ_buf *xmit = &port->state->xmit; in altera_uart_tx_chars()
254 if (port->x_char) { in altera_uart_tx_chars()
255 /* Send special char - probably flow control */ in altera_uart_tx_chars()
256 altera_uart_writel(port, port->x_char, ALTERA_UART_TXDATA_REG); in altera_uart_tx_chars()
257 port->x_char = 0; in altera_uart_tx_chars()
258 port->icount.tx++; in altera_uart_tx_chars()
264 if (xmit->head == xmit->tail) in altera_uart_tx_chars()
266 altera_uart_writel(port, xmit->buf[xmit->tail], in altera_uart_tx_chars()
268 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); in altera_uart_tx_chars()
269 port->icount.tx++; in altera_uart_tx_chars()
275 if (xmit->head == xmit->tail) { in altera_uart_tx_chars()
276 pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK; in altera_uart_tx_chars()
287 isr = altera_uart_readl(port, ALTERA_UART_STATUS_REG) & pp->imr; in altera_uart_interrupt()
289 spin_lock(&port->lock); in altera_uart_interrupt()
294 spin_unlock(&port->lock); in altera_uart_interrupt()
302 struct uart_port *port = &pp->port; in altera_uart_timer()
305 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); in altera_uart_timer()
310 port->type = PORT_ALTERA_UART; in altera_uart_config_port()
323 if (!port->irq) { in altera_uart_startup()
324 timer_setup(&pp->tmr, altera_uart_timer, 0); in altera_uart_startup()
325 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); in altera_uart_startup()
329 ret = request_irq(port->irq, altera_uart_interrupt, 0, in altera_uart_startup()
333 "interrupt vector=%d\n", port->line, port->irq); in altera_uart_startup()
338 spin_lock_irqsave(&port->lock, flags); in altera_uart_startup()
341 pp->imr = ALTERA_UART_CONTROL_RRDY_MSK; in altera_uart_startup()
344 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_startup()
354 spin_lock_irqsave(&port->lock, flags); in altera_uart_shutdown()
357 pp->imr = 0; in altera_uart_shutdown()
360 spin_unlock_irqrestore(&port->lock, flags); in altera_uart_shutdown()
362 if (port->irq) in altera_uart_shutdown()
363 free_irq(port->irq, port); in altera_uart_shutdown()
365 del_timer_sync(&pp->tmr); in altera_uart_shutdown()
370 return (port->type == PORT_ALTERA_UART) ? "Altera UART" : NULL; in altera_uart_type()
387 if ((ser->type != PORT_UNKNOWN) && (ser->type != PORT_ALTERA_UART)) in altera_uart_verify_port()
388 return -EINVAL; in altera_uart_verify_port()
453 struct uart_port *port = &(altera_uart_ports + co->index)->port; in altera_uart_console_write()
466 if (co->index < 0 || co->index >= CONFIG_SERIAL_ALTERA_UART_MAXPORTS) in altera_uart_console_setup()
467 return -EINVAL; in altera_uart_console_setup()
468 port = &altera_uart_ports[co->index].port; in altera_uart_console_setup()
469 if (!port->membase) in altera_uart_console_setup()
470 return -ENODEV; in altera_uart_console_setup()
486 .index = -1,
503 struct earlycon_device *dev = co->data; in altera_uart_earlycon_write()
505 uart_console_write(&dev->port, s, count, altera_uart_console_putc); in altera_uart_earlycon_write()
511 struct uart_port *port = &dev->port; in altera_uart_earlycon_setup()
513 if (!port->membase) in altera_uart_earlycon_setup()
514 return -ENODEV; in altera_uart_earlycon_setup()
520 if (dev->baud) { in altera_uart_earlycon_setup()
521 unsigned int baudclk = port->uartclk / dev->baud; in altera_uart_earlycon_setup()
526 dev->con->write = altera_uart_earlycon_write; in altera_uart_earlycon_setup()
530 OF_EARLYCON_DECLARE(uart, "altr,uart-1.0", altera_uart_earlycon_setup);
553 struct altera_uart_platform_uart *platp = dev_get_platdata(&pdev->dev); in altera_uart_probe()
557 int i = pdev->id; in altera_uart_probe()
560 /* if id is -1 scan for a free id and use that one */ in altera_uart_probe()
561 if (i == -1) { in altera_uart_probe()
568 return -EINVAL; in altera_uart_probe()
574 port->mapbase = res_mem->start; in altera_uart_probe()
576 port->mapbase = platp->mapbase; in altera_uart_probe()
578 return -EINVAL; in altera_uart_probe()
582 port->irq = res_irq->start; in altera_uart_probe()
584 port->irq = platp->irq; in altera_uart_probe()
586 /* Check platform data first so we can override device node data */ in altera_uart_probe()
588 port->uartclk = platp->uartclk; in altera_uart_probe()
590 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", in altera_uart_probe()
591 &port->uartclk); in altera_uart_probe()
596 port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE); in altera_uart_probe()
597 if (!port->membase) in altera_uart_probe()
598 return -ENOMEM; in altera_uart_probe()
601 port->regshift = platp->bus_shift; in altera_uart_probe()
603 port->regshift = 0; in altera_uart_probe()
605 port->line = i; in altera_uart_probe()
606 port->type = PORT_ALTERA_UART; in altera_uart_probe()
607 port->iotype = SERIAL_IO_MEM; in altera_uart_probe()
608 port->ops = &altera_uart_ops; in altera_uart_probe()
609 port->flags = UPF_BOOT_AUTOCONF; in altera_uart_probe()
610 port->dev = &pdev->dev; in altera_uart_probe()
625 port->mapbase = 0; in altera_uart_remove()
626 iounmap(port->membase); in altera_uart_remove()
634 { .compatible = "ALTR,uart-1.0", },
635 { .compatible = "altr,uart-1.0", },