Lines Matching refs:port

40 	struct uart_port port;  member
147 static inline struct asc_port *to_asc_port(struct uart_port *port) in to_asc_port() argument
149 return container_of(port, struct asc_port, port); in to_asc_port()
152 static inline u32 asc_in(struct uart_port *port, u32 offset) in asc_in() argument
155 return readl_relaxed(port->membase + offset); in asc_in()
157 return readl(port->membase + offset); in asc_in()
161 static inline void asc_out(struct uart_port *port, u32 offset, u32 value) in asc_out() argument
164 writel_relaxed(value, port->membase + offset); in asc_out()
166 writel(value, port->membase + offset); in asc_out()
174 static inline void asc_disable_tx_interrupts(struct uart_port *port) in asc_disable_tx_interrupts() argument
176 u32 intenable = asc_in(port, ASC_INTEN) & ~ASC_INTEN_THE; in asc_disable_tx_interrupts()
177 asc_out(port, ASC_INTEN, intenable); in asc_disable_tx_interrupts()
178 (void)asc_in(port, ASC_INTEN); /* Defeat bus write posting */ in asc_disable_tx_interrupts()
181 static inline void asc_enable_tx_interrupts(struct uart_port *port) in asc_enable_tx_interrupts() argument
183 u32 intenable = asc_in(port, ASC_INTEN) | ASC_INTEN_THE; in asc_enable_tx_interrupts()
184 asc_out(port, ASC_INTEN, intenable); in asc_enable_tx_interrupts()
187 static inline void asc_disable_rx_interrupts(struct uart_port *port) in asc_disable_rx_interrupts() argument
189 u32 intenable = asc_in(port, ASC_INTEN) & ~ASC_INTEN_RBE; in asc_disable_rx_interrupts()
190 asc_out(port, ASC_INTEN, intenable); in asc_disable_rx_interrupts()
191 (void)asc_in(port, ASC_INTEN); /* Defeat bus write posting */ in asc_disable_rx_interrupts()
194 static inline void asc_enable_rx_interrupts(struct uart_port *port) in asc_enable_rx_interrupts() argument
196 u32 intenable = asc_in(port, ASC_INTEN) | ASC_INTEN_RBE; in asc_enable_rx_interrupts()
197 asc_out(port, ASC_INTEN, intenable); in asc_enable_rx_interrupts()
200 static inline u32 asc_txfifo_is_empty(struct uart_port *port) in asc_txfifo_is_empty() argument
202 return asc_in(port, ASC_STA) & ASC_STA_TE; in asc_txfifo_is_empty()
205 static inline u32 asc_txfifo_is_half_empty(struct uart_port *port) in asc_txfifo_is_half_empty() argument
207 return asc_in(port, ASC_STA) & ASC_STA_THE; in asc_txfifo_is_half_empty()
210 static inline const char *asc_port_name(struct uart_port *port) in asc_port_name() argument
212 return to_platform_device(port->dev)->name; in asc_port_name()
222 static inline unsigned asc_hw_txroom(struct uart_port *port) in asc_hw_txroom() argument
224 u32 status = asc_in(port, ASC_STA); in asc_hw_txroom()
227 return port->fifosize / 2; in asc_hw_txroom()
239 static void asc_transmit_chars(struct uart_port *port) in asc_transmit_chars() argument
241 struct circ_buf *xmit = &port->state->xmit; in asc_transmit_chars()
245 txroom = asc_hw_txroom(port); in asc_transmit_chars()
247 if ((txroom != 0) && port->x_char) { in asc_transmit_chars()
248 c = port->x_char; in asc_transmit_chars()
249 port->x_char = 0; in asc_transmit_chars()
250 asc_out(port, ASC_TXBUF, c); in asc_transmit_chars()
251 port->icount.tx++; in asc_transmit_chars()
252 txroom = asc_hw_txroom(port); in asc_transmit_chars()
255 if (uart_tx_stopped(port)) { in asc_transmit_chars()
260 asc_disable_tx_interrupts(port); in asc_transmit_chars()
265 asc_disable_tx_interrupts(port); in asc_transmit_chars()
275 asc_out(port, ASC_TXBUF, c); in asc_transmit_chars()
276 port->icount.tx++; in asc_transmit_chars()
281 uart_write_wakeup(port); in asc_transmit_chars()
284 asc_disable_tx_interrupts(port); in asc_transmit_chars()
287 static void asc_receive_chars(struct uart_port *port) in asc_receive_chars() argument
289 struct tty_port *tport = &port->state->port; in asc_receive_chars()
294 if (port->irq_wake) in asc_receive_chars()
297 while ((status = asc_in(port, ASC_STA)) & ASC_STA_RBF) { in asc_receive_chars()
298 c = asc_in(port, ASC_RXBUF) | ASC_RXBUF_DUMMY_RX; in asc_receive_chars()
300 port->icount.rx++; in asc_receive_chars()
307 port->icount.brk++; in asc_receive_chars()
308 if (uart_handle_break(port)) in asc_receive_chars()
312 port->icount.frame++; in asc_receive_chars()
315 port->icount.parity++; in asc_receive_chars()
322 port->icount.overrun++; in asc_receive_chars()
326 c &= port->read_status_mask; in asc_receive_chars()
336 if (uart_handle_sysrq_char(port, c & 0xff)) in asc_receive_chars()
339 uart_insert_char(port, c, ASC_RXBUF_DUMMY_OE, c & 0xff, flag); in asc_receive_chars()
348 struct uart_port *port = ptr; in asc_interrupt() local
351 spin_lock(&port->lock); in asc_interrupt()
353 status = asc_in(port, ASC_STA); in asc_interrupt()
357 asc_receive_chars(port); in asc_interrupt()
361 (asc_in(port, ASC_INTEN) & ASC_INTEN_THE)) { in asc_interrupt()
363 asc_transmit_chars(port); in asc_interrupt()
366 spin_unlock(&port->lock); in asc_interrupt()
377 static unsigned int asc_tx_empty(struct uart_port *port) in asc_tx_empty() argument
379 return asc_txfifo_is_empty(port) ? TIOCSER_TEMT : 0; in asc_tx_empty()
382 static void asc_set_mctrl(struct uart_port *port, unsigned int mctrl) in asc_set_mctrl() argument
392 static unsigned int asc_get_mctrl(struct uart_port *port) in asc_get_mctrl() argument
402 static void asc_start_tx(struct uart_port *port) in asc_start_tx() argument
404 struct circ_buf *xmit = &port->state->xmit; in asc_start_tx()
407 asc_enable_tx_interrupts(port); in asc_start_tx()
411 static void asc_stop_tx(struct uart_port *port) in asc_stop_tx() argument
413 asc_disable_tx_interrupts(port); in asc_stop_tx()
417 static void asc_stop_rx(struct uart_port *port) in asc_stop_rx() argument
419 asc_disable_rx_interrupts(port); in asc_stop_rx()
423 static void asc_break_ctl(struct uart_port *port, int break_state) in asc_break_ctl() argument
431 static int asc_startup(struct uart_port *port) in asc_startup() argument
433 if (request_irq(port->irq, asc_interrupt, IRQF_NO_SUSPEND, in asc_startup()
434 asc_port_name(port), port)) { in asc_startup()
435 dev_err(port->dev, "cannot allocate irq.\n"); in asc_startup()
439 asc_transmit_chars(port); in asc_startup()
440 asc_enable_rx_interrupts(port); in asc_startup()
445 static void asc_shutdown(struct uart_port *port) in asc_shutdown() argument
447 asc_disable_tx_interrupts(port); in asc_shutdown()
448 asc_disable_rx_interrupts(port); in asc_shutdown()
449 free_irq(port->irq, port); in asc_shutdown()
452 static void asc_pm(struct uart_port *port, unsigned int state, in asc_pm() argument
455 struct asc_port *ascport = to_asc_port(port); in asc_pm()
469 spin_lock_irqsave(&port->lock, flags); in asc_pm()
470 ctl = asc_in(port, ASC_CTL) & ~ASC_CTL_RUN; in asc_pm()
471 asc_out(port, ASC_CTL, ctl); in asc_pm()
472 spin_unlock_irqrestore(&port->lock, flags); in asc_pm()
478 static void asc_set_termios(struct uart_port *port, struct ktermios *termios, in asc_set_termios() argument
481 struct asc_port *ascport = to_asc_port(port); in asc_set_termios()
491 port->uartclk = clk_get_rate(ascport->clk); in asc_set_termios()
493 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); in asc_set_termios()
496 spin_lock_irqsave(&port->lock, flags); in asc_set_termios()
499 ctrl_val = asc_in(port, ASC_CTL); in asc_set_termios()
502 asc_out(port, ASC_CTL, (ctrl_val & ~ASC_CTL_RUN)); in asc_set_termios()
506 asc_out(port, ASC_TXRESET, 1); in asc_set_termios()
507 asc_out(port, ASC_RXRESET, 1); in asc_set_termios()
529 asc_out(port, ASC_BAUDRATE, (port->uartclk / (16 * baud))); in asc_set_termios()
542 do_div(dividend, port->uartclk / 16); in asc_set_termios()
543 asc_out(port, ASC_BAUDRATE, dividend); in asc_set_termios()
547 uart_update_timeout(port, cflag, baud); in asc_set_termios()
549 ascport->port.read_status_mask = ASC_RXBUF_DUMMY_OE; in asc_set_termios()
551 ascport->port.read_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE; in asc_set_termios()
553 ascport->port.read_status_mask |= ASC_RXBUF_DUMMY_BE; in asc_set_termios()
558 ascport->port.ignore_status_mask = 0; in asc_set_termios()
560 ascport->port.ignore_status_mask |= ASC_RXBUF_FE | ASC_RXBUF_PE; in asc_set_termios()
562 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_BE; in asc_set_termios()
568 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_OE; in asc_set_termios()
575 ascport->port.ignore_status_mask |= ASC_RXBUF_DUMMY_RX; in asc_set_termios()
578 asc_out(port, ASC_TIMEOUT, 20); in asc_set_termios()
581 asc_out(port, ASC_CTL, (ctrl_val | ASC_CTL_RUN)); in asc_set_termios()
583 spin_unlock_irqrestore(&port->lock, flags); in asc_set_termios()
586 static const char *asc_type(struct uart_port *port) in asc_type() argument
588 return (port->type == PORT_ASC) ? DRIVER_NAME : NULL; in asc_type()
591 static void asc_release_port(struct uart_port *port) in asc_release_port() argument
595 static int asc_request_port(struct uart_port *port) in asc_request_port() argument
604 static void asc_config_port(struct uart_port *port, int flags) in asc_config_port() argument
607 port->type = PORT_ASC; in asc_config_port()
611 asc_verify_port(struct uart_port *port, struct serial_struct *ser) in asc_verify_port() argument
623 static int asc_get_poll_char(struct uart_port *port) in asc_get_poll_char() argument
625 if (!(asc_in(port, ASC_STA) & ASC_STA_RBF)) in asc_get_poll_char()
628 return asc_in(port, ASC_RXBUF); in asc_get_poll_char()
631 static void asc_put_poll_char(struct uart_port *port, unsigned char c) in asc_put_poll_char() argument
633 while (!asc_txfifo_is_half_empty(port)) in asc_put_poll_char()
635 asc_out(port, ASC_TXBUF, c); in asc_put_poll_char()
668 struct uart_port *port = &ascport->port; in asc_init_port() local
671 port->iotype = UPIO_MEM; in asc_init_port()
672 port->flags = UPF_BOOT_AUTOCONF; in asc_init_port()
673 port->ops = &asc_uart_ops; in asc_init_port()
674 port->fifosize = ASC_FIFO_SIZE; in asc_init_port()
675 port->dev = &pdev->dev; in asc_init_port()
676 port->irq = platform_get_irq(pdev, 0); in asc_init_port()
679 port->membase = devm_ioremap_resource(&pdev->dev, res); in asc_init_port()
680 if (IS_ERR(port->membase)) in asc_init_port()
681 return PTR_ERR(port->membase); in asc_init_port()
682 port->mapbase = res->start; in asc_init_port()
684 spin_lock_init(&port->lock); in asc_init_port()
692 ascport->port.uartclk = clk_get_rate(ascport->clk); in asc_init_port()
693 WARN_ON(ascport->port.uartclk == 0); in asc_init_port()
718 asc_ports[id].port.line = id; in asc_of_get_asc_port()
744 ret = uart_add_one_port(&asc_uart_driver, &ascport->port); in asc_serial_probe()
748 platform_set_drvdata(pdev, &ascport->port); in asc_serial_probe()
755 struct uart_port *port = platform_get_drvdata(pdev); in asc_serial_remove() local
757 return uart_remove_one_port(&asc_uart_driver, port); in asc_serial_remove()
764 struct uart_port *port = platform_get_drvdata(pdev); in asc_serial_suspend() local
766 return uart_suspend_port(&asc_uart_driver, port); in asc_serial_suspend()
772 struct uart_port *port = platform_get_drvdata(pdev); in asc_serial_resume() local
774 return uart_resume_port(&asc_uart_driver, port); in asc_serial_resume()
782 static void asc_console_putchar(struct uart_port *port, int ch) in asc_console_putchar() argument
787 while (--timeout && !asc_txfifo_is_half_empty(port)) in asc_console_putchar()
790 asc_out(port, ASC_TXBUF, ch); in asc_console_putchar()
800 struct uart_port *port = &asc_ports[co->index].port; in asc_console_write() local
807 if (port->sysrq) in asc_console_write()
810 locked = spin_trylock(&port->lock); in asc_console_write()
812 spin_lock(&port->lock); in asc_console_write()
818 intenable = asc_in(port, ASC_INTEN); in asc_console_write()
819 asc_out(port, ASC_INTEN, 0); in asc_console_write()
820 (void)asc_in(port, ASC_INTEN); /* Defeat bus write posting */ in asc_console_write()
822 uart_console_write(port, s, count, asc_console_putchar); in asc_console_write()
824 while (--timeout && !asc_txfifo_is_empty(port)) in asc_console_write()
827 asc_out(port, ASC_INTEN, intenable); in asc_console_write()
830 spin_unlock(&port->lock); in asc_console_write()
853 if (ascport->port.mapbase == 0 || ascport->port.membase == NULL) in asc_console_setup()
859 return uart_set_options(&ascport->port, co, baud, parity, bits, flow); in asc_console_setup()