Lines Matching +full:uart +full:- +full:fifosize
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
204 spin_lock_irqsave(&port->lock, flags); in bcm_uart_break_ctl()
213 spin_unlock_irqrestore(&port->lock, flags); in bcm_uart_break_ctl()
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()
292 if ((cstat & port->ignore_status_mask) == 0) in bcm_uart_do_rx()
295 } while (--max_count); in bcm_uart_do_rx()
313 port->fifosize - val, in bcm_uart_do_tx()
330 * process uart interrupt
338 spin_lock(&port->lock); in bcm_uart_interrupt()
359 spin_unlock(&port->lock); in bcm_uart_interrupt()
364 * enable rx & tx operation on uart
376 * disable rx & tx operation on uart
406 * serial core request to initialize uart and start rx operation
424 val |= (port->fifosize / 2) << UART_MCTL_RXFIFOTHRESH_SHIFT; in bcm_uart_startup()
425 val |= (port->fifosize / 2) << UART_MCTL_TXFIFOTHRESH_SHIFT; in bcm_uart_startup()
441 ret = request_irq(port->irq, bcm_uart_interrupt, 0, in bcm_uart_startup()
442 dev_name(port->dev), port); in bcm_uart_startup()
451 * serial core request to flush & disable uart
457 spin_lock_irqsave(&port->lock, flags); in bcm_uart_shutdown()
459 spin_unlock_irqrestore(&port->lock, flags); in bcm_uart_shutdown()
463 free_irq(port->irq, port); in bcm_uart_shutdown()
467 * serial core request to change current uart setting
476 spin_lock_irqsave(&port->lock, flags); in bcm_uart_set_termios()
479 for (tries = 3; !bcm_uart_tx_empty(port) && tries; tries--) in bcm_uart_set_termios()
482 /* disable uart while changing speed */ in bcm_uart_set_termios()
490 switch (new->c_cflag & CSIZE) { in bcm_uart_set_termios()
506 if (new->c_cflag & CSTOPB) in bcm_uart_set_termios()
512 if (new->c_cflag & PARENB) in bcm_uart_set_termios()
515 if (new->c_cflag & PARODD) in bcm_uart_set_termios()
520 baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16); in bcm_uart_set_termios()
521 quot = uart_get_divisor(port, baud) - 1; in bcm_uart_set_termios()
528 if (UART_ENABLE_MS(port, new->c_cflag)) in bcm_uart_set_termios()
534 port->read_status_mask = UART_FIFO_VALID_MASK; in bcm_uart_set_termios()
535 if (new->c_iflag & INPCK) { in bcm_uart_set_termios()
536 port->read_status_mask |= UART_FIFO_FRAMEERR_MASK; in bcm_uart_set_termios()
537 port->read_status_mask |= UART_FIFO_PARERR_MASK; in bcm_uart_set_termios()
539 if (new->c_iflag & (IGNBRK | BRKINT)) in bcm_uart_set_termios()
540 port->read_status_mask |= UART_FIFO_BRKDET_MASK; in bcm_uart_set_termios()
542 port->ignore_status_mask = 0; in bcm_uart_set_termios()
543 if (new->c_iflag & IGNPAR) in bcm_uart_set_termios()
544 port->ignore_status_mask |= UART_FIFO_PARERR_MASK; in bcm_uart_set_termios()
545 if (new->c_iflag & IGNBRK) in bcm_uart_set_termios()
546 port->ignore_status_mask |= UART_FIFO_BRKDET_MASK; in bcm_uart_set_termios()
547 if (!(new->c_cflag & CREAD)) in bcm_uart_set_termios()
548 port->ignore_status_mask |= UART_FIFO_VALID_MASK; in bcm_uart_set_termios()
550 uart_update_timeout(port, new->c_cflag, baud); in bcm_uart_set_termios()
552 spin_unlock_irqrestore(&port->lock, flags); in bcm_uart_set_termios()
556 * serial core request to claim uart iomem
565 * serial core request to release uart iomem
580 port->type = PORT_BCM63XX; in bcm_uart_config_port()
591 if (port->type != PORT_BCM63XX) in bcm_uart_verify_port()
592 return -EINVAL; in bcm_uart_verify_port()
593 if (port->irq != serinfo->irq) in bcm_uart_verify_port()
594 return -EINVAL; in bcm_uart_verify_port()
595 if (port->iotype != serinfo->io_type) in bcm_uart_verify_port()
596 return -EINVAL; in bcm_uart_verify_port()
597 if (port->mapbase != (unsigned long)serinfo->iomem_base) in bcm_uart_verify_port()
598 return -EINVAL; in bcm_uart_verify_port()
612 return !(port->fifosize - val); in bcm_uart_tx_full()
669 while (--tmout) { in wait_for_xmitr()
679 if (port->flags & UPF_CONS_FLOW) { in wait_for_xmitr()
681 while (--tmout) { in wait_for_xmitr()
711 port = &ports[co->index]; in bcm_console_write()
714 if (port->sysrq) { in bcm_console_write()
718 locked = spin_trylock(&port->lock); in bcm_console_write()
720 spin_lock(&port->lock); in bcm_console_write()
731 spin_unlock(&port->lock); in bcm_console_write()
736 * console core request to setup given console, find matching uart
747 if (co->index < 0 || co->index >= BCM63XX_NR_UARTS) in bcm_console_setup()
748 return -EINVAL; in bcm_console_setup()
749 port = &ports[co->index]; in bcm_console_setup()
750 if (!port->membase) in bcm_console_setup()
751 return -ENODEV; in bcm_console_setup()
766 .index = -1,
780 struct earlycon_device *dev = con->data; in bcm_early_write()
782 uart_console_write(&dev->port, s, n, bcm_console_putchar); in bcm_early_write()
783 wait_for_xmitr(&dev->port); in bcm_early_write()
789 if (!device->port.membase) in bcm_early_console_setup()
790 return -ENODEV; in bcm_early_console_setup()
792 device->con->write = bcm_early_write; in bcm_early_console_setup()
796 OF_EARLYCON_DECLARE(bcm63xx_uart, "brcm,bcm6345-uart", bcm_early_console_setup);
823 if (pdev->dev.of_node) { in bcm_uart_probe()
824 pdev->id = of_alias_get_id(pdev->dev.of_node, "serial"); in bcm_uart_probe()
826 if (pdev->id < 0) in bcm_uart_probe()
827 pdev->id = of_alias_get_id(pdev->dev.of_node, "uart"); in bcm_uart_probe()
830 if (pdev->id < 0 || pdev->id >= BCM63XX_NR_UARTS) in bcm_uart_probe()
831 return -EINVAL; in bcm_uart_probe()
833 port = &ports[pdev->id]; in bcm_uart_probe()
834 if (port->membase) in bcm_uart_probe()
835 return -EBUSY; in bcm_uart_probe()
838 port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res_mem); in bcm_uart_probe()
839 if (IS_ERR(port->membase)) in bcm_uart_probe()
840 return PTR_ERR(port->membase); in bcm_uart_probe()
841 port->mapbase = res_mem->start; in bcm_uart_probe()
846 port->irq = ret; in bcm_uart_probe()
848 clk = clk_get(&pdev->dev, "refclk"); in bcm_uart_probe()
849 if (IS_ERR(clk) && pdev->dev.of_node) in bcm_uart_probe()
850 clk = of_clk_get(pdev->dev.of_node, 0); in bcm_uart_probe()
853 return -ENODEV; in bcm_uart_probe()
855 port->iotype = UPIO_MEM; in bcm_uart_probe()
856 port->ops = &bcm_uart_ops; in bcm_uart_probe()
857 port->flags = UPF_BOOT_AUTOCONF; in bcm_uart_probe()
858 port->dev = &pdev->dev; in bcm_uart_probe()
859 port->fifosize = 16; in bcm_uart_probe()
860 port->uartclk = clk_get_rate(clk) / 2; in bcm_uart_probe()
861 port->line = pdev->id; in bcm_uart_probe()
862 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_BCM63XX_CONSOLE); in bcm_uart_probe()
867 ports[pdev->id].membase = NULL; in bcm_uart_probe()
881 ports[pdev->id].membase = NULL; in bcm_uart_remove()
886 { .compatible = "brcm,bcm6345-uart" },
928 MODULE_DESCRIPTION("Broadcom 63xx integrated uart driver");