Lines Matching full:port
73 static inline unsigned int bcm_uart_readl(struct uart_port *port, in bcm_uart_readl() argument
76 return __raw_readl(port->membase + offset); in bcm_uart_readl()
79 static inline void bcm_uart_writel(struct uart_port *port, in bcm_uart_writel() argument
82 __raw_writel(value, port->membase + offset); in bcm_uart_writel()
88 static unsigned int bcm_uart_tx_empty(struct uart_port *port) in bcm_uart_tx_empty() argument
92 val = bcm_uart_readl(port, UART_IR_REG); in bcm_uart_tx_empty()
99 static void bcm_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) in bcm_uart_set_mctrl() argument
103 val = bcm_uart_readl(port, UART_MCTL_REG); in bcm_uart_set_mctrl()
110 bcm_uart_writel(port, val, UART_MCTL_REG); in bcm_uart_set_mctrl()
112 val = bcm_uart_readl(port, UART_CTL_REG); in bcm_uart_set_mctrl()
117 bcm_uart_writel(port, val, UART_CTL_REG); in bcm_uart_set_mctrl()
123 static unsigned int bcm_uart_get_mctrl(struct uart_port *port) in bcm_uart_get_mctrl() argument
128 val = bcm_uart_readl(port, UART_EXTINP_REG); in bcm_uart_get_mctrl()
143 static void bcm_uart_stop_tx(struct uart_port *port) in bcm_uart_stop_tx() argument
147 val = bcm_uart_readl(port, UART_CTL_REG); in bcm_uart_stop_tx()
149 bcm_uart_writel(port, val, UART_CTL_REG); in bcm_uart_stop_tx()
151 val = bcm_uart_readl(port, UART_IR_REG); in bcm_uart_stop_tx()
153 bcm_uart_writel(port, val, UART_IR_REG); in bcm_uart_stop_tx()
159 static void bcm_uart_start_tx(struct uart_port *port) in bcm_uart_start_tx() argument
163 val = bcm_uart_readl(port, UART_IR_REG); in bcm_uart_start_tx()
165 bcm_uart_writel(port, val, UART_IR_REG); in bcm_uart_start_tx()
167 val = bcm_uart_readl(port, UART_CTL_REG); in bcm_uart_start_tx()
169 bcm_uart_writel(port, val, UART_CTL_REG); in bcm_uart_start_tx()
173 * serial core request to stop rx, called before port shutdown
175 static void bcm_uart_stop_rx(struct uart_port *port) in bcm_uart_stop_rx() argument
179 val = bcm_uart_readl(port, UART_IR_REG); in bcm_uart_stop_rx()
181 bcm_uart_writel(port, val, UART_IR_REG); in bcm_uart_stop_rx()
187 static void bcm_uart_enable_ms(struct uart_port *port) in bcm_uart_enable_ms() argument
191 val = bcm_uart_readl(port, UART_IR_REG); in bcm_uart_enable_ms()
193 bcm_uart_writel(port, val, UART_IR_REG); in bcm_uart_enable_ms()
199 static void bcm_uart_break_ctl(struct uart_port *port, int ctl) in bcm_uart_break_ctl() argument
204 spin_lock_irqsave(&port->lock, flags); in bcm_uart_break_ctl()
206 val = bcm_uart_readl(port, UART_CTL_REG); in bcm_uart_break_ctl()
211 bcm_uart_writel(port, val, UART_CTL_REG); in bcm_uart_break_ctl()
213 spin_unlock_irqrestore(&port->lock, flags); in bcm_uart_break_ctl()
217 * return port type in string format
219 static const char *bcm_uart_type(struct uart_port *port) in bcm_uart_type() argument
221 return (port->type == PORT_BCM63XX) ? "bcm63xx_uart" : NULL; in bcm_uart_type()
227 static void bcm_uart_do_rx(struct uart_port *port) in bcm_uart_do_rx() argument
229 struct tty_port *tty_port = &port->state->port; in bcm_uart_do_rx()
234 * serial port */ in bcm_uart_do_rx()
242 iestat = bcm_uart_readl(port, UART_IR_REG); in bcm_uart_do_rx()
249 val = bcm_uart_readl(port, UART_CTL_REG); in bcm_uart_do_rx()
251 bcm_uart_writel(port, val, UART_CTL_REG); in bcm_uart_do_rx()
253 port->icount.overrun++; in bcm_uart_do_rx()
260 cstat = c = bcm_uart_readl(port, UART_FIFO_REG); in bcm_uart_do_rx()
261 port->icount.rx++; in bcm_uart_do_rx()
268 port->icount.brk++; in bcm_uart_do_rx()
269 if (uart_handle_break(port)) 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()
288 if (uart_handle_sysrq_char(port, c)) in bcm_uart_do_rx()
292 if ((cstat & port->ignore_status_mask) == 0) in bcm_uart_do_rx()
304 static void bcm_uart_do_tx(struct uart_port *port) in bcm_uart_do_tx() argument
309 if (port->x_char) { in bcm_uart_do_tx()
310 bcm_uart_writel(port, port->x_char, UART_FIFO_REG); in bcm_uart_do_tx()
311 port->icount.tx++; in bcm_uart_do_tx()
312 port->x_char = 0; in bcm_uart_do_tx()
316 if (uart_tx_stopped(port)) { in bcm_uart_do_tx()
317 bcm_uart_stop_tx(port); in bcm_uart_do_tx()
321 xmit = &port->state->xmit; in bcm_uart_do_tx()
325 val = bcm_uart_readl(port, UART_MCTL_REG); in bcm_uart_do_tx()
327 max_count = port->fifosize - val; in bcm_uart_do_tx()
333 bcm_uart_writel(port, c, UART_FIFO_REG); in bcm_uart_do_tx()
335 port->icount.tx++; in bcm_uart_do_tx()
341 uart_write_wakeup(port); in bcm_uart_do_tx()
349 val = bcm_uart_readl(port, UART_IR_REG); in bcm_uart_do_tx()
351 bcm_uart_writel(port, val, UART_IR_REG); in bcm_uart_do_tx()
360 struct uart_port *port; in bcm_uart_interrupt() local
363 port = dev_id; in bcm_uart_interrupt()
364 spin_lock(&port->lock); in bcm_uart_interrupt()
366 irqstat = bcm_uart_readl(port, UART_IR_REG); in bcm_uart_interrupt()
368 bcm_uart_do_rx(port); in bcm_uart_interrupt()
371 bcm_uart_do_tx(port); in bcm_uart_interrupt()
376 estat = bcm_uart_readl(port, UART_EXTINP_REG); in bcm_uart_interrupt()
378 uart_handle_cts_change(port, in bcm_uart_interrupt()
381 uart_handle_dcd_change(port, in bcm_uart_interrupt()
385 spin_unlock(&port->lock); in bcm_uart_interrupt()
392 static void bcm_uart_enable(struct uart_port *port) in bcm_uart_enable() argument
396 val = bcm_uart_readl(port, UART_CTL_REG); in bcm_uart_enable()
398 bcm_uart_writel(port, val, UART_CTL_REG); in bcm_uart_enable()
404 static void bcm_uart_disable(struct uart_port *port) in bcm_uart_disable() argument
408 val = bcm_uart_readl(port, UART_CTL_REG); in bcm_uart_disable()
411 bcm_uart_writel(port, val, UART_CTL_REG); in bcm_uart_disable()
417 static void bcm_uart_flush(struct uart_port *port) in bcm_uart_flush() argument
422 val = bcm_uart_readl(port, UART_CTL_REG); in bcm_uart_flush()
424 bcm_uart_writel(port, val, UART_CTL_REG); in bcm_uart_flush()
428 (void)bcm_uart_readl(port, UART_FIFO_REG); in bcm_uart_flush()
434 static int bcm_uart_startup(struct uart_port *port) in bcm_uart_startup() argument
439 /* mask all irq and flush port */ in bcm_uart_startup()
440 bcm_uart_disable(port); in bcm_uart_startup()
441 bcm_uart_writel(port, 0, UART_IR_REG); in bcm_uart_startup()
442 bcm_uart_flush(port); in bcm_uart_startup()
445 (void)bcm_uart_readl(port, UART_EXTINP_REG); in bcm_uart_startup()
448 val = bcm_uart_readl(port, UART_MCTL_REG); in bcm_uart_startup()
450 val |= (port->fifosize / 2) << UART_MCTL_RXFIFOTHRESH_SHIFT; in bcm_uart_startup()
451 val |= (port->fifosize / 2) << UART_MCTL_TXFIFOTHRESH_SHIFT; in bcm_uart_startup()
452 bcm_uart_writel(port, val, UART_MCTL_REG); in bcm_uart_startup()
455 val = bcm_uart_readl(port, UART_CTL_REG); in bcm_uart_startup()
458 bcm_uart_writel(port, val, UART_CTL_REG); in bcm_uart_startup()
464 bcm_uart_writel(port, val, UART_EXTINP_REG); in bcm_uart_startup()
467 ret = request_irq(port->irq, bcm_uart_interrupt, 0, in bcm_uart_startup()
468 dev_name(port->dev), port); in bcm_uart_startup()
471 bcm_uart_writel(port, UART_RX_INT_MASK, UART_IR_REG); in bcm_uart_startup()
472 bcm_uart_enable(port); in bcm_uart_startup()
479 static void bcm_uart_shutdown(struct uart_port *port) in bcm_uart_shutdown() argument
483 spin_lock_irqsave(&port->lock, flags); in bcm_uart_shutdown()
484 bcm_uart_writel(port, 0, UART_IR_REG); in bcm_uart_shutdown()
485 spin_unlock_irqrestore(&port->lock, flags); in bcm_uart_shutdown()
487 bcm_uart_disable(port); in bcm_uart_shutdown()
488 bcm_uart_flush(port); in bcm_uart_shutdown()
489 free_irq(port->irq, port); in bcm_uart_shutdown()
495 static void bcm_uart_set_termios(struct uart_port *port, struct ktermios *new, in bcm_uart_set_termios() argument
502 spin_lock_irqsave(&port->lock, flags); in bcm_uart_set_termios()
505 for (tries = 3; !bcm_uart_tx_empty(port) && tries; tries--) in bcm_uart_set_termios()
509 bcm_uart_disable(port); in bcm_uart_set_termios()
510 bcm_uart_flush(port); in bcm_uart_set_termios()
513 ctl = bcm_uart_readl(port, UART_CTL_REG); in bcm_uart_set_termios()
543 bcm_uart_writel(port, ctl, UART_CTL_REG); in bcm_uart_set_termios()
546 baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16); in bcm_uart_set_termios()
547 quot = uart_get_divisor(port, baud) - 1; in bcm_uart_set_termios()
548 bcm_uart_writel(port, quot, UART_BAUD_REG); in bcm_uart_set_termios()
551 ier = bcm_uart_readl(port, UART_IR_REG); in bcm_uart_set_termios()
554 if (UART_ENABLE_MS(port, new->c_cflag)) in bcm_uart_set_termios()
557 bcm_uart_writel(port, ier, UART_IR_REG); in bcm_uart_set_termios()
560 port->read_status_mask = UART_FIFO_VALID_MASK; in bcm_uart_set_termios()
562 port->read_status_mask |= UART_FIFO_FRAMEERR_MASK; in bcm_uart_set_termios()
563 port->read_status_mask |= UART_FIFO_PARERR_MASK; in bcm_uart_set_termios()
566 port->read_status_mask |= UART_FIFO_BRKDET_MASK; in bcm_uart_set_termios()
568 port->ignore_status_mask = 0; in bcm_uart_set_termios()
570 port->ignore_status_mask |= UART_FIFO_PARERR_MASK; in bcm_uart_set_termios()
572 port->ignore_status_mask |= UART_FIFO_BRKDET_MASK; in bcm_uart_set_termios()
574 port->ignore_status_mask |= UART_FIFO_VALID_MASK; in bcm_uart_set_termios()
576 uart_update_timeout(port, new->c_cflag, baud); in bcm_uart_set_termios()
577 bcm_uart_enable(port); in bcm_uart_set_termios()
578 spin_unlock_irqrestore(&port->lock, flags); in bcm_uart_set_termios()
584 static int bcm_uart_request_port(struct uart_port *port) in bcm_uart_request_port() argument
593 static void bcm_uart_release_port(struct uart_port *port) in bcm_uart_release_port() argument
599 * serial core request to do any port required autoconfiguration
601 static void bcm_uart_config_port(struct uart_port *port, int flags) in bcm_uart_config_port() argument
604 if (bcm_uart_request_port(port)) in bcm_uart_config_port()
606 port->type = PORT_BCM63XX; in bcm_uart_config_port()
611 * serial core request to check that port information in serinfo are
614 static int bcm_uart_verify_port(struct uart_port *port, in bcm_uart_verify_port() argument
617 if (port->type != PORT_BCM63XX) in bcm_uart_verify_port()
619 if (port->irq != serinfo->irq) in bcm_uart_verify_port()
621 if (port->iotype != serinfo->io_type) in bcm_uart_verify_port()
623 if (port->mapbase != (unsigned long)serinfo->iomem_base) in bcm_uart_verify_port()
651 static void wait_for_xmitr(struct uart_port *port) in wait_for_xmitr() argument
660 val = bcm_uart_readl(port, UART_IR_REG); in wait_for_xmitr()
667 if (port->flags & UPF_CONS_FLOW) { in wait_for_xmitr()
672 val = bcm_uart_readl(port, UART_EXTINP_REG); in wait_for_xmitr()
683 static void bcm_console_putchar(struct uart_port *port, unsigned char ch) in bcm_console_putchar() argument
685 wait_for_xmitr(port); in bcm_console_putchar()
686 bcm_uart_writel(port, ch, UART_FIFO_REG); in bcm_console_putchar()
695 struct uart_port *port; in bcm_console_write() local
699 port = &ports[co->index]; in bcm_console_write()
702 if (port->sysrq) { in bcm_console_write()
706 locked = spin_trylock(&port->lock); in bcm_console_write()
708 spin_lock(&port->lock); in bcm_console_write()
713 uart_console_write(port, s, count, bcm_console_putchar); in bcm_console_write()
716 wait_for_xmitr(port); in bcm_console_write()
719 spin_unlock(&port->lock); in bcm_console_write()
725 * port and setup it.
729 struct uart_port *port; in bcm_console_setup() local
737 port = &ports[co->index]; in bcm_console_setup()
738 if (!port->membase) in bcm_console_setup()
743 return uart_set_options(port, co, baud, parity, bits, flow); in bcm_console_setup()
770 uart_console_write(&dev->port, s, n, bcm_console_putchar); in bcm_early_write()
771 wait_for_xmitr(&dev->port); in bcm_early_write()
777 if (!device->port.membase) in bcm_early_console_setup()
807 struct uart_port *port; in bcm_uart_probe() local
821 port = &ports[pdev->id]; in bcm_uart_probe()
822 if (port->membase) in bcm_uart_probe()
824 memset(port, 0, sizeof(*port)); in bcm_uart_probe()
830 port->mapbase = res_mem->start; in bcm_uart_probe()
831 port->membase = devm_ioremap_resource(&pdev->dev, res_mem); in bcm_uart_probe()
832 if (IS_ERR(port->membase)) in bcm_uart_probe()
833 return PTR_ERR(port->membase); in bcm_uart_probe()
838 port->irq = ret; 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()
857 ret = uart_add_one_port(&bcm_uart_driver, port); in bcm_uart_probe()
862 platform_set_drvdata(pdev, port); in bcm_uart_probe()
868 struct uart_port *port; in bcm_uart_remove() local
870 port = platform_get_drvdata(pdev); in bcm_uart_remove()
871 uart_remove_one_port(&bcm_uart_driver, port); in bcm_uart_remove()
872 /* mark port as free */ in bcm_uart_remove()