Lines Matching +full:bcm6345 +full:- +full:uart
1 // SPDX-License-Identifier: GPL-2.0
7 * Serial driver for BCM63xx integrated UART.
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
71 * handy uart register accessor
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
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()
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()
291 if ((cstat & port->ignore_status_mask) == 0) in bcm_uart_do_rx()
294 } while (--max_count); in bcm_uart_do_rx()
312 port->fifosize - val, in bcm_uart_do_tx()
329 * process uart interrupt
363 * enable rx & tx operation on uart
375 * disable rx & tx operation on uart
405 * serial core request to initialize uart and start rx operation
423 val |= (port->fifosize / 2) << UART_MCTL_RXFIFOTHRESH_SHIFT; in bcm_uart_startup()
424 val |= (port->fifosize / 2) << UART_MCTL_TXFIFOTHRESH_SHIFT; in bcm_uart_startup()
440 ret = request_irq(port->irq, bcm_uart_interrupt, 0, in bcm_uart_startup()
441 dev_name(port->dev), port); in bcm_uart_startup()
450 * serial core request to flush & disable uart
462 free_irq(port->irq, port); in bcm_uart_shutdown()
466 * serial core request to change current uart setting
478 for (tries = 3; !bcm_uart_tx_empty(port) && tries; tries--) in bcm_uart_set_termios()
481 /* disable uart while changing speed */ in bcm_uart_set_termios()
489 switch (new->c_cflag & CSIZE) { in bcm_uart_set_termios()
505 if (new->c_cflag & CSTOPB) in bcm_uart_set_termios()
511 if (new->c_cflag & PARENB) in bcm_uart_set_termios()
514 if (new->c_cflag & PARODD) in bcm_uart_set_termios()
519 baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16); in bcm_uart_set_termios()
520 quot = uart_get_divisor(port, baud) - 1; in bcm_uart_set_termios()
527 if (UART_ENABLE_MS(port, new->c_cflag)) in bcm_uart_set_termios()
533 port->read_status_mask = UART_FIFO_VALID_MASK; in bcm_uart_set_termios()
534 if (new->c_iflag & INPCK) { in bcm_uart_set_termios()
535 port->read_status_mask |= UART_FIFO_FRAMEERR_MASK; in bcm_uart_set_termios()
536 port->read_status_mask |= UART_FIFO_PARERR_MASK; in bcm_uart_set_termios()
538 if (new->c_iflag & (IGNBRK | BRKINT)) in bcm_uart_set_termios()
539 port->read_status_mask |= UART_FIFO_BRKDET_MASK; in bcm_uart_set_termios()
541 port->ignore_status_mask = 0; in bcm_uart_set_termios()
542 if (new->c_iflag & IGNPAR) in bcm_uart_set_termios()
543 port->ignore_status_mask |= UART_FIFO_PARERR_MASK; in bcm_uart_set_termios()
544 if (new->c_iflag & IGNBRK) in bcm_uart_set_termios()
545 port->ignore_status_mask |= UART_FIFO_BRKDET_MASK; in bcm_uart_set_termios()
546 if (!(new->c_cflag & CREAD)) in bcm_uart_set_termios()
547 port->ignore_status_mask |= UART_FIFO_VALID_MASK; in bcm_uart_set_termios()
549 uart_update_timeout(port, new->c_cflag, baud); in bcm_uart_set_termios()
555 * serial core request to claim uart iomem
564 * serial core request to release uart iomem
579 port->type = PORT_BCM63XX; in bcm_uart_config_port()
590 if (port->type != PORT_BCM63XX) in bcm_uart_verify_port()
591 return -EINVAL; in bcm_uart_verify_port()
592 if (port->irq != serinfo->irq) in bcm_uart_verify_port()
593 return -EINVAL; in bcm_uart_verify_port()
594 if (port->iotype != serinfo->io_type) in bcm_uart_verify_port()
595 return -EINVAL; in bcm_uart_verify_port()
596 if (port->mapbase != (unsigned long)serinfo->iomem_base) in bcm_uart_verify_port()
597 return -EINVAL; in bcm_uart_verify_port()
611 return !(port->fifosize - val); in bcm_uart_tx_full()
668 while (--tmout) { in wait_for_xmitr()
678 if (port->flags & UPF_CONS_FLOW) { in wait_for_xmitr()
680 while (--tmout) { in wait_for_xmitr()
710 port = &ports[co->index]; in bcm_console_write()
728 * console core request to setup given console, find matching uart
739 if (co->index < 0 || co->index >= BCM63XX_NR_UARTS) in bcm_console_setup()
740 return -EINVAL; in bcm_console_setup()
741 port = &ports[co->index]; in bcm_console_setup()
742 if (!port->membase) in bcm_console_setup()
743 return -ENODEV; in bcm_console_setup()
758 .index = -1,
772 struct earlycon_device *dev = con->data; in bcm_early_write()
774 uart_console_write(&dev->port, s, n, bcm_console_putchar); in bcm_early_write()
775 wait_for_xmitr(&dev->port); in bcm_early_write()
781 if (!device->port.membase) in bcm_early_console_setup()
782 return -ENODEV; in bcm_early_console_setup()
784 device->con->write = bcm_early_write; in bcm_early_console_setup()
788 OF_EARLYCON_DECLARE(bcm63xx_uart, "brcm,bcm6345-uart", bcm_early_console_setup);
815 if (pdev->dev.of_node) { in bcm_uart_probe()
816 pdev->id = of_alias_get_id(pdev->dev.of_node, "serial"); in bcm_uart_probe()
818 if (pdev->id < 0) in bcm_uart_probe()
819 pdev->id = of_alias_get_id(pdev->dev.of_node, "uart"); in bcm_uart_probe()
822 if (pdev->id < 0 || pdev->id >= BCM63XX_NR_UARTS) in bcm_uart_probe()
823 return -EINVAL; in bcm_uart_probe()
825 port = &ports[pdev->id]; in bcm_uart_probe()
826 if (port->membase) in bcm_uart_probe()
827 return -EBUSY; in bcm_uart_probe()
830 port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res_mem); in bcm_uart_probe()
831 if (IS_ERR(port->membase)) in bcm_uart_probe()
832 return PTR_ERR(port->membase); in bcm_uart_probe()
833 port->mapbase = res_mem->start; in bcm_uart_probe()
838 port->irq = ret; in bcm_uart_probe()
840 clk = clk_get(&pdev->dev, "refclk"); in bcm_uart_probe()
841 if (IS_ERR(clk) && pdev->dev.of_node) in bcm_uart_probe()
842 clk = of_clk_get(pdev->dev.of_node, 0); in bcm_uart_probe()
845 return -ENODEV; in bcm_uart_probe()
847 port->iotype = UPIO_MEM; in bcm_uart_probe()
848 port->ops = &bcm_uart_ops; in bcm_uart_probe()
849 port->flags = UPF_BOOT_AUTOCONF; in bcm_uart_probe()
850 port->dev = &pdev->dev; in bcm_uart_probe()
851 port->fifosize = 16; in bcm_uart_probe()
852 port->uartclk = clk_get_rate(clk) / 2; in bcm_uart_probe()
853 port->line = pdev->id; in bcm_uart_probe()
854 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_BCM63XX_CONSOLE); in bcm_uart_probe()
859 ports[pdev->id].membase = NULL; in bcm_uart_probe()
873 ports[pdev->id].membase = NULL; in bcm_uart_remove()
877 { .compatible = "brcm,bcm6345-uart" },
919 MODULE_DESCRIPTION("Broadcom 63xx integrated uart driver");