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
342 upf_t flags = port->flags & UPF_SPD_MASK; in uart_get_baud_rate()
425 uart_get_divisor(struct uart_port *port, unsigned int baud) in uart_get_divisor() argument
432 if (baud == 38400 && (port->flags & UPF_SPD_MASK) == UPF_SPD_CUST) in uart_get_divisor()
433 quot = port->custom_divisor; in uart_get_divisor()
435 quot = DIV_ROUND_CLOSEST(port->uartclk, 16 * baud); in uart_get_divisor()
488 static inline int __uart_put_char(struct uart_port *port, in __uart_put_char() argument
497 spin_lock_irqsave(&port->lock, flags); in __uart_put_char()
503 spin_unlock_irqrestore(&port->lock, flags); in __uart_put_char()
523 struct uart_port *port; in uart_write() local
537 port = state->uart_port; in uart_write()
543 spin_lock_irqsave(&port->lock, flags); in uart_write()
558 spin_unlock_irqrestore(&port->lock, flags); in uart_write()
590 struct uart_port *port; in uart_flush_buffer() local
602 port = state->uart_port; in uart_flush_buffer()
605 spin_lock_irqsave(&port->lock, flags); in uart_flush_buffer()
607 if (port->ops->flush_buffer) in uart_flush_buffer()
608 port->ops->flush_buffer(port); in uart_flush_buffer()
609 spin_unlock_irqrestore(&port->lock, flags); in uart_flush_buffer()
620 struct uart_port *port = state->uart_port; in uart_send_xchar() local
623 if (port->ops->send_xchar) in uart_send_xchar()
624 port->ops->send_xchar(port, ch); in uart_send_xchar()
626 spin_lock_irqsave(&port->lock, flags); in uart_send_xchar()
627 port->x_char = ch; in uart_send_xchar()
629 port->ops->start_tx(port); in uart_send_xchar()
630 spin_unlock_irqrestore(&port->lock, flags); in uart_send_xchar()
637 struct uart_port *port = state->uart_port; in uart_throttle() local
645 if (port->status & mask) { in uart_throttle()
646 port->ops->throttle(port); in uart_throttle()
647 mask &= ~port->status; in uart_throttle()
654 uart_clear_mctrl(port, TIOCM_RTS); in uart_throttle()
660 struct uart_port *port = state->uart_port; in uart_unthrottle() local
668 if (port->status & mask) { in uart_unthrottle()
669 port->ops->unthrottle(port); in uart_unthrottle()
670 mask &= ~port->status; in uart_unthrottle()
677 uart_set_mctrl(port, TIOCM_RTS); in uart_unthrottle()
680 static void do_uart_get_info(struct tty_port *port, in do_uart_get_info() argument
683 struct uart_state *state = container_of(port, struct uart_state, port); in do_uart_get_info()
690 retinfo->port = uport->iobase; in do_uart_get_info()
697 retinfo->close_delay = jiffies_to_msecs(port->close_delay) / 10; in do_uart_get_info()
698 retinfo->closing_wait = port->closing_wait == ASYNC_CLOSING_WAIT_NONE ? in do_uart_get_info()
700 jiffies_to_msecs(port->closing_wait) / 10; in do_uart_get_info()
708 static void uart_get_info(struct tty_port *port, in uart_get_info() argument
713 mutex_lock(&port->mutex); in uart_get_info()
714 do_uart_get_info(port, retinfo); in uart_get_info()
715 mutex_unlock(&port->mutex); in uart_get_info()
718 static int uart_get_info_user(struct tty_port *port, in uart_get_info_user() argument
722 uart_get_info(port, &tmp); in uart_get_info_user()
729 static int uart_set_info(struct tty_struct *tty, struct tty_port *port, in uart_set_info() argument
740 new_port = new_info->port; in uart_set_info()
775 (close_delay != port->close_delay) || in uart_set_info()
776 (closing_wait != port->closing_wait) || in uart_set_info()
806 if (tty_port_users(port) > 1) in uart_set_info()
889 port->close_delay = close_delay; in uart_set_info()
890 port->closing_wait = closing_wait; in uart_set_info()
893 port->low_latency = (uport->flags & UPF_LOW_LATENCY) ? 1 : 0; in uart_set_info()
899 if (port->flags & ASYNC_INITIALIZED) { in uart_set_info()
911 tty_name(port->tty)); in uart_set_info()
925 struct tty_port *port = &state->port; in uart_set_info_user() local
938 mutex_lock(&port->mutex); in uart_set_info_user()
939 retval = uart_set_info(tty, port, state, &new_serial); in uart_set_info_user()
940 mutex_unlock(&port->mutex); in uart_set_info_user()
977 struct tty_port *port = &state->port; in uart_tiocmget() local
981 mutex_lock(&port->mutex); in uart_tiocmget()
988 mutex_unlock(&port->mutex); in uart_tiocmget()
998 struct tty_port *port = &state->port; in uart_tiocmset() local
1001 mutex_lock(&port->mutex); in uart_tiocmset()
1006 mutex_unlock(&port->mutex); in uart_tiocmset()
1013 struct tty_port *port = &state->port; in uart_break_ctl() local
1016 mutex_lock(&port->mutex); in uart_break_ctl()
1021 mutex_unlock(&port->mutex); in uart_break_ctl()
1028 struct tty_port *port = &state->port; in uart_do_autoconfig() local
1039 if (mutex_lock_interruptible(&port->mutex)) in uart_do_autoconfig()
1043 if (tty_port_users(port) == 1) { in uart_do_autoconfig()
1065 mutex_unlock(&port->mutex); in uart_do_autoconfig()
1091 struct tty_port *port = &state->port; in uart_wait_modem_status() local
1104 add_wait_queue(&port->delta_msr_wait, &wait); in uart_wait_modem_status()
1131 remove_wait_queue(&port->delta_msr_wait, &wait); in uart_wait_modem_status()
1168 static int uart_get_rs485_config(struct uart_port *port, in uart_get_rs485_config() argument
1174 spin_lock_irqsave(&port->lock, flags); in uart_get_rs485_config()
1175 aux = port->rs485; in uart_get_rs485_config()
1176 spin_unlock_irqrestore(&port->lock, flags); in uart_get_rs485_config()
1184 static int uart_set_rs485_config(struct uart_port *port, in uart_set_rs485_config() argument
1191 if (!port->rs485_config) in uart_set_rs485_config()
1197 spin_lock_irqsave(&port->lock, flags); in uart_set_rs485_config()
1198 ret = port->rs485_config(port, &rs485); in uart_set_rs485_config()
1199 spin_unlock_irqrestore(&port->lock, flags); in uart_set_rs485_config()
1203 if (copy_to_user(rs485_user, &port->rs485, sizeof(port->rs485))) in uart_set_rs485_config()
1217 struct tty_port *port = &state->port; in uart_ioctl() local
1227 ret = uart_get_info_user(port, uarg); in uart_ioctl()
1268 mutex_lock(&port->mutex); in uart_ioctl()
1300 mutex_unlock(&port->mutex); in uart_ioctl()
1311 mutex_lock(&state->port.mutex); in uart_set_ldisc()
1313 mutex_unlock(&state->port.mutex); in uart_set_ldisc()
1351 mutex_lock(&state->port.mutex); in uart_set_termios()
1353 mutex_unlock(&state->port.mutex); in uart_set_termios()
1378 struct tty_port *port; in uart_close() local
1385 port = &state->port; in uart_close()
1386 spin_lock_irq(&port->lock); in uart_close()
1387 --port->count; in uart_close()
1388 spin_unlock_irq(&port->lock); in uart_close()
1393 port = &state->port; in uart_close()
1397 if (!port->count || tty_port_close_start(port, tty, filp) == 0) in uart_close()
1404 if (port->flags & ASYNC_INITIALIZED) { in uart_close()
1416 mutex_lock(&port->mutex); in uart_close()
1418 tty_port_tty_set(port, NULL); in uart_close()
1420 spin_lock_irq(&port->lock); in uart_close()
1422 if (port->blocked_open) { in uart_close()
1423 spin_unlock_irq(&port->lock); in uart_close()
1424 if (port->close_delay) in uart_close()
1425 msleep_interruptible(jiffies_to_msecs(port->close_delay)); in uart_close()
1426 spin_lock_irq(&port->lock); in uart_close()
1428 spin_unlock_irq(&port->lock); in uart_close()
1430 spin_lock_irq(&port->lock); in uart_close()
1436 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags); in uart_close()
1437 clear_bit(ASYNCB_CLOSING, &port->flags); in uart_close()
1438 spin_unlock_irq(&port->lock); in uart_close()
1439 wake_up_interruptible(&port->open_wait); in uart_close()
1441 mutex_unlock(&port->mutex); in uart_close()
1450 struct uart_port *port = state->uart_port; in uart_wait_until_sent() local
1453 if (port->type == PORT_UNKNOWN || port->fifosize == 0) in uart_wait_until_sent()
1464 char_time = (port->timeout - HZ/50) / port->fifosize; in uart_wait_until_sent()
1480 if (timeout == 0 || timeout > 2 * port->timeout) in uart_wait_until_sent()
1481 timeout = 2 * port->timeout; in uart_wait_until_sent()
1486 port->line, jiffies, expire); in uart_wait_until_sent()
1493 while (!port->ops->tx_empty(port)) { in uart_wait_until_sent()
1510 struct tty_port *port = &state->port; in uart_hangup() local
1515 mutex_lock(&port->mutex); in uart_hangup()
1516 if (port->flags & ASYNC_NORMAL_ACTIVE) { in uart_hangup()
1519 spin_lock_irqsave(&port->lock, flags); in uart_hangup()
1520 port->count = 0; in uart_hangup()
1521 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags); in uart_hangup()
1522 spin_unlock_irqrestore(&port->lock, flags); in uart_hangup()
1523 tty_port_tty_set(port, NULL); in uart_hangup()
1526 wake_up_interruptible(&port->open_wait); in uart_hangup()
1527 wake_up_interruptible(&port->delta_msr_wait); in uart_hangup()
1529 mutex_unlock(&port->mutex); in uart_hangup()
1532 static void uart_port_shutdown(struct tty_port *port) in uart_port_shutdown() argument
1534 struct uart_state *state = container_of(port, struct uart_state, port); in uart_port_shutdown()
1544 wake_up_interruptible(&port->delta_msr_wait); in uart_port_shutdown()
1557 static int uart_carrier_raised(struct tty_port *port) in uart_carrier_raised() argument
1559 struct uart_state *state = container_of(port, struct uart_state, port); in uart_carrier_raised()
1571 static void uart_dtr_rts(struct tty_port *port, int onoff) in uart_dtr_rts() argument
1573 struct uart_state *state = container_of(port, struct uart_state, port); in uart_dtr_rts()
1597 struct tty_port *port = &state->port; in uart_open() local
1601 spin_lock_irq(&port->lock); in uart_open()
1602 ++port->count; in uart_open()
1603 spin_unlock_irq(&port->lock); in uart_open()
1612 if (mutex_lock_interruptible(&port->mutex)) { in uart_open()
1624 state->port.low_latency = in uart_open()
1626 tty_port_tty_set(port, tty); in uart_open()
1636 mutex_unlock(&port->mutex); in uart_open()
1638 retval = tty_port_block_til_ready(port, tty, filp); in uart_open()
1643 mutex_unlock(&port->mutex); in uart_open()
1647 static const char *uart_type(struct uart_port *port) in uart_type() argument
1651 if (port->ops->type) in uart_type()
1652 str = port->ops->type(port); in uart_type()
1665 struct tty_port *port = &state->port; in uart_line_info() local
1689 mutex_lock(&port->mutex); in uart_line_info()
1698 mutex_unlock(&port->mutex); in uart_line_info()
1777 void uart_console_write(struct uart_port *port, const char *s, in uart_console_write() argument
1785 putchar(port, '\r'); in uart_console_write()
1786 putchar(port, *s); in uart_console_write()
1925 uart_set_options(struct uart_port *port, struct console *co, in uart_set_options() argument
1938 if (!(uart_console(port) && (port->cons->flags & CON_ENABLED))) { in uart_set_options()
1939 spin_lock_init(&port->lock); in uart_set_options()
1940 lockdep_set_class(&port->lock, &port_lock_key); in uart_set_options()
1977 port->mctrl |= TIOCM_DTR; in uart_set_options()
1979 port->ops->set_termios(port, &termios, &dummy); in uart_set_options()
2003 struct uart_port *port = state->uart_port; in uart_change_pm() local
2006 if (port->ops->pm) in uart_change_pm()
2007 port->ops->pm(port, pm_state, state->pm_state); in uart_change_pm()
2013 struct uart_port *port; member
2022 match->port->line; in serial_match_port()
2030 struct tty_port *port = &state->port; in uart_suspend_port() local
2034 mutex_lock(&port->mutex); in uart_suspend_port()
2041 mutex_unlock(&port->mutex); in uart_suspend_port()
2052 if (port->flags & ASYNC_INITIALIZED) { in uart_suspend_port()
2056 set_bit(ASYNCB_SUSPENDED, &port->flags); in uart_suspend_port()
2057 clear_bit(ASYNCB_INITIALIZED, &port->flags); in uart_suspend_port()
2086 mutex_unlock(&port->mutex); in uart_suspend_port()
2094 struct tty_port *port = &state->port; in uart_resume_port() local
2099 mutex_lock(&port->mutex); in uart_resume_port()
2108 mutex_unlock(&port->mutex); in uart_resume_port()
2127 if (port->tty && termios.c_cflag == 0) in uart_resume_port()
2128 termios = port->tty->termios; in uart_resume_port()
2137 if (port->flags & ASYNC_SUSPENDED) { in uart_resume_port()
2147 struct tty_struct *tty = port->tty; in uart_resume_port()
2156 set_bit(ASYNCB_INITIALIZED, &port->flags); in uart_resume_port()
2167 clear_bit(ASYNCB_SUSPENDED, &port->flags); in uart_resume_port()
2170 mutex_unlock(&port->mutex); in uart_resume_port()
2176 uart_report_port(struct uart_driver *drv, struct uart_port *port) in uart_report_port() argument
2180 switch (port->iotype) { in uart_report_port()
2182 snprintf(address, sizeof(address), "I/O 0x%lx", port->iobase); in uart_report_port()
2186 "I/O 0x%lx offset 0x%x", port->iobase, port->hub6); in uart_report_port()
2194 "MMIO 0x%llx", (unsigned long long)port->mapbase); in uart_report_port()
2202 port->dev ? dev_name(port->dev) : "", in uart_report_port()
2203 port->dev ? ": " : "", in uart_report_port()
2205 drv->tty_driver->name_base + port->line, in uart_report_port()
2206 address, port->irq, port->uartclk / 16, uart_type(port)); in uart_report_port()
2211 struct uart_port *port) in uart_configure_port() argument
2218 if (!port->iobase && !port->mapbase && !port->membase) in uart_configure_port()
2226 if (port->flags & UPF_AUTO_IRQ) in uart_configure_port()
2228 if (port->flags & UPF_BOOT_AUTOCONF) { in uart_configure_port()
2229 if (!(port->flags & UPF_FIXED_TYPE)) { in uart_configure_port()
2230 port->type = PORT_UNKNOWN; in uart_configure_port()
2233 port->ops->config_port(port, flags); in uart_configure_port()
2236 if (port->type != PORT_UNKNOWN) { in uart_configure_port()
2239 uart_report_port(drv, port); in uart_configure_port()
2249 spin_lock_irqsave(&port->lock, flags); in uart_configure_port()
2250 port->ops->set_mctrl(port, port->mctrl & TIOCM_DTR); in uart_configure_port()
2251 spin_unlock_irqrestore(&port->lock, flags); in uart_configure_port()
2258 if (port->cons && !(port->cons->flags & CON_ENABLED)) in uart_configure_port()
2259 register_console(port->cons); in uart_configure_port()
2265 if (!uart_console(port)) in uart_configure_port()
2276 struct uart_port *port; in uart_poll_init() local
2286 port = state->uart_port; in uart_poll_init()
2287 if (!(port->ops->poll_get_char && port->ops->poll_put_char)) in uart_poll_init()
2290 if (port->ops->poll_init) { in uart_poll_init()
2291 struct tty_port *tport = &state->port; in uart_poll_init()
2300 ret = port->ops->poll_init(port); in uart_poll_init()
2308 return uart_set_options(port, NULL, baud, parity, bits, flow); in uart_poll_init()
2318 struct uart_port *port; in uart_poll_get_char() local
2323 port = state->uart_port; in uart_poll_get_char()
2324 return port->ops->poll_get_char(port); in uart_poll_get_char()
2331 struct uart_port *port; in uart_poll_put_char() local
2336 port = state->uart_port; in uart_poll_put_char()
2339 port->ops->poll_put_char(port, '\r'); in uart_poll_put_char()
2340 port->ops->poll_put_char(port, ch); in uart_poll_put_char()
2434 struct tty_port *port = &state->port; in uart_register_driver() local
2436 tty_port_init(port); in uart_register_driver()
2437 port->ops = &uart_port_ops; in uart_register_driver()
2445 tty_port_destroy(&drv->state[i].port); in uart_register_driver()
2470 tty_port_destroy(&drv->state[i].port); in uart_unregister_driver()
2487 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_uartclk() local
2489 uart_get_info(port, &tmp); in uart_get_attr_uartclk()
2497 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_type() local
2499 uart_get_info(port, &tmp); in uart_get_attr_type()
2506 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_line() local
2508 uart_get_info(port, &tmp); in uart_get_attr_line()
2516 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_port() local
2519 uart_get_info(port, &tmp); in uart_get_attr_port()
2520 ioaddr = tmp.port; in uart_get_attr_port()
2530 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_irq() local
2532 uart_get_info(port, &tmp); in uart_get_attr_irq()
2540 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_flags() local
2542 uart_get_info(port, &tmp); in uart_get_attr_flags()
2550 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_xmit_fifo_size() local
2552 uart_get_info(port, &tmp); in uart_get_attr_xmit_fifo_size()
2561 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_close_delay() local
2563 uart_get_info(port, &tmp); in uart_get_attr_close_delay()
2572 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_closing_wait() local
2574 uart_get_info(port, &tmp); in uart_get_attr_closing_wait()
2582 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_custom_divisor() local
2584 uart_get_info(port, &tmp); in uart_get_attr_custom_divisor()
2592 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_io_type() local
2594 uart_get_info(port, &tmp); in uart_get_attr_io_type()
2602 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_iomem_base() local
2604 uart_get_info(port, &tmp); in uart_get_attr_iomem_base()
2612 struct tty_port *port = dev_get_drvdata(dev); in uart_get_attr_iomem_reg_shift() local
2614 uart_get_info(port, &tmp); in uart_get_attr_iomem_reg_shift()
2620 static DEVICE_ATTR(port, S_IRUSR | S_IRGRP, uart_get_attr_port, NULL);
2666 struct tty_port *port; in uart_add_one_port() local
2677 port = &state->port; in uart_add_one_port()
2680 mutex_lock(&port->mutex); in uart_add_one_port()
2725 tty_dev = tty_port_register_device_attr(port, drv->tty_driver, in uart_add_one_port()
2726 uport->line, uport->dev, port, uport->tty_groups); in uart_add_one_port()
2740 mutex_unlock(&port->mutex); in uart_add_one_port()
2758 struct tty_port *port = &state->port; in uart_remove_one_port() local
2774 mutex_lock(&port->mutex); in uart_remove_one_port()
2776 mutex_unlock(&port->mutex); in uart_remove_one_port()
2781 mutex_unlock(&port->mutex); in uart_remove_one_port()
2788 tty = tty_port_tty_get(port); in uart_remove_one_port()
2790 tty_vhangup(port->tty); in uart_remove_one_port()
2853 struct tty_port *port = &uport->state->port; in uart_handle_dcd_change() local
2854 struct tty_struct *tty = port->tty; in uart_handle_dcd_change()
2872 wake_up_interruptible(&port->open_wait); in uart_handle_dcd_change()
2922 void uart_insert_char(struct uart_port *port, unsigned int status, in uart_insert_char() argument
2925 struct tty_port *tport = &port->state->port; in uart_insert_char()
2927 if ((status & port->ignore_status_mask & ~overrun) == 0) in uart_insert_char()
2929 ++port->icount.buf_overrun; in uart_insert_char()
2935 if (status & ~port->ignore_status_mask & overrun) in uart_insert_char()
2937 ++port->icount.buf_overrun; in uart_insert_char()