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 spin_lock(&port->lock); 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 spin_unlock(&port->lock); 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 circ_buf *xmit = &port->state->xmit; 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 spin_lock_irqsave(&port->lock, 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 spin_unlock_irqrestore(&port->lock, 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()
478 port->uartclk = clk_get_rate(ascport->clk); in asc_set_termios()
480 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); in asc_set_termios()
483 spin_lock_irqsave(&port->lock, flags); in asc_set_termios()
486 ctrl_val = asc_in(port, ASC_CTL); in asc_set_termios()
489 asc_out(port, ASC_CTL, (ctrl_val & ~ASC_CTL_RUN)); in asc_set_termios()
493 asc_out(port, ASC_TXRESET, 1); in asc_set_termios()
494 asc_out(port, ASC_RXRESET, 1); in asc_set_termios()
521 devm_gpiod_put(port->dev, ascport->rts); in asc_set_termios()
533 gpiod = devm_gpiod_get(port->dev, "rts", GPIOD_OUT_LOW); in asc_set_termios()
536 port->dev->of_node->name); in asc_set_termios()
543 asc_out(port, ASC_BAUDRATE, (port->uartclk / (16 * baud))); in asc_set_termios()
556 do_div(dividend, port->uartclk / 16); in asc_set_termios()
557 asc_out(port, ASC_BAUDRATE, dividend); in asc_set_termios()
561 uart_update_timeout(port, cflag, baud); in asc_set_termios()
563 ascport->port.read_status_mask = ASC_RXBUF_DUMMY_OE; in asc_set_termios()
565 ascport->port.read_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE; in asc_set_termios()
567 ascport->port.read_status_mask |= ASC_RXBUF_DUMMY_BE; in asc_set_termios()
572 ascport->port.ignore_status_mask = 0; in asc_set_termios()
574 ascport->port.ignore_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE; in asc_set_termios()
576 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_BE; in asc_set_termios()
582 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_OE; in asc_set_termios()
589 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_RX; in asc_set_termios()
592 asc_out(port, ASC_TIMEOUT, 20); in asc_set_termios()
595 asc_out(port, ASC_CTL, (ctrl_val | ASC_CTL_RUN)); in asc_set_termios()
597 spin_unlock_irqrestore(&port->lock, flags); in asc_set_termios()
600 static const char *asc_type(struct uart_port *port) in asc_type() argument
602 return (port->type == PORT_ASC) ? DRIVER_NAME : NULL; in asc_type()
605 static void asc_release_port(struct uart_port *port) in asc_release_port() argument
609 static int asc_request_port(struct uart_port *port) in asc_request_port() argument
618 static void asc_config_port(struct uart_port *port, int flags) in asc_config_port() argument
621 port->type = PORT_ASC; in asc_config_port()
625 asc_verify_port(struct uart_port *port, struct serial_struct *ser) in asc_verify_port() argument
637 static int asc_get_poll_char(struct uart_port *port) in asc_get_poll_char() argument
639 if (!(asc_in(port, ASC_STA) & ASC_STA_RBF)) in asc_get_poll_char()
642 return asc_in(port, ASC_RXBUF); in asc_get_poll_char()
645 static void asc_put_poll_char(struct uart_port *port, unsigned char c) in asc_put_poll_char() argument
647 while (!asc_txfifo_is_half_empty(port)) in asc_put_poll_char()
649 asc_out(port, ASC_TXBUF, c); in asc_put_poll_char()
682 struct uart_port *port = &ascport->port; in asc_init_port() local
686 port->iotype = UPIO_MEM; in asc_init_port()
687 port->flags = UPF_BOOT_AUTOCONF; in asc_init_port()
688 port->ops = &asc_uart_ops; in asc_init_port()
689 port->fifosize = ASC_FIFO_SIZE; in asc_init_port()
690 port->dev = &pdev->dev; in asc_init_port()
691 port->irq = platform_get_irq(pdev, 0); in asc_init_port()
692 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ST_ASC_CONSOLE); in asc_init_port()
695 port->membase = devm_ioremap_resource(&pdev->dev, res); in asc_init_port()
696 if (IS_ERR(port->membase)) in asc_init_port()
697 return PTR_ERR(port->membase); in asc_init_port()
698 port->mapbase = res->start; in asc_init_port()
700 spin_lock_init(&port->lock); in asc_init_port()
708 ascport->port.uartclk = clk_get_rate(ascport->clk); in asc_init_port()
709 WARN_ON(ascport->port.uartclk == 0); in asc_init_port()
758 asc_ports[id].port.line = id; in asc_of_get_asc_port()
786 ret = uart_add_one_port(&asc_uart_driver, &ascport->port); in asc_serial_probe()
790 platform_set_drvdata(pdev, &ascport->port); in asc_serial_probe()
797 struct uart_port *port = platform_get_drvdata(pdev); in asc_serial_remove() local
799 return uart_remove_one_port(&asc_uart_driver, port); in asc_serial_remove()
805 struct uart_port *port = dev_get_drvdata(dev); in asc_serial_suspend() local
807 return uart_suspend_port(&asc_uart_driver, port); in asc_serial_suspend()
812 struct uart_port *port = dev_get_drvdata(dev); in asc_serial_resume() local
814 return uart_resume_port(&asc_uart_driver, port); in asc_serial_resume()
822 static void asc_console_putchar(struct uart_port *port, unsigned char ch) in asc_console_putchar() argument
827 while (--timeout && !asc_txfifo_is_half_empty(port)) in asc_console_putchar()
830 asc_out(port, ASC_TXBUF, ch); in asc_console_putchar()
840 struct uart_port *port = &asc_ports[co->index].port; in asc_console_write() local
846 if (port->sysrq) in asc_console_write()
849 locked = spin_trylock_irqsave(&port->lock, flags); in asc_console_write()
851 spin_lock_irqsave(&port->lock, flags); in asc_console_write()
857 intenable = asc_in(port, ASC_INTEN); in asc_console_write()
858 asc_out(port, ASC_INTEN, 0); in asc_console_write()
859 (void)asc_in(port, ASC_INTEN); /* Defeat bus write posting */ in asc_console_write()
861 uart_console_write(port, s, count, asc_console_putchar); in asc_console_write()
863 while (--timeout && !asc_txfifo_is_empty(port)) in asc_console_write()
866 asc_out(port, ASC_INTEN, intenable); in asc_console_write()
869 spin_unlock_irqrestore(&port->lock, flags); in asc_console_write()
891 if (ascport->port.mapbase == 0 || ascport->port.membase == NULL) in asc_console_setup()
897 return uart_set_options(&ascport->port, co, baud, parity, bits, flow); in asc_console_setup()