Lines Matching +full:serial +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0
7 * Serial driver for BCM63xx integrated UART.
23 #include <linux/serial.h>
37 * - rx fifo full
38 * - rx fifo above threshold
39 * - rx fifo not empty for too long
53 * - tx fifo empty
54 * - tx fifo below threshold
76 return __raw_readl(port->membase + offset); in bcm_uart_readl()
82 __raw_writel(value, port->membase + offset); in bcm_uart_writel()
86 * serial core request to check if uart tx fifo is empty
97 * serial core request to set RTS and DTR pin state and loopback mode
121 * serial core request to return RI, CTS, DCD and DSR pin state
141 * serial core request to disable tx ASAP (used for flow control)
157 * serial core request to (re)enable tx
173 * serial core request to stop rx, called before port shutdown
185 * serial core request to enable modem status interrupt reporting
197 * serial core request to start/stop emitting break char
221 return (port->type == PORT_BCM63XX) ? "bcm63xx_uart" : NULL; in bcm_uart_type()
229 struct tty_port *tty_port = &port->state->port; in bcm_uart_do_rx()
234 * serial port */ in bcm_uart_do_rx()
253 port->icount.overrun++; in bcm_uart_do_rx()
261 port->icount.rx++; in bcm_uart_do_rx()
268 port->icount.brk++; in bcm_uart_do_rx()
274 port->icount.parity++; in bcm_uart_do_rx()
276 port->icount.frame++; in bcm_uart_do_rx()
279 cstat &= port->read_status_mask; in bcm_uart_do_rx()
292 if ((cstat & port->ignore_status_mask) == 0) in bcm_uart_do_rx()
295 } while (--max_count); in bcm_uart_do_rx()
313 pending = uart_port_tx_limited(port, ch, port->fifosize - val, in bcm_uart_do_tx()
403 * serial core request to initialize uart and start rx operation
421 val |= (port->fifosize / 2) << UART_MCTL_RXFIFOTHRESH_SHIFT; in bcm_uart_startup()
422 val |= (port->fifosize / 2) << UART_MCTL_TXFIFOTHRESH_SHIFT; in bcm_uart_startup()
438 ret = request_irq(port->irq, bcm_uart_interrupt, 0, in bcm_uart_startup()
439 dev_name(port->dev), port); in bcm_uart_startup()
448 * serial core request to flush & disable uart
460 free_irq(port->irq, port); in bcm_uart_shutdown()
464 * serial core request to change current uart setting
476 for (tries = 3; !bcm_uart_tx_empty(port) && tries; tries--) in bcm_uart_set_termios()
487 switch (new->c_cflag & CSIZE) { in bcm_uart_set_termios()
503 if (new->c_cflag & CSTOPB) in bcm_uart_set_termios()
509 if (new->c_cflag & PARENB) in bcm_uart_set_termios()
512 if (new->c_cflag & PARODD) in bcm_uart_set_termios()
517 baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16); in bcm_uart_set_termios()
518 quot = uart_get_divisor(port, baud) - 1; in bcm_uart_set_termios()
525 if (UART_ENABLE_MS(port, new->c_cflag)) in bcm_uart_set_termios()
531 port->read_status_mask = UART_FIFO_VALID_MASK; in bcm_uart_set_termios()
532 if (new->c_iflag & INPCK) { in bcm_uart_set_termios()
533 port->read_status_mask |= UART_FIFO_FRAMEERR_MASK; in bcm_uart_set_termios()
534 port->read_status_mask |= UART_FIFO_PARERR_MASK; in bcm_uart_set_termios()
536 if (new->c_iflag & (IGNBRK | BRKINT)) in bcm_uart_set_termios()
537 port->read_status_mask |= UART_FIFO_BRKDET_MASK; in bcm_uart_set_termios()
539 port->ignore_status_mask = 0; in bcm_uart_set_termios()
540 if (new->c_iflag & IGNPAR) in bcm_uart_set_termios()
541 port->ignore_status_mask |= UART_FIFO_PARERR_MASK; in bcm_uart_set_termios()
542 if (new->c_iflag & IGNBRK) in bcm_uart_set_termios()
543 port->ignore_status_mask |= UART_FIFO_BRKDET_MASK; in bcm_uart_set_termios()
544 if (!(new->c_cflag & CREAD)) in bcm_uart_set_termios()
545 port->ignore_status_mask |= UART_FIFO_VALID_MASK; in bcm_uart_set_termios()
547 uart_update_timeout(port, new->c_cflag, baud); in bcm_uart_set_termios()
553 * serial core request to claim uart iomem
562 * serial core request to release uart iomem
570 * serial core request to do any port required autoconfiguration
577 port->type = PORT_BCM63XX; in bcm_uart_config_port()
582 * serial core request to check that port information in serinfo are
588 if (port->type != PORT_BCM63XX) in bcm_uart_verify_port()
589 return -EINVAL; in bcm_uart_verify_port()
590 if (port->irq != serinfo->irq) in bcm_uart_verify_port()
591 return -EINVAL; in bcm_uart_verify_port()
592 if (port->iotype != serinfo->io_type) in bcm_uart_verify_port()
593 return -EINVAL; in bcm_uart_verify_port()
594 if (port->mapbase != (unsigned long)serinfo->iomem_base) in bcm_uart_verify_port()
595 return -EINVAL; in bcm_uart_verify_port()
609 return !(port->fifosize - val); in bcm_uart_tx_full()
633 /* serial core callbacks */
666 while (--tmout) { in wait_for_xmitr()
676 if (port->flags & UPF_CONS_FLOW) { in wait_for_xmitr()
678 while (--tmout) { in wait_for_xmitr()
708 port = &ports[co->index]; in bcm_console_write()
711 if (port->sysrq) { in bcm_console_write()
744 if (co->index < 0 || co->index >= BCM63XX_NR_UARTS) in bcm_console_setup()
745 return -EINVAL; in bcm_console_setup()
746 port = &ports[co->index]; in bcm_console_setup()
747 if (!port->membase) in bcm_console_setup()
748 return -ENODEV; in bcm_console_setup()
763 .index = -1,
777 struct earlycon_device *dev = con->data; in bcm_early_write()
779 uart_console_write(&dev->port, s, n, bcm_console_putchar); in bcm_early_write()
780 wait_for_xmitr(&dev->port); in bcm_early_write()
786 if (!device->port.membase) in bcm_early_console_setup()
787 return -ENODEV; in bcm_early_console_setup()
789 device->con->write = bcm_early_write; in bcm_early_console_setup()
793 OF_EARLYCON_DECLARE(bcm63xx_uart, "brcm,bcm6345-uart", bcm_early_console_setup);
820 if (pdev->dev.of_node) { in bcm_uart_probe()
821 pdev->id = of_alias_get_id(pdev->dev.of_node, "serial"); in bcm_uart_probe()
823 if (pdev->id < 0) in bcm_uart_probe()
824 pdev->id = of_alias_get_id(pdev->dev.of_node, "uart"); in bcm_uart_probe()
827 if (pdev->id < 0 || pdev->id >= BCM63XX_NR_UARTS) in bcm_uart_probe()
828 return -EINVAL; in bcm_uart_probe()
830 port = &ports[pdev->id]; in bcm_uart_probe()
831 if (port->membase) in bcm_uart_probe()
832 return -EBUSY; in bcm_uart_probe()
835 port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res_mem); in bcm_uart_probe()
836 if (IS_ERR(port->membase)) in bcm_uart_probe()
837 return PTR_ERR(port->membase); in bcm_uart_probe()
838 port->mapbase = res_mem->start; in bcm_uart_probe()
843 port->irq = ret; in bcm_uart_probe()
845 clk = clk_get(&pdev->dev, "refclk"); in bcm_uart_probe()
846 if (IS_ERR(clk) && pdev->dev.of_node) in bcm_uart_probe()
847 clk = of_clk_get(pdev->dev.of_node, 0); in bcm_uart_probe()
850 return -ENODEV; in bcm_uart_probe()
852 port->iotype = UPIO_MEM; in bcm_uart_probe()
853 port->ops = &bcm_uart_ops; in bcm_uart_probe()
854 port->flags = UPF_BOOT_AUTOCONF; in bcm_uart_probe()
855 port->dev = &pdev->dev; in bcm_uart_probe()
856 port->fifosize = 16; in bcm_uart_probe()
857 port->uartclk = clk_get_rate(clk) / 2; in bcm_uart_probe()
858 port->line = pdev->id; in bcm_uart_probe()
859 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_BCM63XX_CONSOLE); in bcm_uart_probe()
864 ports[pdev->id].membase = NULL; in bcm_uart_probe()
878 ports[pdev->id].membase = NULL; in bcm_uart_remove()
882 { .compatible = "brcm,bcm6345-uart" },