Lines Matching refs:port

60 static void uart_port_shutdown(struct tty_port *port);
71 void uart_write_wakeup(struct uart_port *port) in uart_write_wakeup() argument
73 struct uart_state *state = port->state; in uart_write_wakeup()
79 tty_wakeup(state->port.tty); in uart_write_wakeup()
85 struct uart_port *port = state->uart_port; in uart_stop() local
88 spin_lock_irqsave(&port->lock, flags); in uart_stop()
89 port->ops->stop_tx(port); in uart_stop()
90 spin_unlock_irqrestore(&port->lock, flags); in uart_stop()
96 struct uart_port *port = state->uart_port; in __uart_start() local
98 if (!uart_tx_stopped(port)) in __uart_start()
99 port->ops->start_tx(port); in __uart_start()
105 struct uart_port *port = state->uart_port; in uart_start() local
108 spin_lock_irqsave(&port->lock, flags); in uart_start()
110 spin_unlock_irqrestore(&port->lock, flags); in uart_start()
114 uart_update_mctrl(struct uart_port *port, unsigned int set, unsigned int clear) in uart_update_mctrl() argument
119 spin_lock_irqsave(&port->lock, flags); in uart_update_mctrl()
120 old = port->mctrl; in uart_update_mctrl()
121 port->mctrl = (old & ~clear) | set; in uart_update_mctrl()
122 if (old != port->mctrl) in uart_update_mctrl()
123 port->ops->set_mctrl(port, port->mctrl); in uart_update_mctrl()
124 spin_unlock_irqrestore(&port->lock, flags); in uart_update_mctrl()
127 #define uart_set_mctrl(port, set) uart_update_mctrl(port, set, 0) argument
128 #define uart_clear_mctrl(port, clear) uart_update_mctrl(port, 0, clear) argument
198 struct tty_port *port = &state->port; in uart_startup() local
201 if (port->flags & ASYNC_INITIALIZED) in uart_startup()
212 set_bit(ASYNCB_INITIALIZED, &port->flags); in uart_startup()
228 struct tty_port *port = &state->port; in uart_shutdown() local
236 if (test_and_clear_bit(ASYNCB_INITIALIZED, &port->flags)) { in uart_shutdown()
246 uart_port_shutdown(port); in uart_shutdown()
254 clear_bit(ASYNCB_SUSPENDED, &port->flags); in uart_shutdown()
275 uart_update_timeout(struct uart_port *port, unsigned int cflag, in uart_update_timeout() argument
304 bits = bits * port->fifosize; in uart_update_timeout()
310 port->timeout = (HZ * bits) / baud + HZ/50; in uart_update_timeout()
335 uart_get_baud_rate(struct uart_port *port, struct ktermios *termios, in uart_get_baud_rate() argument
340 upf_t flags = port->flags & UPF_SPD_MASK; in uart_get_baud_rate()
414 uart_get_divisor(struct uart_port *port, unsigned int baud) in uart_get_divisor() argument
421 if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST) in uart_get_divisor()
422 quot = port->custom_divisor; in uart_get_divisor()
424 quot = DIV_ROUND_CLOSEST(port->uartclk, 16 * baud); in uart_get_divisor()
477 static inline int __uart_put_char(struct uart_port *port, in __uart_put_char() argument
486 spin_lock_irqsave(&port->lock, flags); in __uart_put_char()
492 spin_unlock_irqrestore(&port->lock, flags); in __uart_put_char()
512 struct uart_port *port; in uart_write() local
526 port = state->uart_port; in uart_write()
532 spin_lock_irqsave(&port->lock, flags); in uart_write()
547 spin_unlock_irqrestore(&port->lock, flags); in uart_write()
579 struct uart_port *port; in uart_flush_buffer() local
591 port = state->uart_port; in uart_flush_buffer()
594 spin_lock_irqsave(&port->lock, flags); in uart_flush_buffer()
596 if (port->ops->flush_buffer) in uart_flush_buffer()
597 port->ops->flush_buffer(port); in uart_flush_buffer()
598 spin_unlock_irqrestore(&port->lock, flags); in uart_flush_buffer()
609 struct uart_port *port = state->uart_port; in uart_send_xchar() local
612 if (port->ops->send_xchar) in uart_send_xchar()
613 port->ops->send_xchar(port, ch); in uart_send_xchar()
615 spin_lock_irqsave(&port->lock, flags); in uart_send_xchar()
616 port->x_char = ch; in uart_send_xchar()
618 port->ops->start_tx(port); in uart_send_xchar()
619 spin_unlock_irqrestore(&port->lock, flags); in uart_send_xchar()
626 struct uart_port *port = state->uart_port; in uart_throttle() local
634 if (port->status & mask) { in uart_throttle()
635 port->ops->throttle(port); in uart_throttle()
636 mask &= ~port->status; in uart_throttle()
643 uart_clear_mctrl(port, TIOCM_RTS); in uart_throttle()
649 struct uart_port *port = state->uart_port; in uart_unthrottle() local
657 if (port->status & mask) { in uart_unthrottle()
658 port->ops->unthrottle(port); in uart_unthrottle()
659 mask &= ~port->status; in uart_unthrottle()
666 uart_set_mctrl(port, TIOCM_RTS); in uart_unthrottle()
669 static void do_uart_get_info(struct tty_port *port, in do_uart_get_info() argument
672 struct uart_state *state = container_of(port, struct uart_state, port); in do_uart_get_info()
679 retinfo->port = uport->iobase; in do_uart_get_info()
686 retinfo->close_delay = jiffies_to_msecs(port->close_delay) / 10; in do_uart_get_info()
687 retinfo->closing_wait = port->closing_wait == ASYNC_CLOSING_WAIT_NONE ? in do_uart_get_info()
689 jiffies_to_msecs(port->closing_wait) / 10; in do_uart_get_info()
697 static void uart_get_info(struct tty_port *port, in uart_get_info() argument
702 mutex_lock(&port->mutex); in uart_get_info()
703 do_uart_get_info(port, retinfo); in uart_get_info()
704 mutex_unlock(&port->mutex); in uart_get_info()
707 static int uart_get_info_user(struct tty_port *port, in uart_get_info_user() argument
711 uart_get_info(port, &tmp); in uart_get_info_user()
718 static int uart_set_info(struct tty_struct *tty, struct tty_port *port, in uart_set_info() argument
729 new_port = new_info->port; in uart_set_info()
764 (close_delay != port->close_delay) || in uart_set_info()
765 (closing_wait != port->closing_wait) || in uart_set_info()
795 if (tty_port_users(port) > 1) in uart_set_info()
878 port->close_delay = close_delay; in uart_set_info()
879 port->closing_wait = closing_wait; in uart_set_info()
882 port->low_latency = (uport->flags & UPF_LOW_LATENCY) ? 1 : 0; in uart_set_info()
888 if (port->flags & ASYNC_INITIALIZED) { in uart_set_info()
902 tty_name(port->tty, buf)); in uart_set_info()
916 struct tty_port *port = &state->port; in uart_set_info_user() local
929 mutex_lock(&port->mutex); in uart_set_info_user()
930 retval = uart_set_info(tty, port, state, &new_serial); in uart_set_info_user()
931 mutex_unlock(&port->mutex); in uart_set_info_user()
968 struct tty_port *port = &state->port; in uart_tiocmget() local
972 mutex_lock(&port->mutex); in uart_tiocmget()
979 mutex_unlock(&port->mutex); in uart_tiocmget()
989 struct tty_port *port = &state->port; in uart_tiocmset() local
992 mutex_lock(&port->mutex); in uart_tiocmset()
997 mutex_unlock(&port->mutex); in uart_tiocmset()
1004 struct tty_port *port = &state->port; in uart_break_ctl() local
1007 mutex_lock(&port->mutex); in uart_break_ctl()
1012 mutex_unlock(&port->mutex); in uart_break_ctl()
1019 struct tty_port *port = &state->port; in uart_do_autoconfig() local
1030 if (mutex_lock_interruptible(&port->mutex)) in uart_do_autoconfig()
1034 if (tty_port_users(port) == 1) { in uart_do_autoconfig()
1056 mutex_unlock(&port->mutex); in uart_do_autoconfig()
1082 struct tty_port *port = &state->port; in uart_wait_modem_status() local
1095 add_wait_queue(&port->delta_msr_wait, &wait); in uart_wait_modem_status()
1122 remove_wait_queue(&port->delta_msr_wait, &wait); in uart_wait_modem_status()
1159 static int uart_get_rs485_config(struct uart_port *port, in uart_get_rs485_config() argument
1165 spin_lock_irqsave(&port->lock, flags); in uart_get_rs485_config()
1166 aux = port->rs485; in uart_get_rs485_config()
1167 spin_unlock_irqrestore(&port->lock, flags); in uart_get_rs485_config()
1175 static int uart_set_rs485_config(struct uart_port *port, in uart_set_rs485_config() argument
1182 if (!port->rs485_config) in uart_set_rs485_config()
1188 spin_lock_irqsave(&port->lock, flags); in uart_set_rs485_config()
1189 ret = port->rs485_config(port, &rs485); in uart_set_rs485_config()
1190 spin_unlock_irqrestore(&port->lock, flags); in uart_set_rs485_config()
1194 if (copy_to_user(rs485_user, &port->rs485, sizeof(port->rs485))) in uart_set_rs485_config()
1208 struct tty_port *port = &state->port; in uart_ioctl() local
1218 ret = uart_get_info_user(port, uarg); in uart_ioctl()
1259 mutex_lock(&port->mutex); in uart_ioctl()
1291 mutex_unlock(&port->mutex); in uart_ioctl()
1302 mutex_lock(&state->port.mutex); in uart_set_ldisc()
1304 mutex_unlock(&state->port.mutex); in uart_set_ldisc()
1342 mutex_lock(&state->port.mutex); in uart_set_termios()
1344 mutex_unlock(&state->port.mutex); in uart_set_termios()
1369 struct tty_port *port; in uart_close() local
1377 port = &state->port; in uart_close()
1378 spin_lock_irq(&port->lock); in uart_close()
1379 --port->count; in uart_close()
1380 spin_unlock_irq(&port->lock); in uart_close()
1385 port = &state->port; in uart_close()
1389 if (!port->count || tty_port_close_start(port, tty, filp) == 0) in uart_close()
1396 if (port->flags & ASYNC_INITIALIZED) { in uart_close()
1409 mutex_lock(&port->mutex); in uart_close()
1411 tty_port_tty_set(port, NULL); in uart_close()
1413 spin_lock_irqsave(&port->lock, flags); in uart_close()
1415 if (port->blocked_open) { in uart_close()
1416 spin_unlock_irqrestore(&port->lock, flags); in uart_close()
1417 if (port->close_delay) in uart_close()
1418 msleep_interruptible(jiffies_to_msecs(port->close_delay)); in uart_close()
1419 spin_lock_irqsave(&port->lock, flags); in uart_close()
1421 spin_unlock_irqrestore(&port->lock, flags); in uart_close()
1423 spin_lock_irqsave(&port->lock, flags); in uart_close()
1429 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags); in uart_close()
1430 clear_bit(ASYNCB_CLOSING, &port->flags); in uart_close()
1431 spin_unlock_irqrestore(&port->lock, flags); in uart_close()
1432 wake_up_interruptible(&port->open_wait); in uart_close()
1433 wake_up_interruptible(&port->close_wait); in uart_close()
1435 mutex_unlock(&port->mutex); in uart_close()
1444 struct uart_port *port = state->uart_port; in uart_wait_until_sent() local
1447 if (port->type == PORT_UNKNOWN || port->fifosize == 0) in uart_wait_until_sent()
1458 char_time = (port->timeout - HZ/50) / port->fifosize; in uart_wait_until_sent()
1474 if (timeout == 0 || timeout > 2 * port->timeout) in uart_wait_until_sent()
1475 timeout = 2 * port->timeout; in uart_wait_until_sent()
1480 port->line, jiffies, expire); in uart_wait_until_sent()
1487 while (!port->ops->tx_empty(port)) { in uart_wait_until_sent()
1504 struct tty_port *port = &state->port; in uart_hangup() local
1509 mutex_lock(&port->mutex); in uart_hangup()
1510 if (port->flags & ASYNC_NORMAL_ACTIVE) { in uart_hangup()
1513 spin_lock_irqsave(&port->lock, flags); in uart_hangup()
1514 port->count = 0; in uart_hangup()
1515 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags); in uart_hangup()
1516 spin_unlock_irqrestore(&port->lock, flags); in uart_hangup()
1517 tty_port_tty_set(port, NULL); in uart_hangup()
1520 wake_up_interruptible(&port->open_wait); in uart_hangup()
1521 wake_up_interruptible(&port->delta_msr_wait); in uart_hangup()
1523 mutex_unlock(&port->mutex); in uart_hangup()
1526 static int uart_port_activate(struct tty_port *port, struct tty_struct *tty) in uart_port_activate() argument
1531 static void uart_port_shutdown(struct tty_port *port) in uart_port_shutdown() argument
1533 struct uart_state *state = container_of(port, struct uart_state, port); in uart_port_shutdown()
1543 wake_up_interruptible(&port->delta_msr_wait); in uart_port_shutdown()
1556 static int uart_carrier_raised(struct tty_port *port) in uart_carrier_raised() argument
1558 struct uart_state *state = container_of(port, struct uart_state, port); in uart_carrier_raised()
1570 static void uart_dtr_rts(struct tty_port *port, int onoff) in uart_dtr_rts() argument
1572 struct uart_state *state = container_of(port, struct uart_state, port); in uart_dtr_rts()
1596 struct tty_port *port = &state->port; in uart_open() local
1600 spin_lock_irq(&port->lock); in uart_open()
1601 ++port->count; in uart_open()
1602 spin_unlock_irq(&port->lock); in uart_open()
1611 if (mutex_lock_interruptible(&port->mutex)) { in uart_open()
1623 state->port.low_latency = in uart_open()
1625 tty_port_tty_set(port, tty); in uart_open()
1635 mutex_unlock(&port->mutex); in uart_open()
1637 retval = tty_port_block_til_ready(port, tty, filp); in uart_open()
1642 mutex_unlock(&port->mutex); in uart_open()
1646 static const char *uart_type(struct uart_port *port) in uart_type() argument
1650 if (port->ops->type) in uart_type()
1651 str = port->ops->type(port); in uart_type()
1664 struct tty_port *port = &state->port; in uart_line_info() local
1688 mutex_lock(&port->mutex); in uart_line_info()
1697 mutex_unlock(&port->mutex); in uart_line_info()
1776 void uart_console_write(struct uart_port *port, const char *s, in uart_console_write() argument
1784 putchar(port, '\r'); in uart_console_write()
1785 putchar(port, *s); in uart_console_write()
1917 uart_set_options(struct uart_port *port, struct console *co, in uart_set_options() argument
1930 if (!(uart_console(port) && (port->cons->flags & CON_ENABLED))) { in uart_set_options()
1931 spin_lock_init(&port->lock); in uart_set_options()
1932 lockdep_set_class(&port->lock, &port_lock_key); in uart_set_options()
1969 port->mctrl |= TIOCM_DTR; in uart_set_options()
1971 port->ops->set_termios(port, &termios, &dummy); in uart_set_options()
1995 struct uart_port *port = state->uart_port; in uart_change_pm() local
1998 if (port->ops->pm) in uart_change_pm()
1999 port->ops->pm(port, pm_state, state->pm_state); in uart_change_pm()
2005 struct uart_port *port; member
2014 match->port->line; in serial_match_port()
2022 struct tty_port *port = &state->port; in uart_suspend_port() local
2026 mutex_lock(&port->mutex); in uart_suspend_port()
2033 mutex_unlock(&port->mutex); in uart_suspend_port()
2044 if (port->flags & ASYNC_INITIALIZED) { in uart_suspend_port()
2048 set_bit(ASYNCB_SUSPENDED, &port->flags); in uart_suspend_port()
2049 clear_bit(ASYNCB_INITIALIZED, &port->flags); in uart_suspend_port()
2078 mutex_unlock(&port->mutex); in uart_suspend_port()
2086 struct tty_port *port = &state->port; in uart_resume_port() local
2091 mutex_lock(&port->mutex); in uart_resume_port()
2100 mutex_unlock(&port->mutex); in uart_resume_port()
2119 if (port->tty && termios.c_cflag == 0) in uart_resume_port()
2120 termios = port->tty->termios; in uart_resume_port()
2129 if (port->flags & ASYNC_SUSPENDED) { in uart_resume_port()
2139 struct tty_struct *tty = port->tty; in uart_resume_port()
2148 set_bit(ASYNCB_INITIALIZED, &port->flags); in uart_resume_port()
2159 clear_bit(ASYNCB_SUSPENDED, &port->flags); in uart_resume_port()
2162 mutex_unlock(&port->mutex); in uart_resume_port()
2168 uart_report_port(struct uart_driver *drv, struct uart_port *port) in uart_report_port() argument
2172 switch (port->iotype) { in uart_report_port()
2174 snprintf(address, sizeof(address), "I/O 0x%lx", port->iobase); in uart_report_port()
2178 "I/O 0x%lx offset 0x%x", port->iobase, port->hub6); in uart_report_port()
2186 "MMIO 0x%llx", (unsigned long long)port->mapbase); in uart_report_port()
2194 port->dev ? dev_name(port->dev) : "", in uart_report_port()
2195 port->dev ? ": " : "", in uart_report_port()
2197 drv->tty_driver->name_base + port->line, in uart_report_port()
2198 address, port->irq, port->uartclk / 16, uart_type(port)); in uart_report_port()
2203 struct uart_port *port) in uart_configure_port() argument
2210 if (!port->iobase && !port->mapbase && !port->membase) in uart_configure_port()
2218 if (port->flags & UPF_AUTO_IRQ) in uart_configure_port()
2220 if (port->flags & UPF_BOOT_AUTOCONF) { in uart_configure_port()
2221 if (!(port->flags & UPF_FIXED_TYPE)) { in uart_configure_port()
2222 port->type = PORT_UNKNOWN; in uart_configure_port()
2225 port->ops->config_port(port, flags); in uart_configure_port()
2228 if (port->type != PORT_UNKNOWN) { in uart_configure_port()
2231 uart_report_port(drv, port); in uart_configure_port()
2241 spin_lock_irqsave(&port->lock, flags); in uart_configure_port()
2242 port->ops->set_mctrl(port, port->mctrl & TIOCM_DTR); in uart_configure_port()
2243 spin_unlock_irqrestore(&port->lock, flags); in uart_configure_port()
2250 if (port->cons && !(port->cons->flags & CON_ENABLED)) in uart_configure_port()
2251 register_console(port->cons); in uart_configure_port()
2257 if (!uart_console(port)) in uart_configure_port()
2268 struct uart_port *port; in uart_poll_init() local
2278 port = state->uart_port; in uart_poll_init()
2279 if (!(port->ops->poll_get_char && port->ops->poll_put_char)) in uart_poll_init()
2282 if (port->ops->poll_init) { in uart_poll_init()
2283 struct tty_port *tport = &state->port; in uart_poll_init()
2292 ret = port->ops->poll_init(port); in uart_poll_init()
2300 return uart_set_options(port, NULL, baud, parity, bits, flow); in uart_poll_init()
2310 struct uart_port *port; in uart_poll_get_char() local
2315 port = state->uart_port; in uart_poll_get_char()
2316 return port->ops->poll_get_char(port); in uart_poll_get_char()
2323 struct uart_port *port; in uart_poll_put_char() local
2328 port = state->uart_port; in uart_poll_put_char()
2331 port->ops->poll_put_char(port, '\r'); in uart_poll_put_char()
2332 port->ops->poll_put_char(port, ch); in uart_poll_put_char()
2428 struct tty_port *port = &state->port; in uart_register_driver() local
2430 tty_port_init(port); in uart_register_driver()
2431 port->ops = &uart_port_ops; in uart_register_driver()
2439 tty_port_destroy(&drv->state[i].port); in uart_register_driver()
2464 tty_port_destroy(&drv->state[i].port); in uart_unregister_driver()
2481 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_uartclk() local
2483 uart_get_info(port, &tmp); in uart_get_attr_uartclk()
2491 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_type() local
2493 uart_get_info(port, &tmp); in uart_get_attr_type()
2500 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_line() local
2502 uart_get_info(port, &tmp); in uart_get_attr_line()
2510 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_port() local
2513 uart_get_info(port, &tmp); in uart_get_attr_port()
2514 ioaddr = tmp.port; in uart_get_attr_port()
2524 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_irq() local
2526 uart_get_info(port, &tmp); in uart_get_attr_irq()
2534 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_flags() local
2536 uart_get_info(port, &tmp); in uart_get_attr_flags()
2544 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_xmit_fifo_size() local
2546 uart_get_info(port, &tmp); in uart_get_attr_xmit_fifo_size()
2555 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_close_delay() local
2557 uart_get_info(port, &tmp); in uart_get_attr_close_delay()
2566 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_closing_wait() local
2568 uart_get_info(port, &tmp); in uart_get_attr_closing_wait()
2576 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_custom_divisor() local
2578 uart_get_info(port, &tmp); in uart_get_attr_custom_divisor()
2586 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_io_type() local
2588 uart_get_info(port, &tmp); in uart_get_attr_io_type()
2596 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_iomem_base() local
2598 uart_get_info(port, &tmp); in uart_get_attr_iomem_base()
2606 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_iomem_reg_shift() local
2608 uart_get_info(port, &tmp); in uart_get_attr_iomem_reg_shift()
2614 static DEVICE_ATTR(port, S_IRUSR | S_IRGRP, uart_get_attr_port, NULL);
2660 struct tty_port *port; in uart_add_one_port() local
2671 port = &state->port; in uart_add_one_port()
2674 mutex_lock(&port->mutex); in uart_add_one_port()
2719 tty_dev = tty_port_register_device_attr(port, drv->tty_driver, in uart_add_one_port()
2720 uport->line, uport->dev, port, uport->tty_groups); in uart_add_one_port()
2734 mutex_unlock(&port->mutex); in uart_add_one_port()
2752 struct tty_port *port = &state->port; in uart_remove_one_port() local
2768 mutex_lock(&port->mutex); in uart_remove_one_port()
2770 mutex_unlock(&port->mutex); in uart_remove_one_port()
2775 mutex_unlock(&port->mutex); in uart_remove_one_port()
2782 tty = tty_port_tty_get(port); in uart_remove_one_port()
2784 tty_vhangup(port->tty); in uart_remove_one_port()
2847 struct tty_port *port = &uport->state->port; in uart_handle_dcd_change() local
2848 struct tty_struct *tty = port->tty; in uart_handle_dcd_change()
2866 wake_up_interruptible(&port->open_wait); in uart_handle_dcd_change()
2916 void uart_insert_char(struct uart_port *port, unsigned int status, in uart_insert_char() argument
2919 struct tty_port *tport = &port->state->port; in uart_insert_char()
2921 if ((status & port->ignore_status_mask & ~overrun) == 0) in uart_insert_char()
2923 ++port->icount.buf_overrun; in uart_insert_char()
2929 if (status & ~port->ignore_status_mask & overrun) in uart_insert_char()
2931 ++port->icount.buf_overrun; in uart_insert_char()