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
242 uart_port_tx_limited(port, ch, asc_hw_txroom(port), in asc_transmit_chars()
244 asc_out(port, ASC_TXBUF, ch), in asc_transmit_chars()
248 static void asc_receive_chars(struct uart_port *port) in asc_receive_chars() argument
250 struct tty_port *tport = &port->state->port; in asc_receive_chars()
261 mode = asc_in(port, ASC_CTL) & ASC_CTL_MODE_MSK; in asc_receive_chars()
265 if (irqd_is_wakeup_set(irq_get_irq_data(port->irq))) in asc_receive_chars()
268 while ((status = asc_in(port, ASC_STA)) & ASC_STA_RBF) { in asc_receive_chars()
269 c = asc_in(port, ASC_RXBUF) | ASC_RXBUF_DUMMY_RX; in asc_receive_chars()
271 port->icount.rx++; in asc_receive_chars()
278 port->icount.brk++; in asc_receive_chars()
279 if (uart_handle_break(port)) in asc_receive_chars()
283 port->icount.frame++; in asc_receive_chars()
286 port->icount.parity++; in asc_receive_chars()
293 port->icount.overrun++; in asc_receive_chars()
297 c &= port->read_status_mask; in asc_receive_chars()
307 if (uart_handle_sysrq_char(port, c & 0xff)) in asc_receive_chars()
310 uart_insert_char(port, c, ASC_RXBUF_DUMMY_OE, c & 0xff, flag); in asc_receive_chars()
319 struct uart_port *port = ptr; in asc_interrupt() local
322 uart_port_lock(port); in asc_interrupt()
324 status = asc_in(port, ASC_STA); in asc_interrupt()
328 asc_receive_chars(port); in asc_interrupt()
332 (asc_in(port, ASC_INTEN) & ASC_INTEN_THE)) { in asc_interrupt()
334 asc_transmit_chars(port); in asc_interrupt()
337 uart_port_unlock(port); in asc_interrupt()
348 static unsigned int asc_tx_empty(struct uart_port *port) in asc_tx_empty() argument
350 return asc_txfifo_is_empty(port) ? TIOCSER_TEMT : 0; in asc_tx_empty()
353 static void asc_set_mctrl(struct uart_port *port, unsigned int mctrl) in asc_set_mctrl() argument
355 struct asc_port *ascport = to_asc_port(port); in asc_set_mctrl()
372 if (asc_in(port, ASC_CTL) & ASC_CTL_CTSENABLE) in asc_set_mctrl()
378 static unsigned int asc_get_mctrl(struct uart_port *port) in asc_get_mctrl() argument
388 static void asc_start_tx(struct uart_port *port) in asc_start_tx() argument
390 struct tty_port *tport = &port->state->port; in asc_start_tx()
393 asc_enable_tx_interrupts(port); in asc_start_tx()
397 static void asc_stop_tx(struct uart_port *port) in asc_stop_tx() argument
399 asc_disable_tx_interrupts(port); in asc_stop_tx()
403 static void asc_stop_rx(struct uart_port *port) in asc_stop_rx() argument
405 asc_disable_rx_interrupts(port); in asc_stop_rx()
409 static void asc_break_ctl(struct uart_port *port, int break_state) in asc_break_ctl() argument
417 static int asc_startup(struct uart_port *port) in asc_startup() argument
419 if (request_irq(port->irq, asc_interrupt, 0, in asc_startup()
420 asc_port_name(port), port)) { in asc_startup()
421 dev_err(port->dev, "cannot allocate irq.\n"); in asc_startup()
425 asc_transmit_chars(port); in asc_startup()
426 asc_enable_rx_interrupts(port); in asc_startup()
431 static void asc_shutdown(struct uart_port *port) in asc_shutdown() argument
433 asc_disable_tx_interrupts(port); in asc_shutdown()
434 asc_disable_rx_interrupts(port); in asc_shutdown()
435 free_irq(port->irq, port); in asc_shutdown()
438 static void asc_pm(struct uart_port *port, unsigned int state, in asc_pm() argument
441 struct asc_port *ascport = to_asc_port(port); in asc_pm()
455 uart_port_lock_irqsave(port, &flags); in asc_pm()
456 ctl = asc_in(port, ASC_CTL) & ~ASC_CTL_RUN; in asc_pm()
457 asc_out(port, ASC_CTL, ctl); in asc_pm()
458 uart_port_unlock_irqrestore(port, flags); in asc_pm()
464 static void asc_set_termios(struct uart_port *port, struct ktermios *termios, in asc_set_termios() argument
467 struct asc_port *ascport = to_asc_port(port); in asc_set_termios()
479 port->uartclk = clk_get_rate(ascport->clk); in asc_set_termios()
481 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); in asc_set_termios()
484 uart_port_lock_irqsave(port, &flags); in asc_set_termios()
487 ctrl_val = asc_in(port, ASC_CTL); in asc_set_termios()
490 asc_out(port, ASC_CTL, (ctrl_val & ~ASC_CTL_RUN)); in asc_set_termios()
494 asc_out(port, ASC_TXRESET, 1); in asc_set_termios()
495 asc_out(port, ASC_RXRESET, 1); in asc_set_termios()
532 asc_out(port, ASC_BAUDRATE, (port->uartclk / (16 * baud))); in asc_set_termios()
545 do_div(dividend, port->uartclk / 16); in asc_set_termios()
546 asc_out(port, ASC_BAUDRATE, dividend); in asc_set_termios()
550 uart_update_timeout(port, cflag, baud); in asc_set_termios()
552 ascport->port.read_status_mask = ASC_RXBUF_DUMMY_OE; in asc_set_termios()
554 ascport->port.read_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE; in asc_set_termios()
556 ascport->port.read_status_mask |= ASC_RXBUF_DUMMY_BE; in asc_set_termios()
561 ascport->port.ignore_status_mask = 0; in asc_set_termios()
563 ascport->port.ignore_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE; in asc_set_termios()
565 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_BE; in asc_set_termios()
571 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_OE; in asc_set_termios()
578 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_RX; in asc_set_termios()
581 asc_out(port, ASC_TIMEOUT, 20); in asc_set_termios()
584 asc_out(port, ASC_CTL, (ctrl_val | ASC_CTL_RUN)); in asc_set_termios()
586 uart_port_unlock_irqrestore(port, flags); in asc_set_termios()
593 gpiod = devm_gpiod_get(port->dev, "rts", GPIOD_OUT_LOW); in asc_set_termios()
596 port->dev->of_node->name); in asc_set_termios()
600 devm_gpiod_put(port->dev, ascport->rts); in asc_set_termios()
608 static const char *asc_type(struct uart_port *port) in asc_type() argument
610 return (port->type == PORT_ASC) ? DRIVER_NAME : NULL; in asc_type()
613 static void asc_release_port(struct uart_port *port) in asc_release_port() argument
617 static int asc_request_port(struct uart_port *port) in asc_request_port() argument
626 static void asc_config_port(struct uart_port *port, int flags) in asc_config_port() argument
629 port->type = PORT_ASC; in asc_config_port()
633 asc_verify_port(struct uart_port *port, struct serial_struct *ser) in asc_verify_port() argument
645 static int asc_get_poll_char(struct uart_port *port) in asc_get_poll_char() argument
647 if (!(asc_in(port, ASC_STA) & ASC_STA_RBF)) in asc_get_poll_char()
650 return asc_in(port, ASC_RXBUF); in asc_get_poll_char()
653 static void asc_put_poll_char(struct uart_port *port, unsigned char c) in asc_put_poll_char() argument
655 while (!asc_txfifo_is_half_empty(port)) in asc_put_poll_char()
657 asc_out(port, ASC_TXBUF, c); in asc_put_poll_char()
690 struct uart_port *port = &ascport->port; in asc_init_port() local
694 port->iotype = UPIO_MEM; in asc_init_port()
695 port->flags = UPF_BOOT_AUTOCONF; in asc_init_port()
696 port->ops = &asc_uart_ops; in asc_init_port()
697 port->fifosize = ASC_FIFO_SIZE; in asc_init_port()
698 port->dev = &pdev->dev; in asc_init_port()
699 port->irq = platform_get_irq(pdev, 0); in asc_init_port()
700 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ST_ASC_CONSOLE); in asc_init_port()
702 port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in asc_init_port()
703 if (IS_ERR(port->membase)) in asc_init_port()
704 return PTR_ERR(port->membase); in asc_init_port()
705 port->mapbase = res->start; in asc_init_port()
707 spin_lock_init(&port->lock); in asc_init_port()
717 ascport->port.uartclk = clk_get_rate(ascport->clk); in asc_init_port()
718 WARN_ON(ascport->port.uartclk == 0); in asc_init_port()
767 asc_ports[id].port.line = id; in asc_of_get_asc_port()
795 ret = uart_add_one_port(&asc_uart_driver, &ascport->port); in asc_serial_probe()
799 platform_set_drvdata(pdev, &ascport->port); in asc_serial_probe()
806 struct uart_port *port = platform_get_drvdata(pdev); in asc_serial_remove() local
808 uart_remove_one_port(&asc_uart_driver, port); in asc_serial_remove()
813 struct uart_port *port = dev_get_drvdata(dev); in asc_serial_suspend() local
815 return uart_suspend_port(&asc_uart_driver, port); in asc_serial_suspend()
820 struct uart_port *port = dev_get_drvdata(dev); in asc_serial_resume() local
822 return uart_resume_port(&asc_uart_driver, port); in asc_serial_resume()
828 static void asc_console_putchar(struct uart_port *port, unsigned char ch) in asc_console_putchar() argument
833 while (--timeout && !asc_txfifo_is_half_empty(port)) in asc_console_putchar()
836 asc_out(port, ASC_TXBUF, ch); in asc_console_putchar()
846 struct uart_port *port = &asc_ports[co->index].port; in asc_console_write() local
852 if (port->sysrq) in asc_console_write()
855 locked = uart_port_trylock_irqsave(port, &flags); in asc_console_write()
857 uart_port_lock_irqsave(port, &flags); in asc_console_write()
863 intenable = asc_in(port, ASC_INTEN); in asc_console_write()
864 asc_out(port, ASC_INTEN, 0); in asc_console_write()
865 (void)asc_in(port, ASC_INTEN); /* Defeat bus write posting */ in asc_console_write()
867 uart_console_write(port, s, count, asc_console_putchar); in asc_console_write()
869 while (--timeout && !asc_txfifo_is_empty(port)) in asc_console_write()
872 asc_out(port, ASC_INTEN, intenable); in asc_console_write()
875 uart_port_unlock_irqrestore(port, flags); in asc_console_write()
897 if (ascport->port.mapbase == 0 || ascport->port.membase == NULL) in asc_console_setup()
903 return uart_set_options(&ascport->port, co, baud, parity, bits, flow); in asc_console_setup()