Lines Matching +full:8810 +full:pl +full:- +full:uart

1 // SPDX-License-Identifier: GPL-2.0+
128 writel(val, port->membase + off); in rda_uart_write()
133 return readl(port->membase + off); in rda_uart_read()
142 spin_lock_irqsave(&port->lock, flags); in rda_uart_tx_empty()
147 spin_unlock_irqrestore(&port->lock, flags); in rda_uart_tx_empty()
236 clk_set_rate(rda_port->clk, baud * 8); in rda_uart_change_baudrate()
249 spin_lock_irqsave(&port->lock, flags); in rda_uart_set_termios()
251 baud = uart_get_baud_rate(port, termios, old, 9600, port->uartclk / 4); in rda_uart_set_termios()
258 switch (termios->c_cflag & CSIZE) { in rda_uart_set_termios()
261 dev_warn(port->dev, "bit size not supported, using 7 bits\n"); in rda_uart_set_termios()
265 termios->c_cflag &= ~CSIZE; in rda_uart_set_termios()
266 termios->c_cflag |= CS7; in rda_uart_set_termios()
274 if (termios->c_cflag & CSTOPB) in rda_uart_set_termios()
280 if (termios->c_cflag & PARENB) { in rda_uart_set_termios()
284 if (termios->c_cflag & CMSPAR) { in rda_uart_set_termios()
285 if (termios->c_cflag & PARODD) in rda_uart_set_termios()
289 } else if (termios->c_cflag & PARODD) { in rda_uart_set_termios()
299 if (termios->c_cflag & CRTSCTS) { in rda_uart_set_termios()
325 /* update the per-port timeout */ in rda_uart_set_termios()
326 uart_update_timeout(port, termios->c_cflag, baud); in rda_uart_set_termios()
328 spin_unlock_irqrestore(&port->lock, flags); in rda_uart_set_termios()
333 struct circ_buf *xmit = &port->state->xmit; in rda_uart_send_chars()
340 if (port->x_char) { in rda_uart_send_chars()
345 rda_uart_write(port, port->x_char, RDA_UART_RXTX_BUFFER); in rda_uart_send_chars()
346 port->icount.tx++; in rda_uart_send_chars()
347 port->x_char = 0; in rda_uart_send_chars()
354 ch = xmit->buf[xmit->tail]; in rda_uart_send_chars()
363 /* Re-enable Tx FIFO interrupt */ in rda_uart_send_chars()
379 port->icount.parity++; in rda_uart_receive_chars()
384 port->icount.frame++; in rda_uart_receive_chars()
389 port->icount.overrun++; in rda_uart_receive_chars()
396 port->icount.rx++; in rda_uart_receive_chars()
397 tty_insert_flip_char(&port->state->port, val, flag); in rda_uart_receive_chars()
402 tty_flip_buffer_push(&port->state->port); in rda_uart_receive_chars()
411 spin_lock_irqsave(&port->lock, flags); in rda_interrupt()
428 spin_unlock_irqrestore(&port->lock, flags); in rda_interrupt()
439 spin_lock_irqsave(&port->lock, flags); in rda_uart_startup()
441 spin_unlock_irqrestore(&port->lock, flags); in rda_uart_startup()
443 ret = request_irq(port->irq, rda_interrupt, IRQF_NO_SUSPEND, in rda_uart_startup()
444 "rda-uart", port); in rda_uart_startup()
448 spin_lock_irqsave(&port->lock, flags); in rda_uart_startup()
459 spin_unlock_irqrestore(&port->lock, flags); in rda_uart_startup()
469 spin_lock_irqsave(&port->lock, flags); in rda_uart_shutdown()
478 spin_unlock_irqrestore(&port->lock, flags); in rda_uart_shutdown()
483 return (port->type == PORT_RDA) ? "rda-uart" : NULL; in rda_uart_type()
488 struct platform_device *pdev = to_platform_device(port->dev); in rda_uart_request_port()
493 return -ENXIO; in rda_uart_request_port()
495 if (!devm_request_mem_region(port->dev, port->mapbase, in rda_uart_request_port()
496 resource_size(res), dev_name(port->dev))) in rda_uart_request_port()
497 return -EBUSY; in rda_uart_request_port()
499 if (port->flags & UPF_IOREMAP) { in rda_uart_request_port()
500 port->membase = devm_ioremap(port->dev, port->mapbase, in rda_uart_request_port()
502 if (!port->membase) in rda_uart_request_port()
503 return -EBUSY; in rda_uart_request_port()
514 port->type = PORT_RDA; in rda_uart_config_port()
518 spin_lock_irqsave(&port->lock, irq_flags); in rda_uart_config_port()
526 spin_unlock_irqrestore(&port->lock, irq_flags); in rda_uart_config_port()
531 struct platform_device *pdev = to_platform_device(port->dev); in rda_uart_release_port()
538 if (port->flags & UPF_IOREMAP) { in rda_uart_release_port()
539 devm_release_mem_region(port->dev, port->mapbase, in rda_uart_release_port()
541 devm_iounmap(port->dev, port->membase); in rda_uart_release_port()
542 port->membase = NULL; in rda_uart_release_port()
549 if (port->type != PORT_RDA) in rda_uart_verify_port()
550 return -EINVAL; in rda_uart_verify_port()
552 if (port->irq != ser->irq) in rda_uart_verify_port()
553 return -EINVAL; in rda_uart_verify_port()
579 if (!port->membase) in rda_console_putchar()
597 if (port->sysrq) { in rda_uart_port_write()
600 locked = spin_trylock(&port->lock); in rda_uart_port_write()
602 spin_lock(&port->lock); in rda_uart_port_write()
618 spin_unlock(&port->lock); in rda_uart_port_write()
628 rda_port = rda_uart_ports[co->index]; in rda_uart_console_write()
632 rda_uart_port_write(&rda_port->port, s, count); in rda_uart_console_write()
643 if (co->index < 0 || co->index >= RDA_UART_PORT_NUM) in rda_uart_console_setup()
644 return -EINVAL; in rda_uart_console_setup()
646 rda_port = rda_uart_ports[co->index]; in rda_uart_console_setup()
647 if (!rda_port || !rda_port->port.membase) in rda_uart_console_setup()
648 return -ENODEV; in rda_uart_console_setup()
653 return uart_set_options(&rda_port->port, co, baud, parity, bits, flow); in rda_uart_console_setup()
662 .index = -1,
678 struct earlycon_device *dev = co->data; in rda_uart_early_console_write()
680 rda_uart_port_write(&dev->port, s, count); in rda_uart_early_console_write()
686 if (!device->port.membase) in rda_uart_early_console_setup()
687 return -ENODEV; in rda_uart_early_console_setup()
689 device->con->write = rda_uart_early_console_write; in rda_uart_early_console_setup()
694 OF_EARLYCON_DECLARE(rda, "rda,8810pl-uart",
704 .driver_name = "rda-uart",
711 { .compatible = "rda,8810pl-uart" },
722 if (pdev->dev.of_node) in rda_uart_probe()
723 pdev->id = of_alias_get_id(pdev->dev.of_node, "serial"); in rda_uart_probe()
725 if (pdev->id < 0 || pdev->id >= RDA_UART_PORT_NUM) { in rda_uart_probe()
726 dev_err(&pdev->dev, "id %d out of range\n", pdev->id); in rda_uart_probe()
727 return -EINVAL; in rda_uart_probe()
732 dev_err(&pdev->dev, "could not get mem\n"); in rda_uart_probe()
733 return -ENODEV; in rda_uart_probe()
740 if (rda_uart_ports[pdev->id]) { in rda_uart_probe()
741 dev_err(&pdev->dev, "port %d already allocated\n", pdev->id); in rda_uart_probe()
742 return -EBUSY; in rda_uart_probe()
745 rda_port = devm_kzalloc(&pdev->dev, sizeof(*rda_port), GFP_KERNEL); in rda_uart_probe()
747 return -ENOMEM; in rda_uart_probe()
749 rda_port->clk = devm_clk_get(&pdev->dev, NULL); in rda_uart_probe()
750 if (IS_ERR(rda_port->clk)) { in rda_uart_probe()
751 dev_err(&pdev->dev, "could not get clk\n"); in rda_uart_probe()
752 return PTR_ERR(rda_port->clk); in rda_uart_probe()
755 rda_port->port.dev = &pdev->dev; in rda_uart_probe()
756 rda_port->port.regshift = 0; in rda_uart_probe()
757 rda_port->port.line = pdev->id; in rda_uart_probe()
758 rda_port->port.type = PORT_RDA; in rda_uart_probe()
759 rda_port->port.iotype = UPIO_MEM; in rda_uart_probe()
760 rda_port->port.mapbase = res_mem->start; in rda_uart_probe()
761 rda_port->port.irq = irq; in rda_uart_probe()
762 rda_port->port.uartclk = clk_get_rate(rda_port->clk); in rda_uart_probe()
763 if (rda_port->port.uartclk == 0) { in rda_uart_probe()
764 dev_err(&pdev->dev, "clock rate is zero\n"); in rda_uart_probe()
765 return -EINVAL; in rda_uart_probe()
767 rda_port->port.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | in rda_uart_probe()
769 rda_port->port.x_char = 0; in rda_uart_probe()
770 rda_port->port.fifosize = RDA_UART_TX_FIFO_SIZE; in rda_uart_probe()
771 rda_port->port.ops = &rda_uart_ops; in rda_uart_probe()
773 rda_uart_ports[pdev->id] = rda_port; in rda_uart_probe()
776 ret = uart_add_one_port(&rda_uart_driver, &rda_port->port); in rda_uart_probe()
778 rda_uart_ports[pdev->id] = NULL; in rda_uart_probe()
787 uart_remove_one_port(&rda_uart_driver, &rda_port->port); in rda_uart_remove()
788 rda_uart_ports[pdev->id] = NULL; in rda_uart_remove()
797 .name = "rda-uart",