Lines Matching +full:disable +full:- +full:eop
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 <[email protected]>
53 #define ALTERA_UART_STATUS_DCTS_MSK 0x0400 /* CTS logic-level change */
55 #define ALTERA_UART_STATUS_EOP_MSK 0x1000 /* EOP written/read */
71 #define ALTERA_UART_CONTROL_EOP_MSK 0x1000 /* Interrupt on EOP */
74 * Local per-uart structure.
85 return readl(port->membase + (reg << port->regshift)); in altera_uart_readl()
90 writel(dat, port->membase + (reg << port->regshift)); in altera_uart_writel()
106 sigs |= (pp->sigs & TIOCM_RTS); in altera_uart_get_mctrl()
113 unsigned short imr = pp->imr; in altera_uart_update_ctrl_reg()
119 if (!pp->port.irq) in altera_uart_update_ctrl_reg()
122 altera_uart_writel(&pp->port, imr, ALTERA_UART_CONTROL_REG); in altera_uart_update_ctrl_reg()
129 pp->sigs = sigs; in altera_uart_set_mctrl()
131 pp->imr |= ALTERA_UART_CONTROL_RTS_MSK; in altera_uart_set_mctrl()
133 pp->imr &= ~ALTERA_UART_CONTROL_RTS_MSK; in altera_uart_set_mctrl()
141 pp->imr |= ALTERA_UART_CONTROL_TRDY_MSK; in altera_uart_start_tx()
149 pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK; in altera_uart_stop_tx()
157 pp->imr &= ~ALTERA_UART_CONTROL_RRDY_MSK; in altera_uart_stop_rx()
167 if (break_state == -1) in altera_uart_break_ctl()
168 pp->imr |= ALTERA_UART_CONTROL_TRBK_MSK; in altera_uart_break_ctl()
170 pp->imr &= ~ALTERA_UART_CONTROL_TRBK_MSK; in altera_uart_break_ctl()
183 baudclk = port->uartclk / baud; in altera_uart_set_termios()
190 uart_update_timeout(port, termios->c_cflag, baud); in altera_uart_set_termios()
195 * FIXME: port->read_status_mask and port->ignore_status_mask in altera_uart_set_termios()
210 port->icount.rx++; in altera_uart_rx_chars()
217 port->icount.brk++; in altera_uart_rx_chars()
221 port->icount.parity++; in altera_uart_rx_chars()
223 port->icount.overrun++; in altera_uart_rx_chars()
225 port->icount.frame++; in altera_uart_rx_chars()
228 status &= port->read_status_mask; in altera_uart_rx_chars()
244 tty_flip_buffer_push(&port->state->port); in altera_uart_rx_chars()
264 isr = altera_uart_readl(port, ALTERA_UART_STATUS_REG) & pp->imr; in altera_uart_interrupt()
279 struct uart_port *port = &pp->port; in altera_uart_timer()
282 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); in altera_uart_timer()
287 port->type = PORT_ALTERA_UART; in altera_uart_config_port()
300 if (!port->irq) { in altera_uart_startup()
301 timer_setup(&pp->tmr, altera_uart_timer, 0); in altera_uart_startup()
302 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); in altera_uart_startup()
306 ret = request_irq(port->irq, altera_uart_interrupt, 0, in altera_uart_startup()
307 dev_name(port->dev), port); in altera_uart_startup()
309 dev_err(port->dev, "unable to attach Altera UART %d interrupt vector=%d\n", in altera_uart_startup()
310 port->line, port->irq); in altera_uart_startup()
318 pp->imr = ALTERA_UART_CONTROL_RRDY_MSK; in altera_uart_startup()
333 /* Disable all interrupts now */ in altera_uart_shutdown()
334 pp->imr = 0; in altera_uart_shutdown()
339 if (port->irq) in altera_uart_shutdown()
340 free_irq(port->irq, port); in altera_uart_shutdown()
342 del_timer_sync(&pp->tmr); in altera_uart_shutdown()
347 return (port->type == PORT_ALTERA_UART) ? "Altera UART" : NULL; in altera_uart_type()
364 if ((ser->type != PORT_UNKNOWN) && (ser->type != PORT_ALTERA_UART)) in altera_uart_verify_port()
365 return -EINVAL; in altera_uart_verify_port()
430 struct uart_port *port = &(altera_uart_ports + co->index)->port; in altera_uart_console_write()
443 if (co->index < 0 || co->index >= CONFIG_SERIAL_ALTERA_UART_MAXPORTS) in altera_uart_console_setup()
444 return -EINVAL; in altera_uart_console_setup()
445 port = &altera_uart_ports[co->index].port; in altera_uart_console_setup()
446 if (!port->membase) in altera_uart_console_setup()
447 return -ENODEV; in altera_uart_console_setup()
463 .index = -1,
480 struct earlycon_device *dev = co->data; in altera_uart_earlycon_write()
482 uart_console_write(&dev->port, s, count, altera_uart_console_putc); in altera_uart_earlycon_write()
488 struct uart_port *port = &dev->port; in altera_uart_earlycon_setup()
490 if (!port->membase) in altera_uart_earlycon_setup()
491 return -ENODEV; in altera_uart_earlycon_setup()
497 if (dev->baud) { in altera_uart_earlycon_setup()
498 unsigned int baudclk = port->uartclk / dev->baud; in altera_uart_earlycon_setup()
503 dev->con->write = altera_uart_earlycon_write; in altera_uart_earlycon_setup()
507 OF_EARLYCON_DECLARE(uart, "altr,uart-1.0", altera_uart_earlycon_setup);
530 struct altera_uart_platform_uart *platp = dev_get_platdata(&pdev->dev); in altera_uart_probe()
533 int i = pdev->id; in altera_uart_probe()
536 /* if id is -1 scan for a free id and use that one */ in altera_uart_probe()
537 if (i == -1) { in altera_uart_probe()
544 return -EINVAL; in altera_uart_probe()
550 port->mapbase = res_mem->start; in altera_uart_probe()
552 port->mapbase = platp->mapbase; in altera_uart_probe()
554 return -EINVAL; in altera_uart_probe()
557 if (ret < 0 && ret != -ENXIO) in altera_uart_probe()
560 port->irq = ret; in altera_uart_probe()
562 port->irq = platp->irq; in altera_uart_probe()
566 port->uartclk = platp->uartclk; in altera_uart_probe()
568 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", in altera_uart_probe()
569 &port->uartclk); in altera_uart_probe()
574 port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE); in altera_uart_probe()
575 if (!port->membase) in altera_uart_probe()
576 return -ENOMEM; in altera_uart_probe()
579 port->regshift = platp->bus_shift; in altera_uart_probe()
581 port->regshift = 0; in altera_uart_probe()
583 port->line = i; in altera_uart_probe()
584 port->type = PORT_ALTERA_UART; in altera_uart_probe()
585 port->iotype = SERIAL_IO_MEM; in altera_uart_probe()
586 port->ops = &altera_uart_ops; in altera_uart_probe()
587 port->flags = UPF_BOOT_AUTOCONF; in altera_uart_probe()
588 port->dev = &pdev->dev; in altera_uart_probe()
603 port->mapbase = 0; in altera_uart_remove()
604 iounmap(port->membase); in altera_uart_remove()
610 { .compatible = "ALTR,uart-1.0", },
611 { .compatible = "altr,uart-1.0", },