• Home
  • Raw
  • Download

Lines Matching refs:port

128 	struct uart_port *port;  member
137 static struct mvebu_uart *to_mvuart(struct uart_port *port) in to_mvuart() argument
139 return (struct mvebu_uart *)port->private_data; in to_mvuart()
142 #define IS_EXTENDED(port) (to_mvuart(port)->data->is_ext) argument
144 #define UART_RBR(port) (to_mvuart(port)->data->regs.rbr) argument
145 #define UART_TSH(port) (to_mvuart(port)->data->regs.tsh) argument
146 #define UART_CTRL(port) (to_mvuart(port)->data->regs.ctrl) argument
147 #define UART_INTR(port) (to_mvuart(port)->data->regs.intr) argument
149 #define CTRL_TX_RDY_INT(port) (to_mvuart(port)->data->flags.ctrl_tx_rdy_int) argument
150 #define CTRL_RX_RDY_INT(port) (to_mvuart(port)->data->flags.ctrl_rx_rdy_int) argument
151 #define STAT_TX_RDY(port) (to_mvuart(port)->data->flags.stat_tx_rdy) argument
152 #define STAT_RX_RDY(port) (to_mvuart(port)->data->flags.stat_rx_rdy) argument
157 static unsigned int mvebu_uart_tx_empty(struct uart_port *port) in mvebu_uart_tx_empty() argument
162 spin_lock_irqsave(&port->lock, flags); in mvebu_uart_tx_empty()
163 st = readl(port->membase + UART_STAT); in mvebu_uart_tx_empty()
164 spin_unlock_irqrestore(&port->lock, flags); in mvebu_uart_tx_empty()
169 static unsigned int mvebu_uart_get_mctrl(struct uart_port *port) in mvebu_uart_get_mctrl() argument
174 static void mvebu_uart_set_mctrl(struct uart_port *port, in mvebu_uart_set_mctrl() argument
183 static void mvebu_uart_stop_tx(struct uart_port *port) in mvebu_uart_stop_tx() argument
185 unsigned int ctl = readl(port->membase + UART_INTR(port)); in mvebu_uart_stop_tx()
187 ctl &= ~CTRL_TX_RDY_INT(port); in mvebu_uart_stop_tx()
188 writel(ctl, port->membase + UART_INTR(port)); in mvebu_uart_stop_tx()
191 static void mvebu_uart_start_tx(struct uart_port *port) in mvebu_uart_start_tx() argument
194 struct circ_buf *xmit = &port->state->xmit; in mvebu_uart_start_tx()
196 if (IS_EXTENDED(port) && !uart_circ_empty(xmit)) { in mvebu_uart_start_tx()
197 writel(xmit->buf[xmit->tail], port->membase + UART_TSH(port)); in mvebu_uart_start_tx()
199 port->icount.tx++; in mvebu_uart_start_tx()
202 ctl = readl(port->membase + UART_INTR(port)); in mvebu_uart_start_tx()
203 ctl |= CTRL_TX_RDY_INT(port); in mvebu_uart_start_tx()
204 writel(ctl, port->membase + UART_INTR(port)); in mvebu_uart_start_tx()
207 static void mvebu_uart_stop_rx(struct uart_port *port) in mvebu_uart_stop_rx() argument
211 ctl = readl(port->membase + UART_CTRL(port)); in mvebu_uart_stop_rx()
213 writel(ctl, port->membase + UART_CTRL(port)); in mvebu_uart_stop_rx()
215 ctl = readl(port->membase + UART_INTR(port)); in mvebu_uart_stop_rx()
216 ctl &= ~CTRL_RX_RDY_INT(port); in mvebu_uart_stop_rx()
217 writel(ctl, port->membase + UART_INTR(port)); in mvebu_uart_stop_rx()
220 static void mvebu_uart_break_ctl(struct uart_port *port, int brk) in mvebu_uart_break_ctl() argument
225 spin_lock_irqsave(&port->lock, flags); in mvebu_uart_break_ctl()
226 ctl = readl(port->membase + UART_CTRL(port)); in mvebu_uart_break_ctl()
231 writel(ctl, port->membase + UART_CTRL(port)); in mvebu_uart_break_ctl()
232 spin_unlock_irqrestore(&port->lock, flags); in mvebu_uart_break_ctl()
235 static void mvebu_uart_rx_chars(struct uart_port *port, unsigned int status) in mvebu_uart_rx_chars() argument
237 struct tty_port *tport = &port->state->port; in mvebu_uart_rx_chars()
243 if (status & STAT_RX_RDY(port)) { in mvebu_uart_rx_chars()
244 ch = readl(port->membase + UART_RBR(port)); in mvebu_uart_rx_chars()
247 port->icount.rx++; in mvebu_uart_rx_chars()
250 port->icount.parity++; in mvebu_uart_rx_chars()
257 if (IS_EXTENDED(port) && (status & STAT_BRK_ERR)) { in mvebu_uart_rx_chars()
258 ret = readl(port->membase + UART_STAT); in mvebu_uart_rx_chars()
260 writel(ret, port->membase + UART_STAT); in mvebu_uart_rx_chars()
264 port->icount.brk++; in mvebu_uart_rx_chars()
266 if (uart_handle_break(port)) in mvebu_uart_rx_chars()
271 port->icount.overrun++; in mvebu_uart_rx_chars()
274 port->icount.frame++; in mvebu_uart_rx_chars()
276 if (uart_handle_sysrq_char(port, ch)) in mvebu_uart_rx_chars()
279 if (status & port->ignore_status_mask & STAT_PAR_ERR) in mvebu_uart_rx_chars()
280 status &= ~STAT_RX_RDY(port); in mvebu_uart_rx_chars()
282 status &= port->read_status_mask; in mvebu_uart_rx_chars()
287 status &= ~port->ignore_status_mask; in mvebu_uart_rx_chars()
289 if (status & STAT_RX_RDY(port)) in mvebu_uart_rx_chars()
302 status = readl(port->membase + UART_STAT); in mvebu_uart_rx_chars()
303 } while (status & (STAT_RX_RDY(port) | STAT_BRK_DET)); in mvebu_uart_rx_chars()
308 static void mvebu_uart_tx_chars(struct uart_port *port, unsigned int status) in mvebu_uart_tx_chars() argument
310 struct circ_buf *xmit = &port->state->xmit; in mvebu_uart_tx_chars()
314 if (port->x_char) { in mvebu_uart_tx_chars()
315 writel(port->x_char, port->membase + UART_TSH(port)); in mvebu_uart_tx_chars()
316 port->icount.tx++; in mvebu_uart_tx_chars()
317 port->x_char = 0; in mvebu_uart_tx_chars()
321 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { in mvebu_uart_tx_chars()
322 mvebu_uart_stop_tx(port); in mvebu_uart_tx_chars()
326 for (count = 0; count < port->fifosize; count++) { in mvebu_uart_tx_chars()
327 writel(xmit->buf[xmit->tail], port->membase + UART_TSH(port)); in mvebu_uart_tx_chars()
329 port->icount.tx++; in mvebu_uart_tx_chars()
334 st = readl(port->membase + UART_STAT); in mvebu_uart_tx_chars()
340 uart_write_wakeup(port); in mvebu_uart_tx_chars()
343 mvebu_uart_stop_tx(port); in mvebu_uart_tx_chars()
348 struct uart_port *port = (struct uart_port *)dev_id; in mvebu_uart_isr() local
349 unsigned int st = readl(port->membase + UART_STAT); in mvebu_uart_isr()
351 if (st & (STAT_RX_RDY(port) | STAT_OVR_ERR | STAT_FRM_ERR | in mvebu_uart_isr()
353 mvebu_uart_rx_chars(port, st); in mvebu_uart_isr()
355 if (st & STAT_TX_RDY(port)) in mvebu_uart_isr()
356 mvebu_uart_tx_chars(port, st); in mvebu_uart_isr()
363 struct uart_port *port = (struct uart_port *)dev_id; in mvebu_uart_rx_isr() local
364 unsigned int st = readl(port->membase + UART_STAT); in mvebu_uart_rx_isr()
366 if (st & (STAT_RX_RDY(port) | STAT_OVR_ERR | STAT_FRM_ERR | in mvebu_uart_rx_isr()
368 mvebu_uart_rx_chars(port, st); in mvebu_uart_rx_isr()
375 struct uart_port *port = (struct uart_port *)dev_id; in mvebu_uart_tx_isr() local
376 unsigned int st = readl(port->membase + UART_STAT); in mvebu_uart_tx_isr()
378 if (st & STAT_TX_RDY(port)) in mvebu_uart_tx_isr()
379 mvebu_uart_tx_chars(port, st); in mvebu_uart_tx_isr()
384 static int mvebu_uart_startup(struct uart_port *port) in mvebu_uart_startup() argument
386 struct mvebu_uart *mvuart = to_mvuart(port); in mvebu_uart_startup()
391 port->membase + UART_CTRL(port)); in mvebu_uart_startup()
395 ret = readl(port->membase + UART_STAT); in mvebu_uart_startup()
397 writel(ret, port->membase + UART_STAT); in mvebu_uart_startup()
399 writel(CTRL_BRK_INT, port->membase + UART_CTRL(port)); in mvebu_uart_startup()
401 ctl = readl(port->membase + UART_INTR(port)); in mvebu_uart_startup()
402 ctl |= CTRL_RX_RDY_INT(port); in mvebu_uart_startup()
403 writel(ctl, port->membase + UART_INTR(port)); in mvebu_uart_startup()
407 ret = devm_request_irq(port->dev, mvuart->irq[UART_IRQ_SUM], in mvebu_uart_startup()
408 mvebu_uart_isr, port->irqflags, in mvebu_uart_startup()
409 dev_name(port->dev), port); in mvebu_uart_startup()
411 dev_err(port->dev, "unable to request IRQ %d\n", in mvebu_uart_startup()
417 ret = devm_request_irq(port->dev, mvuart->irq[UART_RX_IRQ], in mvebu_uart_startup()
418 mvebu_uart_rx_isr, port->irqflags, in mvebu_uart_startup()
419 dev_name(port->dev), port); in mvebu_uart_startup()
421 dev_err(port->dev, "unable to request IRQ %d\n", in mvebu_uart_startup()
426 ret = devm_request_irq(port->dev, mvuart->irq[UART_TX_IRQ], in mvebu_uart_startup()
427 mvebu_uart_tx_isr, port->irqflags, in mvebu_uart_startup()
428 dev_name(port->dev), in mvebu_uart_startup()
429 port); in mvebu_uart_startup()
431 dev_err(port->dev, "unable to request IRQ %d\n", in mvebu_uart_startup()
433 devm_free_irq(port->dev, mvuart->irq[UART_RX_IRQ], in mvebu_uart_startup()
434 port); in mvebu_uart_startup()
442 static void mvebu_uart_shutdown(struct uart_port *port) in mvebu_uart_shutdown() argument
444 struct mvebu_uart *mvuart = to_mvuart(port); in mvebu_uart_shutdown()
446 writel(0, port->membase + UART_INTR(port)); in mvebu_uart_shutdown()
449 devm_free_irq(port->dev, mvuart->irq[UART_IRQ_SUM], port); in mvebu_uart_shutdown()
451 devm_free_irq(port->dev, mvuart->irq[UART_RX_IRQ], port); in mvebu_uart_shutdown()
452 devm_free_irq(port->dev, mvuart->irq[UART_TX_IRQ], port); in mvebu_uart_shutdown()
456 static unsigned int mvebu_uart_baud_rate_set(struct uart_port *port, unsigned int baud) in mvebu_uart_baud_rate_set() argument
461 if (!port->uartclk) in mvebu_uart_baud_rate_set()
475 d_divisor = DIV_ROUND_CLOSEST(port->uartclk, baud * m_divisor); in mvebu_uart_baud_rate_set()
477 brdv = readl(port->membase + UART_BRDV); in mvebu_uart_baud_rate_set()
480 writel(brdv, port->membase + UART_BRDV); in mvebu_uart_baud_rate_set()
482 osamp = readl(port->membase + UART_OSAMP); in mvebu_uart_baud_rate_set()
484 writel(osamp, port->membase + UART_OSAMP); in mvebu_uart_baud_rate_set()
486 return DIV_ROUND_CLOSEST(port->uartclk, d_divisor * m_divisor); in mvebu_uart_baud_rate_set()
489 static void mvebu_uart_set_termios(struct uart_port *port, in mvebu_uart_set_termios() argument
496 spin_lock_irqsave(&port->lock, flags); in mvebu_uart_set_termios()
498 port->read_status_mask = STAT_RX_RDY(port) | STAT_OVR_ERR | in mvebu_uart_set_termios()
499 STAT_TX_RDY(port) | STAT_TX_FIFO_FUL; in mvebu_uart_set_termios()
502 port->read_status_mask |= STAT_FRM_ERR | STAT_PAR_ERR; in mvebu_uart_set_termios()
504 port->ignore_status_mask = 0; in mvebu_uart_set_termios()
506 port->ignore_status_mask |= in mvebu_uart_set_termios()
510 port->ignore_status_mask |= STAT_RX_RDY(port) | STAT_BRK_ERR; in mvebu_uart_set_termios()
519 min_baud = DIV_ROUND_UP(port->uartclk, 1023 * 16); in mvebu_uart_set_termios()
522 baud = uart_get_baud_rate(port, termios, old, min_baud, max_baud); in mvebu_uart_set_termios()
523 baud = mvebu_uart_baud_rate_set(port, baud); in mvebu_uart_set_termios()
540 uart_update_timeout(port, termios->c_cflag, baud); in mvebu_uart_set_termios()
543 spin_unlock_irqrestore(&port->lock, flags); in mvebu_uart_set_termios()
546 static const char *mvebu_uart_type(struct uart_port *port) in mvebu_uart_type() argument
551 static void mvebu_uart_release_port(struct uart_port *port) in mvebu_uart_release_port() argument
556 static int mvebu_uart_request_port(struct uart_port *port) in mvebu_uart_request_port() argument
562 static int mvebu_uart_get_poll_char(struct uart_port *port) in mvebu_uart_get_poll_char() argument
564 unsigned int st = readl(port->membase + UART_STAT); in mvebu_uart_get_poll_char()
566 if (!(st & STAT_RX_RDY(port))) in mvebu_uart_get_poll_char()
569 return readl(port->membase + UART_RBR(port)); in mvebu_uart_get_poll_char()
572 static void mvebu_uart_put_poll_char(struct uart_port *port, unsigned char c) in mvebu_uart_put_poll_char() argument
577 st = readl(port->membase + UART_STAT); in mvebu_uart_put_poll_char()
585 writel(c, port->membase + UART_TSH(port)); in mvebu_uart_put_poll_char()
613 static void mvebu_uart_putc(struct uart_port *port, int c) in mvebu_uart_putc() argument
618 st = readl(port->membase + UART_STAT); in mvebu_uart_putc()
624 writel(c, port->membase + UART_STD_TSH); in mvebu_uart_putc()
627 st = readl(port->membase + UART_STAT); in mvebu_uart_putc()
639 uart_console_write(&dev->port, s, n, mvebu_uart_putc); in mvebu_uart_putc_early_write()
646 if (!device->port.membase) in mvebu_uart_early_console_setup()
658 static void wait_for_xmitr(struct uart_port *port) in wait_for_xmitr() argument
662 readl_poll_timeout_atomic(port->membase + UART_STAT, val, in wait_for_xmitr()
663 (val & STAT_TX_RDY(port)), 1, 10000); in wait_for_xmitr()
666 static void wait_for_xmite(struct uart_port *port) in wait_for_xmite() argument
670 readl_poll_timeout_atomic(port->membase + UART_STAT, val, in wait_for_xmite()
674 static void mvebu_uart_console_putchar(struct uart_port *port, int ch) in mvebu_uart_console_putchar() argument
676 wait_for_xmitr(port); in mvebu_uart_console_putchar()
677 writel(ch, port->membase + UART_TSH(port)); in mvebu_uart_console_putchar()
683 struct uart_port *port = &mvebu_uart_ports[co->index]; in mvebu_uart_console_write() local
689 locked = spin_trylock_irqsave(&port->lock, flags); in mvebu_uart_console_write()
691 spin_lock_irqsave(&port->lock, flags); in mvebu_uart_console_write()
693 ier = readl(port->membase + UART_CTRL(port)) & CTRL_BRK_INT; in mvebu_uart_console_write()
694 intr = readl(port->membase + UART_INTR(port)) & in mvebu_uart_console_write()
695 (CTRL_RX_RDY_INT(port) | CTRL_TX_RDY_INT(port)); in mvebu_uart_console_write()
696 writel(0, port->membase + UART_CTRL(port)); in mvebu_uart_console_write()
697 writel(0, port->membase + UART_INTR(port)); in mvebu_uart_console_write()
699 uart_console_write(port, s, count, mvebu_uart_console_putchar); in mvebu_uart_console_write()
701 wait_for_xmite(port); in mvebu_uart_console_write()
704 writel(ier, port->membase + UART_CTRL(port)); in mvebu_uart_console_write()
707 ctl = intr | readl(port->membase + UART_INTR(port)); in mvebu_uart_console_write()
708 writel(ctl, port->membase + UART_INTR(port)); in mvebu_uart_console_write()
712 spin_unlock_irqrestore(&port->lock, flags); in mvebu_uart_console_write()
717 struct uart_port *port; in mvebu_uart_console_setup() local
726 port = &mvebu_uart_ports[co->index]; in mvebu_uart_console_setup()
728 if (!port->mapbase || !port->membase) { in mvebu_uart_console_setup()
736 return uart_set_options(port, co, baud, parity, bits, flow); in mvebu_uart_console_setup()
776 struct uart_port *port = mvuart->port; in mvebu_uart_suspend() local
778 uart_suspend_port(&mvebu_uart_driver, port); in mvebu_uart_suspend()
780 mvuart->pm_regs.rbr = readl(port->membase + UART_RBR(port)); in mvebu_uart_suspend()
781 mvuart->pm_regs.tsh = readl(port->membase + UART_TSH(port)); in mvebu_uart_suspend()
782 mvuart->pm_regs.ctrl = readl(port->membase + UART_CTRL(port)); in mvebu_uart_suspend()
783 mvuart->pm_regs.intr = readl(port->membase + UART_INTR(port)); in mvebu_uart_suspend()
784 mvuart->pm_regs.stat = readl(port->membase + UART_STAT); in mvebu_uart_suspend()
785 mvuart->pm_regs.brdv = readl(port->membase + UART_BRDV); in mvebu_uart_suspend()
786 mvuart->pm_regs.osamp = readl(port->membase + UART_OSAMP); in mvebu_uart_suspend()
796 struct uart_port *port = mvuart->port; in mvebu_uart_resume() local
798 writel(mvuart->pm_regs.rbr, port->membase + UART_RBR(port)); in mvebu_uart_resume()
799 writel(mvuart->pm_regs.tsh, port->membase + UART_TSH(port)); in mvebu_uart_resume()
800 writel(mvuart->pm_regs.ctrl, port->membase + UART_CTRL(port)); in mvebu_uart_resume()
801 writel(mvuart->pm_regs.intr, port->membase + UART_INTR(port)); in mvebu_uart_resume()
802 writel(mvuart->pm_regs.stat, port->membase + UART_STAT); in mvebu_uart_resume()
803 writel(mvuart->pm_regs.brdv, port->membase + UART_BRDV); in mvebu_uart_resume()
804 writel(mvuart->pm_regs.osamp, port->membase + UART_OSAMP); in mvebu_uart_resume()
806 uart_resume_port(&mvebu_uart_driver, port); in mvebu_uart_resume()
827 struct uart_port *port; in mvebu_uart_probe() local
849 port = &mvebu_uart_ports[pdev->id]; in mvebu_uart_probe()
851 spin_lock_init(&port->lock); in mvebu_uart_probe()
853 port->dev = &pdev->dev; in mvebu_uart_probe()
854 port->type = PORT_MVEBU; in mvebu_uart_probe()
855 port->ops = &mvebu_uart_ops; in mvebu_uart_probe()
856 port->regshift = 0; in mvebu_uart_probe()
858 port->fifosize = 32; in mvebu_uart_probe()
859 port->iotype = UPIO_MEM32; in mvebu_uart_probe()
860 port->flags = UPF_FIXED_PORT; in mvebu_uart_probe()
861 port->line = pdev->id; in mvebu_uart_probe()
868 port->irq = 0; in mvebu_uart_probe()
869 port->irqflags = 0; in mvebu_uart_probe()
870 port->mapbase = reg->start; in mvebu_uart_probe()
872 port->membase = devm_ioremap_resource(&pdev->dev, reg); in mvebu_uart_probe()
873 if (IS_ERR(port->membase)) in mvebu_uart_probe()
874 return PTR_ERR(port->membase); in mvebu_uart_probe()
883 mvuart->port = port; in mvebu_uart_probe()
885 port->private_data = mvuart; in mvebu_uart_probe()
894 if (IS_EXTENDED(port)) { in mvebu_uart_probe()
900 port->uartclk = clk_get_rate(mvuart->clk); in mvebu_uart_probe()
931 writel(CTRL_SOFT_RST, port->membase + UART_CTRL(port)); in mvebu_uart_probe()
933 writel(0, port->membase + UART_CTRL(port)); in mvebu_uart_probe()
935 return uart_add_one_port(&mvebu_uart_driver, port); in mvebu_uart_probe()