Lines Matching full:up
57 static inline unsigned int ar933x_uart_read(struct ar933x_uart_port *up, in ar933x_uart_read() argument
60 return readl(up->port.membase + offset); in ar933x_uart_read()
63 static inline void ar933x_uart_write(struct ar933x_uart_port *up, in ar933x_uart_write() argument
66 writel(value, up->port.membase + offset); in ar933x_uart_write()
69 static inline void ar933x_uart_rmw(struct ar933x_uart_port *up, in ar933x_uart_rmw() argument
76 t = ar933x_uart_read(up, offset); in ar933x_uart_rmw()
79 ar933x_uart_write(up, offset, t); in ar933x_uart_rmw()
82 static inline void ar933x_uart_rmw_set(struct ar933x_uart_port *up, in ar933x_uart_rmw_set() argument
86 ar933x_uart_rmw(up, offset, 0, val); in ar933x_uart_rmw_set()
89 static inline void ar933x_uart_rmw_clear(struct ar933x_uart_port *up, in ar933x_uart_rmw_clear() argument
93 ar933x_uart_rmw(up, offset, val, 0); in ar933x_uart_rmw_clear()
96 static inline void ar933x_uart_start_tx_interrupt(struct ar933x_uart_port *up) in ar933x_uart_start_tx_interrupt() argument
98 up->ier |= AR933X_UART_INT_TX_EMPTY; in ar933x_uart_start_tx_interrupt()
99 ar933x_uart_write(up, AR933X_UART_INT_EN_REG, up->ier); in ar933x_uart_start_tx_interrupt()
102 static inline void ar933x_uart_stop_tx_interrupt(struct ar933x_uart_port *up) in ar933x_uart_stop_tx_interrupt() argument
104 up->ier &= ~AR933X_UART_INT_TX_EMPTY; in ar933x_uart_stop_tx_interrupt()
105 ar933x_uart_write(up, AR933X_UART_INT_EN_REG, up->ier); in ar933x_uart_stop_tx_interrupt()
108 static inline void ar933x_uart_start_rx_interrupt(struct ar933x_uart_port *up) in ar933x_uart_start_rx_interrupt() argument
110 up->ier |= AR933X_UART_INT_RX_VALID; in ar933x_uart_start_rx_interrupt()
111 ar933x_uart_write(up, AR933X_UART_INT_EN_REG, up->ier); in ar933x_uart_start_rx_interrupt()
114 static inline void ar933x_uart_stop_rx_interrupt(struct ar933x_uart_port *up) in ar933x_uart_stop_rx_interrupt() argument
116 up->ier &= ~AR933X_UART_INT_RX_VALID; in ar933x_uart_stop_rx_interrupt()
117 ar933x_uart_write(up, AR933X_UART_INT_EN_REG, up->ier); in ar933x_uart_stop_rx_interrupt()
120 static inline void ar933x_uart_putc(struct ar933x_uart_port *up, int ch) in ar933x_uart_putc() argument
126 ar933x_uart_write(up, AR933X_UART_DATA_REG, rdata); in ar933x_uart_putc()
131 struct ar933x_uart_port *up = in ar933x_uart_tx_empty() local
136 uart_port_lock_irqsave(&up->port, &flags); in ar933x_uart_tx_empty()
137 rdata = ar933x_uart_read(up, AR933X_UART_DATA_REG); in ar933x_uart_tx_empty()
138 uart_port_unlock_irqrestore(&up->port, flags); in ar933x_uart_tx_empty()
145 struct ar933x_uart_port *up = in ar933x_uart_get_mctrl() local
149 mctrl_gpio_get(up->gpios, &ret); in ar933x_uart_get_mctrl()
156 struct ar933x_uart_port *up = in ar933x_uart_set_mctrl() local
159 mctrl_gpio_set(up->gpios, mctrl); in ar933x_uart_set_mctrl()
164 struct ar933x_uart_port *up = in ar933x_uart_start_tx() local
167 ar933x_uart_start_tx_interrupt(up); in ar933x_uart_start_tx()
170 static void ar933x_uart_wait_tx_complete(struct ar933x_uart_port *up) in ar933x_uart_wait_tx_complete() argument
175 /* Wait up to 60ms for the character(s) to be sent. */ in ar933x_uart_wait_tx_complete()
177 status = ar933x_uart_read(up, AR933X_UART_CS_REG); in ar933x_uart_wait_tx_complete()
184 dev_err(up->port.dev, "waiting for TX timed out\n"); in ar933x_uart_wait_tx_complete()
187 static void ar933x_uart_rx_flush(struct ar933x_uart_port *up) in ar933x_uart_rx_flush() argument
192 ar933x_uart_write(up, AR933X_UART_INT_REG, AR933X_UART_INT_RX_VALID); in ar933x_uart_rx_flush()
196 ar933x_uart_write(up, AR933X_UART_DATA_REG, AR933X_UART_DATA_RX_CSR); in ar933x_uart_rx_flush()
197 status = ar933x_uart_read(up, AR933X_UART_DATA_REG); in ar933x_uart_rx_flush()
203 struct ar933x_uart_port *up = in ar933x_uart_stop_tx() local
206 ar933x_uart_stop_tx_interrupt(up); in ar933x_uart_stop_tx()
211 struct ar933x_uart_port *up = in ar933x_uart_stop_rx() local
214 ar933x_uart_stop_rx_interrupt(up); in ar933x_uart_stop_rx()
219 struct ar933x_uart_port *up = in ar933x_uart_break_ctl() local
223 uart_port_lock_irqsave(&up->port, &flags); in ar933x_uart_break_ctl()
225 ar933x_uart_rmw_set(up, AR933X_UART_CS_REG, in ar933x_uart_break_ctl()
228 ar933x_uart_rmw_clear(up, AR933X_UART_CS_REG, in ar933x_uart_break_ctl()
230 uart_port_unlock_irqrestore(&up->port, flags); in ar933x_uart_break_ctl()
288 struct ar933x_uart_port *up = in ar933x_uart_set_termios() local
314 baud = uart_get_baud_rate(port, new, old, up->min_baud, up->max_baud); in ar933x_uart_set_termios()
321 uart_port_lock_irqsave(&up->port, &flags); in ar933x_uart_set_termios()
324 ar933x_uart_rmw_clear(up, AR933X_UART_CS_REG, in ar933x_uart_set_termios()
330 up->port.ignore_status_mask = 0; in ar933x_uart_set_termios()
334 up->port.ignore_status_mask |= AR933X_DUMMY_STATUS_RD; in ar933x_uart_set_termios()
336 ar933x_uart_write(up, AR933X_UART_CLOCK_REG, in ar933x_uart_set_termios()
340 ar933x_uart_rmw(up, AR933X_UART_CS_REG, AR933X_UART_CS_PARITY_M, cs); in ar933x_uart_set_termios()
343 ar933x_uart_rmw_set(up, AR933X_UART_CS_REG, in ar933x_uart_set_termios()
347 ar933x_uart_rmw_set(up, AR933X_UART_CS_REG, in ar933x_uart_set_termios()
351 ar933x_uart_rmw(up, AR933X_UART_CS_REG, in ar933x_uart_set_termios()
355 uart_port_unlock_irqrestore(&up->port, flags); in ar933x_uart_set_termios()
361 static void ar933x_uart_rx_chars(struct ar933x_uart_port *up) in ar933x_uart_rx_chars() argument
363 struct tty_port *port = &up->port.state->port; in ar933x_uart_rx_chars()
370 rdata = ar933x_uart_read(up, AR933X_UART_DATA_REG); in ar933x_uart_rx_chars()
375 ar933x_uart_write(up, AR933X_UART_DATA_REG, in ar933x_uart_rx_chars()
378 up->port.icount.rx++; in ar933x_uart_rx_chars()
381 if (uart_prepare_sysrq_char(&up->port, ch)) in ar933x_uart_rx_chars()
384 if ((up->port.ignore_status_mask & AR933X_DUMMY_STATUS_RD) == 0) in ar933x_uart_rx_chars()
391 static void ar933x_uart_tx_chars(struct ar933x_uart_port *up) in ar933x_uart_tx_chars() argument
393 struct tty_port *tport = &up->port.state->port; in ar933x_uart_tx_chars()
394 struct serial_rs485 *rs485conf = &up->port.rs485; in ar933x_uart_tx_chars()
398 if (uart_tx_stopped(&up->port)) in ar933x_uart_tx_chars()
402 (up->port.x_char || !kfifo_is_empty(&tport->xmit_fifo))) { in ar933x_uart_tx_chars()
403 ar933x_uart_stop_rx_interrupt(up); in ar933x_uart_tx_chars()
404 gpiod_set_value(up->rts_gpiod, !!(rs485conf->flags & SER_RS485_RTS_ON_SEND)); in ar933x_uart_tx_chars()
408 count = up->port.fifosize; in ar933x_uart_tx_chars()
413 rdata = ar933x_uart_read(up, AR933X_UART_DATA_REG); in ar933x_uart_tx_chars()
417 if (up->port.x_char) { in ar933x_uart_tx_chars()
418 ar933x_uart_putc(up, up->port.x_char); in ar933x_uart_tx_chars()
419 up->port.icount.tx++; in ar933x_uart_tx_chars()
420 up->port.x_char = 0; in ar933x_uart_tx_chars()
424 if (!uart_fifo_get(&up->port, &c)) in ar933x_uart_tx_chars()
427 ar933x_uart_putc(up, c); in ar933x_uart_tx_chars()
431 uart_write_wakeup(&up->port); in ar933x_uart_tx_chars()
434 ar933x_uart_start_tx_interrupt(up); in ar933x_uart_tx_chars()
436 ar933x_uart_wait_tx_complete(up); in ar933x_uart_tx_chars()
437 ar933x_uart_rx_flush(up); in ar933x_uart_tx_chars()
438 ar933x_uart_start_rx_interrupt(up); in ar933x_uart_tx_chars()
439 gpiod_set_value(up->rts_gpiod, !!(rs485conf->flags & SER_RS485_RTS_AFTER_SEND)); in ar933x_uart_tx_chars()
445 struct ar933x_uart_port *up = dev_id; in ar933x_uart_interrupt() local
448 status = ar933x_uart_read(up, AR933X_UART_CS_REG); in ar933x_uart_interrupt()
452 uart_port_lock(&up->port); in ar933x_uart_interrupt()
454 status = ar933x_uart_read(up, AR933X_UART_INT_REG); in ar933x_uart_interrupt()
455 status &= ar933x_uart_read(up, AR933X_UART_INT_EN_REG); in ar933x_uart_interrupt()
458 ar933x_uart_write(up, AR933X_UART_INT_REG, in ar933x_uart_interrupt()
460 ar933x_uart_rx_chars(up); in ar933x_uart_interrupt()
464 ar933x_uart_write(up, AR933X_UART_INT_REG, in ar933x_uart_interrupt()
466 ar933x_uart_stop_tx_interrupt(up); in ar933x_uart_interrupt()
467 ar933x_uart_tx_chars(up); in ar933x_uart_interrupt()
470 uart_unlock_and_check_sysrq(&up->port); in ar933x_uart_interrupt()
477 struct ar933x_uart_port *up = in ar933x_uart_startup() local
482 ret = request_irq(up->port.irq, ar933x_uart_interrupt, in ar933x_uart_startup()
483 up->port.irqflags, dev_name(up->port.dev), up); in ar933x_uart_startup()
487 uart_port_lock_irqsave(&up->port, &flags); in ar933x_uart_startup()
490 ar933x_uart_rmw_set(up, AR933X_UART_CS_REG, in ar933x_uart_startup()
494 ar933x_uart_rmw_set(up, AR933X_UART_CS_REG, in ar933x_uart_startup()
498 ar933x_uart_start_rx_interrupt(up); in ar933x_uart_startup()
500 uart_port_unlock_irqrestore(&up->port, flags); in ar933x_uart_startup()
507 struct ar933x_uart_port *up = in ar933x_uart_shutdown() local
511 up->ier = 0; in ar933x_uart_shutdown()
512 ar933x_uart_write(up, AR933X_UART_INT_EN_REG, up->ier); in ar933x_uart_shutdown()
515 ar933x_uart_rmw_clear(up, AR933X_UART_CS_REG, in ar933x_uart_shutdown()
518 free_irq(up->port.irq, up); in ar933x_uart_shutdown()
546 struct ar933x_uart_port *up = in ar933x_uart_verify_port() local
556 if (ser->baud_base < up->min_baud || in ar933x_uart_verify_port()
557 ser->baud_base > up->max_baud) in ar933x_uart_verify_port()
584 struct ar933x_uart_port *up = in ar933x_config_rs485() local
588 gpiod_set_value(up->rts_gpiod, in ar933x_config_rs485()
598 static void ar933x_uart_wait_xmitr(struct ar933x_uart_port *up) in ar933x_uart_wait_xmitr() argument
603 /* Wait up to 60ms for the character(s) to be sent. */ in ar933x_uart_wait_xmitr()
605 status = ar933x_uart_read(up, AR933X_UART_DATA_REG); in ar933x_uart_wait_xmitr()
614 struct ar933x_uart_port *up = in ar933x_uart_console_putchar() local
617 ar933x_uart_wait_xmitr(up); in ar933x_uart_console_putchar()
618 ar933x_uart_putc(up, ch); in ar933x_uart_console_putchar()
624 struct ar933x_uart_port *up = ar933x_console_ports[co->index]; in ar933x_uart_console_write() local
630 locked = uart_port_trylock_irqsave(&up->port, &flags); in ar933x_uart_console_write()
632 uart_port_lock_irqsave(&up->port, &flags); in ar933x_uart_console_write()
637 int_en = ar933x_uart_read(up, AR933X_UART_INT_EN_REG); in ar933x_uart_console_write()
638 ar933x_uart_write(up, AR933X_UART_INT_EN_REG, 0); in ar933x_uart_console_write()
640 uart_console_write(&up->port, s, count, ar933x_uart_console_putchar); in ar933x_uart_console_write()
646 ar933x_uart_wait_xmitr(up); in ar933x_uart_console_write()
647 ar933x_uart_write(up, AR933X_UART_INT_EN_REG, int_en); in ar933x_uart_console_write()
649 ar933x_uart_write(up, AR933X_UART_INT_REG, AR933X_UART_INT_ALLINTS); in ar933x_uart_console_write()
652 uart_port_unlock_irqrestore(&up->port, flags); in ar933x_uart_console_write()
657 struct ar933x_uart_port *up; in ar933x_uart_console_setup() local
666 up = ar933x_console_ports[co->index]; in ar933x_uart_console_setup()
667 if (!up) in ar933x_uart_console_setup()
673 return uart_set_options(&up->port, co, baud, parity, bits, flow); in ar933x_uart_console_setup()
701 struct ar933x_uart_port *up; in ar933x_uart_probe() local
731 up = devm_kzalloc(&pdev->dev, sizeof(struct ar933x_uart_port), in ar933x_uart_probe()
733 if (!up) in ar933x_uart_probe()
736 up->clk = devm_clk_get(&pdev->dev, "uart"); in ar933x_uart_probe()
737 if (IS_ERR(up->clk)) { in ar933x_uart_probe()
739 return PTR_ERR(up->clk); in ar933x_uart_probe()
742 port = &up->port; in ar933x_uart_probe()
748 ret = clk_prepare_enable(up->clk); in ar933x_uart_probe()
752 port->uartclk = clk_get_rate(up->clk); in ar933x_uart_probe()
772 up->min_baud = max_t(unsigned int, baud, AR933X_UART_MIN_BAUD); in ar933x_uart_probe()
775 up->max_baud = min_t(unsigned int, baud, AR933X_UART_MAX_BAUD); in ar933x_uart_probe()
781 up->gpios = mctrl_gpio_init(port, 0); in ar933x_uart_probe()
782 if (IS_ERR(up->gpios) && PTR_ERR(up->gpios) != -ENOSYS) { in ar933x_uart_probe()
783 ret = PTR_ERR(up->gpios); in ar933x_uart_probe()
787 up->rts_gpiod = mctrl_gpio_to_gpiod(up->gpios, UART_GPIO_RTS); in ar933x_uart_probe()
789 if (!up->rts_gpiod) { in ar933x_uart_probe()
798 ar933x_console_ports[up->port.line] = up; in ar933x_uart_probe()
801 ret = uart_add_one_port(&ar933x_uart_driver, &up->port); in ar933x_uart_probe()
805 platform_set_drvdata(pdev, up); in ar933x_uart_probe()
809 clk_disable_unprepare(up->clk); in ar933x_uart_probe()
815 struct ar933x_uart_port *up; in ar933x_uart_remove() local
817 up = platform_get_drvdata(pdev); in ar933x_uart_remove()
819 if (up) { in ar933x_uart_remove()
820 uart_remove_one_port(&ar933x_uart_driver, &up->port); in ar933x_uart_remove()
821 clk_disable_unprepare(up->clk); in ar933x_uart_remove()