Lines Matching refs:port
36 struct uart_port port; member
146 static inline struct asc_port *to_asc_port(struct uart_port *port) in to_asc_port() argument
148 return container_of(port, struct asc_port, port); in to_asc_port()
151 static inline u32 asc_in(struct uart_port *port, u32 offset) in asc_in() argument
154 return readl_relaxed(port->membase + offset); in asc_in()
156 return readl(port->membase + offset); in asc_in()
160 static inline void asc_out(struct uart_port *port, u32 offset, u32 value) in asc_out() argument
163 writel_relaxed(value, port->membase + offset); in asc_out()
165 writel(value, port->membase + offset); in asc_out()
173 static inline void asc_disable_tx_interrupts(struct uart_port *port) in asc_disable_tx_interrupts() argument
175 u32 intenable = asc_in(port, ASC_INTEN) & ~ASC_INTEN_THE; in asc_disable_tx_interrupts()
176 asc_out(port, ASC_INTEN, intenable); in asc_disable_tx_interrupts()
177 (void)asc_in(port, ASC_INTEN); /* Defeat bus write posting */ in asc_disable_tx_interrupts()
180 static inline void asc_enable_tx_interrupts(struct uart_port *port) in asc_enable_tx_interrupts() argument
182 u32 intenable = asc_in(port, ASC_INTEN) | ASC_INTEN_THE; in asc_enable_tx_interrupts()
183 asc_out(port, ASC_INTEN, intenable); in asc_enable_tx_interrupts()
186 static inline void asc_disable_rx_interrupts(struct uart_port *port) in asc_disable_rx_interrupts() argument
188 u32 intenable = asc_in(port, ASC_INTEN) & ~ASC_INTEN_RBE; in asc_disable_rx_interrupts()
189 asc_out(port, ASC_INTEN, intenable); in asc_disable_rx_interrupts()
190 (void)asc_in(port, ASC_INTEN); /* Defeat bus write posting */ in asc_disable_rx_interrupts()
193 static inline void asc_enable_rx_interrupts(struct uart_port *port) in asc_enable_rx_interrupts() argument
195 u32 intenable = asc_in(port, ASC_INTEN) | ASC_INTEN_RBE; in asc_enable_rx_interrupts()
196 asc_out(port, ASC_INTEN, intenable); in asc_enable_rx_interrupts()
199 static inline u32 asc_txfifo_is_empty(struct uart_port *port) in asc_txfifo_is_empty() argument
201 return asc_in(port, ASC_STA) & ASC_STA_TE; in asc_txfifo_is_empty()
204 static inline u32 asc_txfifo_is_half_empty(struct uart_port *port) in asc_txfifo_is_half_empty() argument
206 return asc_in(port, ASC_STA) & ASC_STA_THE; in asc_txfifo_is_half_empty()
209 static inline const char *asc_port_name(struct uart_port *port) in asc_port_name() argument
211 return to_platform_device(port->dev)->name; in asc_port_name()
221 static inline unsigned asc_hw_txroom(struct uart_port *port) in asc_hw_txroom() argument
223 u32 status = asc_in(port, ASC_STA); in asc_hw_txroom()
226 return port->fifosize / 2; in asc_hw_txroom()
238 static void asc_transmit_chars(struct uart_port *port) in asc_transmit_chars() argument
240 struct circ_buf *xmit = &port->state->xmit; in asc_transmit_chars()
244 txroom = asc_hw_txroom(port); in asc_transmit_chars()
246 if ((txroom != 0) && port->x_char) { in asc_transmit_chars()
247 c = port->x_char; in asc_transmit_chars()
248 port->x_char = 0; in asc_transmit_chars()
249 asc_out(port, ASC_TXBUF, c); in asc_transmit_chars()
250 port->icount.tx++; in asc_transmit_chars()
251 txroom = asc_hw_txroom(port); in asc_transmit_chars()
254 if (uart_tx_stopped(port)) { in asc_transmit_chars()
259 asc_disable_tx_interrupts(port); in asc_transmit_chars()
264 asc_disable_tx_interrupts(port); in asc_transmit_chars()
274 asc_out(port, ASC_TXBUF, c); in asc_transmit_chars()
275 port->icount.tx++; in asc_transmit_chars()
280 uart_write_wakeup(port); in asc_transmit_chars()
283 asc_disable_tx_interrupts(port); in asc_transmit_chars()
286 static void asc_receive_chars(struct uart_port *port) in asc_receive_chars() argument
288 struct tty_port *tport = &port->state->port; in asc_receive_chars()
299 mode = asc_in(port, ASC_CTL) & ASC_CTL_MODE_MSK; in asc_receive_chars()
303 if (irqd_is_wakeup_set(irq_get_irq_data(port->irq))) in asc_receive_chars()
306 while ((status = asc_in(port, ASC_STA)) & ASC_STA_RBF) { in asc_receive_chars()
307 c = asc_in(port, ASC_RXBUF) | ASC_RXBUF_DUMMY_RX; in asc_receive_chars()
309 port->icount.rx++; in asc_receive_chars()
316 port->icount.brk++; in asc_receive_chars()
317 if (uart_handle_break(port)) in asc_receive_chars()
321 port->icount.frame++; in asc_receive_chars()
324 port->icount.parity++; in asc_receive_chars()
331 port->icount.overrun++; in asc_receive_chars()
335 c &= port->read_status_mask; in asc_receive_chars()
345 if (uart_handle_sysrq_char(port, c & 0xff)) in asc_receive_chars()
348 uart_insert_char(port, c, ASC_RXBUF_DUMMY_OE, c & 0xff, flag); in asc_receive_chars()
357 struct uart_port *port = ptr; in asc_interrupt() local
360 spin_lock(&port->lock); in asc_interrupt()
362 status = asc_in(port, ASC_STA); in asc_interrupt()
366 asc_receive_chars(port); in asc_interrupt()
370 (asc_in(port, ASC_INTEN) & ASC_INTEN_THE)) { in asc_interrupt()
372 asc_transmit_chars(port); in asc_interrupt()
375 spin_unlock(&port->lock); in asc_interrupt()
386 static unsigned int asc_tx_empty(struct uart_port *port) in asc_tx_empty() argument
388 return asc_txfifo_is_empty(port) ? TIOCSER_TEMT : 0; in asc_tx_empty()
391 static void asc_set_mctrl(struct uart_port *port, unsigned int mctrl) in asc_set_mctrl() argument
393 struct asc_port *ascport = to_asc_port(port); in asc_set_mctrl()
410 if (asc_in(port, ASC_CTL) & ASC_CTL_CTSENABLE) in asc_set_mctrl()
416 static unsigned int asc_get_mctrl(struct uart_port *port) in asc_get_mctrl() argument
426 static void asc_start_tx(struct uart_port *port) in asc_start_tx() argument
428 struct circ_buf *xmit = &port->state->xmit; in asc_start_tx()
431 asc_enable_tx_interrupts(port); in asc_start_tx()
435 static void asc_stop_tx(struct uart_port *port) in asc_stop_tx() argument
437 asc_disable_tx_interrupts(port); in asc_stop_tx()
441 static void asc_stop_rx(struct uart_port *port) in asc_stop_rx() argument
443 asc_disable_rx_interrupts(port); in asc_stop_rx()
447 static void asc_break_ctl(struct uart_port *port, int break_state) in asc_break_ctl() argument
455 static int asc_startup(struct uart_port *port) in asc_startup() argument
457 if (request_irq(port->irq, asc_interrupt, 0, in asc_startup()
458 asc_port_name(port), port)) { in asc_startup()
459 dev_err(port->dev, "cannot allocate irq.\n"); in asc_startup()
463 asc_transmit_chars(port); in asc_startup()
464 asc_enable_rx_interrupts(port); in asc_startup()
469 static void asc_shutdown(struct uart_port *port) in asc_shutdown() argument
471 asc_disable_tx_interrupts(port); in asc_shutdown()
472 asc_disable_rx_interrupts(port); in asc_shutdown()
473 free_irq(port->irq, port); in asc_shutdown()
476 static void asc_pm(struct uart_port *port, unsigned int state, in asc_pm() argument
479 struct asc_port *ascport = to_asc_port(port); in asc_pm()
493 spin_lock_irqsave(&port->lock, flags); in asc_pm()
494 ctl = asc_in(port, ASC_CTL) & ~ASC_CTL_RUN; in asc_pm()
495 asc_out(port, ASC_CTL, ctl); in asc_pm()
496 spin_unlock_irqrestore(&port->lock, flags); in asc_pm()
502 static void asc_set_termios(struct uart_port *port, struct ktermios *termios, in asc_set_termios() argument
505 struct asc_port *ascport = to_asc_port(port); in asc_set_termios()
516 port->uartclk = clk_get_rate(ascport->clk); in asc_set_termios()
518 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); in asc_set_termios()
521 spin_lock_irqsave(&port->lock, flags); in asc_set_termios()
524 ctrl_val = asc_in(port, ASC_CTL); in asc_set_termios()
527 asc_out(port, ASC_CTL, (ctrl_val & ~ASC_CTL_RUN)); in asc_set_termios()
531 asc_out(port, ASC_TXRESET, 1); in asc_set_termios()
532 asc_out(port, ASC_RXRESET, 1); in asc_set_termios()
559 devm_gpiod_put(port->dev, ascport->rts); in asc_set_termios()
571 gpiod = devm_gpiod_get(port->dev, "rts", GPIOD_OUT_LOW); in asc_set_termios()
574 port->dev->of_node->name); in asc_set_termios()
581 asc_out(port, ASC_BAUDRATE, (port->uartclk / (16 * baud))); in asc_set_termios()
594 do_div(dividend, port->uartclk / 16); in asc_set_termios()
595 asc_out(port, ASC_BAUDRATE, dividend); in asc_set_termios()
599 uart_update_timeout(port, cflag, baud); in asc_set_termios()
601 ascport->port.read_status_mask = ASC_RXBUF_DUMMY_OE; in asc_set_termios()
603 ascport->port.read_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE; in asc_set_termios()
605 ascport->port.read_status_mask |= ASC_RXBUF_DUMMY_BE; in asc_set_termios()
610 ascport->port.ignore_status_mask = 0; in asc_set_termios()
612 ascport->port.ignore_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE; in asc_set_termios()
614 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_BE; in asc_set_termios()
620 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_OE; in asc_set_termios()
627 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_RX; in asc_set_termios()
630 asc_out(port, ASC_TIMEOUT, 20); in asc_set_termios()
633 asc_out(port, ASC_CTL, (ctrl_val | ASC_CTL_RUN)); in asc_set_termios()
635 spin_unlock_irqrestore(&port->lock, flags); in asc_set_termios()
638 static const char *asc_type(struct uart_port *port) in asc_type() argument
640 return (port->type == PORT_ASC) ? DRIVER_NAME : NULL; in asc_type()
643 static void asc_release_port(struct uart_port *port) in asc_release_port() argument
647 static int asc_request_port(struct uart_port *port) in asc_request_port() argument
656 static void asc_config_port(struct uart_port *port, int flags) in asc_config_port() argument
659 port->type = PORT_ASC; in asc_config_port()
663 asc_verify_port(struct uart_port *port, struct serial_struct *ser) in asc_verify_port() argument
675 static int asc_get_poll_char(struct uart_port *port) in asc_get_poll_char() argument
677 if (!(asc_in(port, ASC_STA) & ASC_STA_RBF)) in asc_get_poll_char()
680 return asc_in(port, ASC_RXBUF); in asc_get_poll_char()
683 static void asc_put_poll_char(struct uart_port *port, unsigned char c) in asc_put_poll_char() argument
685 while (!asc_txfifo_is_half_empty(port)) in asc_put_poll_char()
687 asc_out(port, ASC_TXBUF, c); in asc_put_poll_char()
720 struct uart_port *port = &ascport->port; in asc_init_port() local
724 port->iotype = UPIO_MEM; in asc_init_port()
725 port->flags = UPF_BOOT_AUTOCONF; in asc_init_port()
726 port->ops = &asc_uart_ops; in asc_init_port()
727 port->fifosize = ASC_FIFO_SIZE; in asc_init_port()
728 port->dev = &pdev->dev; in asc_init_port()
729 port->irq = platform_get_irq(pdev, 0); in asc_init_port()
730 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ST_ASC_CONSOLE); in asc_init_port()
733 port->membase = devm_ioremap_resource(&pdev->dev, res); in asc_init_port()
734 if (IS_ERR(port->membase)) in asc_init_port()
735 return PTR_ERR(port->membase); in asc_init_port()
736 port->mapbase = res->start; in asc_init_port()
738 spin_lock_init(&port->lock); in asc_init_port()
746 ascport->port.uartclk = clk_get_rate(ascport->clk); in asc_init_port()
747 WARN_ON(ascport->port.uartclk == 0); in asc_init_port()
796 asc_ports[id].port.line = id; in asc_of_get_asc_port()
824 ret = uart_add_one_port(&asc_uart_driver, &ascport->port); in asc_serial_probe()
828 platform_set_drvdata(pdev, &ascport->port); in asc_serial_probe()
835 struct uart_port *port = platform_get_drvdata(pdev); in asc_serial_remove() local
837 return uart_remove_one_port(&asc_uart_driver, port); in asc_serial_remove()
843 struct uart_port *port = dev_get_drvdata(dev); in asc_serial_suspend() local
845 return uart_suspend_port(&asc_uart_driver, port); in asc_serial_suspend()
850 struct uart_port *port = dev_get_drvdata(dev); in asc_serial_resume() local
852 return uart_resume_port(&asc_uart_driver, port); in asc_serial_resume()
860 static void asc_console_putchar(struct uart_port *port, unsigned char ch) in asc_console_putchar() argument
865 while (--timeout && !asc_txfifo_is_half_empty(port)) in asc_console_putchar()
868 asc_out(port, ASC_TXBUF, ch); in asc_console_putchar()
878 struct uart_port *port = &asc_ports[co->index].port; in asc_console_write() local
884 if (port->sysrq) in asc_console_write()
887 locked = spin_trylock_irqsave(&port->lock, flags); in asc_console_write()
889 spin_lock_irqsave(&port->lock, flags); in asc_console_write()
895 intenable = asc_in(port, ASC_INTEN); in asc_console_write()
896 asc_out(port, ASC_INTEN, 0); in asc_console_write()
897 (void)asc_in(port, ASC_INTEN); /* Defeat bus write posting */ in asc_console_write()
899 uart_console_write(port, s, count, asc_console_putchar); in asc_console_write()
901 while (--timeout && !asc_txfifo_is_empty(port)) in asc_console_write()
904 asc_out(port, ASC_INTEN, intenable); in asc_console_write()
907 spin_unlock_irqrestore(&port->lock, flags); in asc_console_write()
929 if (ascport->port.mapbase == 0 || ascport->port.membase == NULL) in asc_console_setup()
935 return uart_set_options(&ascport->port, co, baud, parity, bits, flow); in asc_console_setup()