• Home
  • Raw
  • Download

Lines Matching refs:port

128 	struct uart_port *port;  member
138 static struct mvebu_uart *to_mvuart(struct uart_port *port) in to_mvuart() argument
140 return (struct mvebu_uart *)port->private_data; in to_mvuart()
143 #define IS_EXTENDED(port) (to_mvuart(port)->data->is_ext) argument
145 #define UART_RBR(port) (to_mvuart(port)->data->regs.rbr) argument
146 #define UART_TSH(port) (to_mvuart(port)->data->regs.tsh) argument
147 #define UART_CTRL(port) (to_mvuart(port)->data->regs.ctrl) argument
148 #define UART_INTR(port) (to_mvuart(port)->data->regs.intr) argument
150 #define CTRL_TX_RDY_INT(port) (to_mvuart(port)->data->flags.ctrl_tx_rdy_int) argument
151 #define CTRL_RX_RDY_INT(port) (to_mvuart(port)->data->flags.ctrl_rx_rdy_int) argument
152 #define STAT_TX_RDY(port) (to_mvuart(port)->data->flags.stat_tx_rdy) argument
153 #define STAT_RX_RDY(port) (to_mvuart(port)->data->flags.stat_rx_rdy) argument
158 static unsigned int mvebu_uart_tx_empty(struct uart_port *port) in mvebu_uart_tx_empty() argument
163 spin_lock_irqsave(&port->lock, flags); in mvebu_uart_tx_empty()
164 st = readl(port->membase + UART_STAT); in mvebu_uart_tx_empty()
165 spin_unlock_irqrestore(&port->lock, flags); in mvebu_uart_tx_empty()
170 static unsigned int mvebu_uart_get_mctrl(struct uart_port *port) in mvebu_uart_get_mctrl() argument
175 static void mvebu_uart_set_mctrl(struct uart_port *port, in mvebu_uart_set_mctrl() argument
184 static void mvebu_uart_stop_tx(struct uart_port *port) in mvebu_uart_stop_tx() argument
186 unsigned int ctl = readl(port->membase + UART_INTR(port)); in mvebu_uart_stop_tx()
188 ctl &= ~CTRL_TX_RDY_INT(port); in mvebu_uart_stop_tx()
189 writel(ctl, port->membase + UART_INTR(port)); in mvebu_uart_stop_tx()
192 static void mvebu_uart_start_tx(struct uart_port *port) in mvebu_uart_start_tx() argument
195 struct circ_buf *xmit = &port->state->xmit; in mvebu_uart_start_tx()
197 if (IS_EXTENDED(port) && !uart_circ_empty(xmit)) { in mvebu_uart_start_tx()
198 writel(xmit->buf[xmit->tail], port->membase + UART_TSH(port)); in mvebu_uart_start_tx()
200 port->icount.tx++; in mvebu_uart_start_tx()
203 ctl = readl(port->membase + UART_INTR(port)); in mvebu_uart_start_tx()
204 ctl |= CTRL_TX_RDY_INT(port); in mvebu_uart_start_tx()
205 writel(ctl, port->membase + UART_INTR(port)); in mvebu_uart_start_tx()
208 static void mvebu_uart_stop_rx(struct uart_port *port) in mvebu_uart_stop_rx() argument
212 ctl = readl(port->membase + UART_CTRL(port)); in mvebu_uart_stop_rx()
214 writel(ctl, port->membase + UART_CTRL(port)); in mvebu_uart_stop_rx()
216 ctl = readl(port->membase + UART_INTR(port)); in mvebu_uart_stop_rx()
217 ctl &= ~CTRL_RX_RDY_INT(port); in mvebu_uart_stop_rx()
218 writel(ctl, port->membase + UART_INTR(port)); in mvebu_uart_stop_rx()
221 static void mvebu_uart_break_ctl(struct uart_port *port, int brk) in mvebu_uart_break_ctl() argument
226 spin_lock_irqsave(&port->lock, flags); in mvebu_uart_break_ctl()
227 ctl = readl(port->membase + UART_CTRL(port)); in mvebu_uart_break_ctl()
232 writel(ctl, port->membase + UART_CTRL(port)); in mvebu_uart_break_ctl()
233 spin_unlock_irqrestore(&port->lock, flags); in mvebu_uart_break_ctl()
236 static void mvebu_uart_rx_chars(struct uart_port *port, unsigned int status) in mvebu_uart_rx_chars() argument
238 struct tty_port *tport = &port->state->port; in mvebu_uart_rx_chars()
244 if (status & STAT_RX_RDY(port)) { in mvebu_uart_rx_chars()
245 ch = readl(port->membase + UART_RBR(port)); in mvebu_uart_rx_chars()
248 port->icount.rx++; in mvebu_uart_rx_chars()
251 port->icount.parity++; in mvebu_uart_rx_chars()
258 if (IS_EXTENDED(port) && (status & STAT_BRK_ERR)) { in mvebu_uart_rx_chars()
259 ret = readl(port->membase + UART_STAT); in mvebu_uart_rx_chars()
261 writel(ret, port->membase + UART_STAT); in mvebu_uart_rx_chars()
265 port->icount.brk++; in mvebu_uart_rx_chars()
267 if (uart_handle_break(port)) in mvebu_uart_rx_chars()
272 port->icount.overrun++; in mvebu_uart_rx_chars()
275 port->icount.frame++; in mvebu_uart_rx_chars()
277 if (uart_handle_sysrq_char(port, ch)) in mvebu_uart_rx_chars()
280 if (status & port->ignore_status_mask & STAT_PAR_ERR) in mvebu_uart_rx_chars()
281 status &= ~STAT_RX_RDY(port); in mvebu_uart_rx_chars()
283 status &= port->read_status_mask; in mvebu_uart_rx_chars()
288 status &= ~port->ignore_status_mask; in mvebu_uart_rx_chars()
290 if (status & STAT_RX_RDY(port)) in mvebu_uart_rx_chars()
303 status = readl(port->membase + UART_STAT); in mvebu_uart_rx_chars()
304 } while (status & (STAT_RX_RDY(port) | STAT_BRK_DET)); in mvebu_uart_rx_chars()
309 static void mvebu_uart_tx_chars(struct uart_port *port, unsigned int status) in mvebu_uart_tx_chars() argument
311 struct circ_buf *xmit = &port->state->xmit; in mvebu_uart_tx_chars()
315 if (port->x_char) { in mvebu_uart_tx_chars()
316 writel(port->x_char, port->membase + UART_TSH(port)); in mvebu_uart_tx_chars()
317 port->icount.tx++; in mvebu_uart_tx_chars()
318 port->x_char = 0; in mvebu_uart_tx_chars()
322 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { in mvebu_uart_tx_chars()
323 mvebu_uart_stop_tx(port); in mvebu_uart_tx_chars()
327 for (count = 0; count < port->fifosize; count++) { in mvebu_uart_tx_chars()
328 writel(xmit->buf[xmit->tail], port->membase + UART_TSH(port)); in mvebu_uart_tx_chars()
330 port->icount.tx++; in mvebu_uart_tx_chars()
335 st = readl(port->membase + UART_STAT); in mvebu_uart_tx_chars()
341 uart_write_wakeup(port); in mvebu_uart_tx_chars()
344 mvebu_uart_stop_tx(port); in mvebu_uart_tx_chars()
349 struct uart_port *port = (struct uart_port *)dev_id; in mvebu_uart_isr() local
350 unsigned int st = readl(port->membase + UART_STAT); in mvebu_uart_isr()
352 if (st & (STAT_RX_RDY(port) | STAT_OVR_ERR | STAT_FRM_ERR | in mvebu_uart_isr()
354 mvebu_uart_rx_chars(port, st); in mvebu_uart_isr()
356 if (st & STAT_TX_RDY(port)) in mvebu_uart_isr()
357 mvebu_uart_tx_chars(port, st); in mvebu_uart_isr()
364 struct uart_port *port = (struct uart_port *)dev_id; in mvebu_uart_rx_isr() local
365 unsigned int st = readl(port->membase + UART_STAT); in mvebu_uart_rx_isr()
367 if (st & (STAT_RX_RDY(port) | STAT_OVR_ERR | STAT_FRM_ERR | in mvebu_uart_rx_isr()
369 mvebu_uart_rx_chars(port, st); in mvebu_uart_rx_isr()
376 struct uart_port *port = (struct uart_port *)dev_id; in mvebu_uart_tx_isr() local
377 unsigned int st = readl(port->membase + UART_STAT); in mvebu_uart_tx_isr()
379 if (st & STAT_TX_RDY(port)) in mvebu_uart_tx_isr()
380 mvebu_uart_tx_chars(port, st); in mvebu_uart_tx_isr()
385 static int mvebu_uart_startup(struct uart_port *port) in mvebu_uart_startup() argument
387 struct mvebu_uart *mvuart = to_mvuart(port); in mvebu_uart_startup()
392 port->membase + UART_CTRL(port)); in mvebu_uart_startup()
396 ret = readl(port->membase + UART_STAT); in mvebu_uart_startup()
398 writel(ret, port->membase + UART_STAT); in mvebu_uart_startup()
400 writel(CTRL_BRK_INT, port->membase + UART_CTRL(port)); in mvebu_uart_startup()
402 ctl = readl(port->membase + UART_INTR(port)); in mvebu_uart_startup()
403 ctl |= CTRL_RX_RDY_INT(port); in mvebu_uart_startup()
404 writel(ctl, port->membase + UART_INTR(port)); in mvebu_uart_startup()
408 ret = devm_request_irq(port->dev, mvuart->irq[UART_IRQ_SUM], in mvebu_uart_startup()
409 mvebu_uart_isr, port->irqflags, in mvebu_uart_startup()
410 dev_name(port->dev), port); in mvebu_uart_startup()
412 dev_err(port->dev, "unable to request IRQ %d\n", in mvebu_uart_startup()
418 ret = devm_request_irq(port->dev, mvuart->irq[UART_RX_IRQ], in mvebu_uart_startup()
419 mvebu_uart_rx_isr, port->irqflags, in mvebu_uart_startup()
420 dev_name(port->dev), port); in mvebu_uart_startup()
422 dev_err(port->dev, "unable to request IRQ %d\n", in mvebu_uart_startup()
427 ret = devm_request_irq(port->dev, mvuart->irq[UART_TX_IRQ], in mvebu_uart_startup()
428 mvebu_uart_tx_isr, port->irqflags, in mvebu_uart_startup()
429 dev_name(port->dev), in mvebu_uart_startup()
430 port); in mvebu_uart_startup()
432 dev_err(port->dev, "unable to request IRQ %d\n", in mvebu_uart_startup()
434 devm_free_irq(port->dev, mvuart->irq[UART_RX_IRQ], in mvebu_uart_startup()
435 port); in mvebu_uart_startup()
443 static void mvebu_uart_shutdown(struct uart_port *port) in mvebu_uart_shutdown() argument
445 struct mvebu_uart *mvuart = to_mvuart(port); in mvebu_uart_shutdown()
447 writel(0, port->membase + UART_INTR(port)); in mvebu_uart_shutdown()
450 devm_free_irq(port->dev, mvuart->irq[UART_IRQ_SUM], port); in mvebu_uart_shutdown()
452 devm_free_irq(port->dev, mvuart->irq[UART_RX_IRQ], port); in mvebu_uart_shutdown()
453 devm_free_irq(port->dev, mvuart->irq[UART_TX_IRQ], port); in mvebu_uart_shutdown()
457 static unsigned int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud) in mvebu_uart_baud_rate_set() argument
462 if (!port->uartclk) in mvebu_uart_baud_rate_set()
476 d_divisor = DIV_ROUND_CLOSEST(port->uartclk, baud * m_divisor); in mvebu_uart_baud_rate_set()
478 brdv = readl(port->membase + UART_BRDV); in mvebu_uart_baud_rate_set()
481 writel(brdv, port->membase + UART_BRDV); in mvebu_uart_baud_rate_set()
483 osamp = readl(port->membase + UART_OSAMP); in mvebu_uart_baud_rate_set()
485 writel(osamp, port->membase + UART_OSAMP); in mvebu_uart_baud_rate_set()
487 return DIV_ROUND_CLOSEST(port->uartclk, d_divisor * m_divisor); in mvebu_uart_baud_rate_set()
490 static void mvebu_uart_set_termios(struct uart_port *port, in mvebu_uart_set_termios() argument
497 spin_lock_irqsave(&port->lock, flags); in mvebu_uart_set_termios()
499 port->read_status_mask = STAT_RX_RDY(port) | STAT_OVR_ERR | in mvebu_uart_set_termios()
500 STAT_TX_RDY(port) | STAT_TX_FIFO_FUL; in mvebu_uart_set_termios()
503 port->read_status_mask |= STAT_FRM_ERR | STAT_PAR_ERR; in mvebu_uart_set_termios()
505 port->ignore_status_mask = 0; in mvebu_uart_set_termios()
507 port->ignore_status_mask |= in mvebu_uart_set_termios()
511 port->ignore_status_mask |= STAT_RX_RDY(port) | STAT_BRK_ERR; in mvebu_uart_set_termios()
520 min_baud = DIV_ROUND_UP(port->uartclk, 1023 * 16); in mvebu_uart_set_termios()
523 baud = uart_get_baud_rate(port, termios, old, min_baud, max_baud); in mvebu_uart_set_termios()
524 baud = mvebu_uart_baud_rate_set(port, baud); in mvebu_uart_set_termios()
541 uart_update_timeout(port, termios->c_cflag, baud); in mvebu_uart_set_termios()
544 spin_unlock_irqrestore(&port->lock, flags); in mvebu_uart_set_termios()
547 static const char *mvebu_uart_type(struct uart_port *port) in mvebu_uart_type() argument
552 static void mvebu_uart_release_port(struct uart_port *port) in mvebu_uart_release_port() argument
557 static int mvebu_uart_request_port(struct uart_port *port) in mvebu_uart_request_port() argument
563 static int mvebu_uart_get_poll_char(struct uart_port *port) in mvebu_uart_get_poll_char() argument
565 unsigned int st = readl(port->membase + UART_STAT); in mvebu_uart_get_poll_char()
567 if (!(st & STAT_RX_RDY(port))) in mvebu_uart_get_poll_char()
570 return readl(port->membase + UART_RBR(port)); in mvebu_uart_get_poll_char()
573 static void mvebu_uart_put_poll_char(struct uart_port *port, unsigned char c) in mvebu_uart_put_poll_char() argument
578 st = readl(port->membase + UART_STAT); in mvebu_uart_put_poll_char()
586 writel(c, port->membase + UART_TSH(port)); in mvebu_uart_put_poll_char()
614 static void mvebu_uart_putc(struct uart_port *port, int c) in mvebu_uart_putc() argument
619 st = readl(port->membase + UART_STAT); in mvebu_uart_putc()
625 writel(c, port->membase + UART_STD_TSH); in mvebu_uart_putc()
628 st = readl(port->membase + UART_STAT); in mvebu_uart_putc()
640 uart_console_write(&dev->port, s, n, mvebu_uart_putc); in mvebu_uart_putc_early_write()
647 if (!device->port.membase) in mvebu_uart_early_console_setup()
659 static void wait_for_xmitr(struct uart_port *port) in wait_for_xmitr() argument
663 readl_poll_timeout_atomic(port->membase + UART_STAT, val, in wait_for_xmitr()
664 (val & STAT_TX_RDY(port)), 1, 10000); in wait_for_xmitr()
667 static void wait_for_xmite(struct uart_port *port) in wait_for_xmite() argument
671 readl_poll_timeout_atomic(port->membase + UART_STAT, val, in wait_for_xmite()
675 static void mvebu_uart_console_putchar(struct uart_port *port, int ch) in mvebu_uart_console_putchar() argument
677 wait_for_xmitr(port); in mvebu_uart_console_putchar()
678 writel(ch, port->membase + UART_TSH(port)); in mvebu_uart_console_putchar()
684 struct uart_port *port = &mvebu_uart_ports[co->index]; in mvebu_uart_console_write() local
690 locked = spin_trylock_irqsave(&port->lock, flags); in mvebu_uart_console_write()
692 spin_lock_irqsave(&port->lock, flags); in mvebu_uart_console_write()
694 ier = readl(port->membase + UART_CTRL(port)) & CTRL_BRK_INT; in mvebu_uart_console_write()
695 intr = readl(port->membase + UART_INTR(port)) & in mvebu_uart_console_write()
696 (CTRL_RX_RDY_INT(port) | CTRL_TX_RDY_INT(port)); in mvebu_uart_console_write()
697 writel(0, port->membase + UART_CTRL(port)); in mvebu_uart_console_write()
698 writel(0, port->membase + UART_INTR(port)); in mvebu_uart_console_write()
700 uart_console_write(port, s, count, mvebu_uart_console_putchar); in mvebu_uart_console_write()
702 wait_for_xmite(port); in mvebu_uart_console_write()
705 writel(ier, port->membase + UART_CTRL(port)); in mvebu_uart_console_write()
708 ctl = intr | readl(port->membase + UART_INTR(port)); in mvebu_uart_console_write()
709 writel(ctl, port->membase + UART_INTR(port)); in mvebu_uart_console_write()
713 spin_unlock_irqrestore(&port->lock, flags); in mvebu_uart_console_write()
718 struct uart_port *port; in mvebu_uart_console_setup() local
727 port = &mvebu_uart_ports[co->index]; in mvebu_uart_console_setup()
729 if (!port->mapbase || !port->membase) { in mvebu_uart_console_setup()
737 return uart_set_options(port, co, baud, parity, bits, flow); in mvebu_uart_console_setup()
777 struct uart_port *port = mvuart->port; in mvebu_uart_suspend() local
779 uart_suspend_port(&mvebu_uart_driver, port); in mvebu_uart_suspend()
781 mvuart->pm_regs.rbr = readl(port->membase + UART_RBR(port)); in mvebu_uart_suspend()
782 mvuart->pm_regs.tsh = readl(port->membase + UART_TSH(port)); in mvebu_uart_suspend()
783 mvuart->pm_regs.ctrl = readl(port->membase + UART_CTRL(port)); in mvebu_uart_suspend()
784 mvuart->pm_regs.intr = readl(port->membase + UART_INTR(port)); in mvebu_uart_suspend()
785 mvuart->pm_regs.stat = readl(port->membase + UART_STAT); in mvebu_uart_suspend()
786 mvuart->pm_regs.brdv = readl(port->membase + UART_BRDV); in mvebu_uart_suspend()
787 mvuart->pm_regs.osamp = readl(port->membase + UART_OSAMP); in mvebu_uart_suspend()
797 struct uart_port *port = mvuart->port; in mvebu_uart_resume() local
799 writel(mvuart->pm_regs.rbr, port->membase + UART_RBR(port)); in mvebu_uart_resume()
800 writel(mvuart->pm_regs.tsh, port->membase + UART_TSH(port)); in mvebu_uart_resume()
801 writel(mvuart->pm_regs.ctrl, port->membase + UART_CTRL(port)); in mvebu_uart_resume()
802 writel(mvuart->pm_regs.intr, port->membase + UART_INTR(port)); in mvebu_uart_resume()
803 writel(mvuart->pm_regs.stat, port->membase + UART_STAT); in mvebu_uart_resume()
804 writel(mvuart->pm_regs.brdv, port->membase + UART_BRDV); in mvebu_uart_resume()
805 writel(mvuart->pm_regs.osamp, port->membase + UART_OSAMP); in mvebu_uart_resume()
807 uart_resume_port(&mvebu_uart_driver, port); in mvebu_uart_resume()
828 struct uart_port *port; in mvebu_uart_probe() local
850 port = &mvebu_uart_ports[pdev->id]; in mvebu_uart_probe()
852 spin_lock_init(&port->lock); in mvebu_uart_probe()
854 port->dev = &pdev->dev; in mvebu_uart_probe()
855 port->type = PORT_MVEBU; in mvebu_uart_probe()
856 port->ops = &mvebu_uart_ops; in mvebu_uart_probe()
857 port->regshift = 0; in mvebu_uart_probe()
859 port->fifosize = 32; in mvebu_uart_probe()
860 port->iotype = UPIO_MEM32; in mvebu_uart_probe()
861 port->flags = UPF_FIXED_PORT; in mvebu_uart_probe()
862 port->line = pdev->id; in mvebu_uart_probe()
869 port->irq = 0; in mvebu_uart_probe()
870 port->irqflags = 0; in mvebu_uart_probe()
871 port->mapbase = reg->start; in mvebu_uart_probe()
873 port->membase = devm_ioremap_resource(&pdev->dev, reg); in mvebu_uart_probe()
874 if (IS_ERR(port->membase)) in mvebu_uart_probe()
875 return PTR_ERR(port->membase); in mvebu_uart_probe()
884 mvuart->port = port; in mvebu_uart_probe()
886 port->private_data = mvuart; in mvebu_uart_probe()
895 if (IS_EXTENDED(port)) { in mvebu_uart_probe()
901 port->uartclk = clk_get_rate(mvuart->clk); in mvebu_uart_probe()
932 writel(CTRL_SOFT_RST, port->membase + UART_CTRL(port)); in mvebu_uart_probe()
934 writel(0, port->membase + UART_CTRL(port)); in mvebu_uart_probe()
936 return uart_add_one_port(&mvebu_uart_driver, port); in mvebu_uart_probe()