Lines Matching +full:uart +full:- +full:state

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
25 ((port)->cons && (port)->cons->index == (port)->line)
37 * struct uart_ops -- interface between serial_core and the driver
55 * This function sets the modem control lines for @port to the state
58 * - %TIOCM_RTS RTS signal.
59 * - %TIOCM_DTR DTR signal.
60 * - %TIOCM_OUT1 OUT1 signal.
61 * - %TIOCM_OUT2 OUT2 signal.
62 * - %TIOCM_LOOP Set the port into loopback mode.
68 * Locking: @port->lock taken.
74 * Returns the current state of modem control inputs of @port. The state
76 * their state. The state information should include:
78 * - %TIOCM_CAR state of DCD signal
79 * - %TIOCM_CTS state of CTS signal
80 * - %TIOCM_DSR state of DSR signal
81 * - %TIOCM_RI state of RI signal
88 * Locking: @port->lock taken.
100 * Locking: @port->lock taken.
108 * Locking: @port->lock taken.
150 * Locking: @port->lock taken.
158 * Locking: @port->lock taken.
169 * Locking: @port->lock taken.
179 * Locking: caller holds tty_port->mutex
183 * Grab any interrupt resources and initialise any low level driver state.
198 * Drivers must not access @port->state once this call has completed.
208 * Flush any write buffers, reset any DMA state and stop any ongoing DMA
211 * This will be called whenever the @port->state->xmit circular buffer is
214 * Locking: @port->lock taken.
222 * Update @port->read_status_mask and @port->ignore_status_mask to
226 * - %CSIZE - word size
227 * - %CSTOPB - 2 stop bits
228 * - %PARENB - parity enable
229 * - %PARODD - odd parity (when %PARENB is in force)
230 * - %ADDRB - address bit (changed through uart_port::rs485_config()).
231 * - %CREAD - enable reception of characters (if not set, still receive
233 * - %CRTSCTS - if set, enable CTS status change reporting.
234 * - %CLOCAL - if not set, enable modem status change reporting.
238 * - %INPCK - enable frame and parity error events to be passed to the TTY
240 * - %BRKINT / %PARMRK - both of these enable break events to be passed to
242 * - %IGNPAR - ignore parity and framing errors.
243 * - %IGNBRK - ignore break errors. If %IGNPAR is also set, ignore overrun
261 * Locking: caller holds tty_port->mutex
268 * Documentation/driver-api/tty/tty_ldisc.rst.
270 * Locking: caller holds tty_port->mutex
272 * @pm: ``void ()(struct uart_port *port, unsigned int state,
276 * @state indicates the new state (defined by enum uart_pm_state),
277 * @oldstate indicates the previous state.
308 * it should return -%EBUSY on failure.
318 * @port->type should be set to the type found, or %PORT_UNKNOWN if no
353 * Locking: %tty_mutex and tty_port->mutex taken.
394 void (*pm)(struct uart_port *, unsigned int state,
455 void (*pm)(struct uart_port *, unsigned int state,
467 unsigned int uartclk; /* base uart clock */
477 #define UPIO_MEM (SERIAL_IO_MEM) /* driver-specific */
491 struct uart_state *state; /* pointer to parent state */ member
505 * The remaining bits are serial-core specific and not modifiable by
528 /* Port has hardware-assisted h/w flow control */
532 /* Port has hardware-assisted s/w flow control */
538 /* The exact UART type is known and should not be probed. */
551 #error Change mask not equivalent to userspace-visible bit defines
567 bool hw_stopped; /* sw-assisted CTS flow state */
594 …struct gpio_desc *rs485_rx_during_tx_gpio; /* Output GPIO that sets the state of RS485 RX during T…
600 * Only for console->device_lock()/_unlock() callbacks and internal
605 spin_lock_irqsave(&up->lock, *flags); in __uart_port_lock_irqsave()
609 * Only for console->device_lock()/_unlock() callbacks and internal
614 spin_unlock_irqrestore(&up->lock, flags); in __uart_port_unlock_irqrestore()
618 * uart_port_set_cons - Safely set the @cons field for a uart
619 * @up: The uart port to set
622 * This function must be used to set @up->cons. It uses the port lock to
631 up->cons = con; in uart_port_set_cons()
638 lockdep_assert_held_once(&up->lock); in __uart_port_using_nbcon()
644 * @up->cons is only modified under the port lock. Therefore it is in __uart_port_using_nbcon()
647 * @up->cons->node is added/removed from the console list under the in __uart_port_using_nbcon()
649 * cannot change here, thus @up->cons->flags can be read directly. in __uart_port_using_nbcon()
651 if (hlist_unhashed_lockless(&up->cons->node) || in __uart_port_using_nbcon()
652 !(up->cons->flags & CON_NBCON) || in __uart_port_using_nbcon()
653 !up->cons->write_atomic) { in __uart_port_using_nbcon()
666 return nbcon_device_try_acquire(up->cons); in __uart_port_nbcon_try_acquire()
675 while (!nbcon_device_try_acquire(up->cons)) in __uart_port_nbcon_acquire()
685 nbcon_device_release(up->cons); in __uart_port_nbcon_release()
689 * uart_port_lock - Lock the UART port
690 * @up: Pointer to UART port structure
694 spin_lock(&up->lock); in uart_port_lock()
699 * uart_port_lock_irq - Lock the UART port and disable interrupts
700 * @up: Pointer to UART port structure
704 spin_lock_irq(&up->lock); in uart_port_lock_irq()
709 * uart_port_lock_irqsave - Lock the UART port, save and disable interrupts
710 * @up: Pointer to UART port structure
715 spin_lock_irqsave(&up->lock, *flags); in uart_port_lock_irqsave()
720 * uart_port_trylock - Try to lock the UART port
721 * @up: Pointer to UART port structure
727 if (!spin_trylock(&up->lock)) in uart_port_trylock()
731 spin_unlock(&up->lock); in uart_port_trylock()
739 * uart_port_trylock_irqsave - Try to lock the UART port, save and disable interrupts
740 * @up: Pointer to UART port structure
747 if (!spin_trylock_irqsave(&up->lock, *flags)) in uart_port_trylock_irqsave()
751 spin_unlock_irqrestore(&up->lock, *flags); in uart_port_trylock_irqsave()
759 * uart_port_unlock - Unlock the UART port
760 * @up: Pointer to UART port structure
765 spin_unlock(&up->lock); in uart_port_unlock()
769 * uart_port_unlock_irq - Unlock the UART port and re-enable interrupts
770 * @up: Pointer to UART port structure
775 spin_unlock_irq(&up->lock); in uart_port_unlock_irq()
779 * uart_port_unlock_irqrestore - Unlock the UART port, restore interrupts
780 * @up: Pointer to UART port structure
786 spin_unlock_irqrestore(&up->lock, flags); in uart_port_unlock_irqrestore()
791 return up->serial_in(up, offset); in serial_port_in()
796 up->serial_out(up, offset, value); in serial_port_out()
800 * enum uart_pm_state - power states for UARTs
801 * @UART_PM_STATE_ON: UART is powered, up and operational
802 * @UART_PM_STATE_OFF: UART is powered off
812 * This is the state information which is persistent across opens.
831 * uart_xmit_advance - Advance xmit buffer and account Tx'ed chars
841 struct tty_port *tport = &up->state->port; in uart_xmit_advance()
843 kfifo_skip_count(&tport->xmit_fifo, chars); in uart_xmit_advance()
844 up->icount.tx += chars; in uart_xmit_advance()
850 struct tty_port *tport = &up->state->port; in uart_fifo_out()
852 chars = kfifo_out(&tport->xmit_fifo, buf, chars); in uart_fifo_out()
853 up->icount.tx += chars; in uart_fifo_out()
861 struct tty_port *tport = &up->state->port; in uart_fifo_get()
864 chars = kfifo_get(&tport->xmit_fifo, ch); in uart_fifo_get()
865 up->icount.tx += chars; in uart_fifo_get()
886 struct uart_state *state; member
893 * enum UART_TX_FLAGS -- flags for uart_port_tx_flags()
895 * @UART_TX_NOSTOP: don't call port->ops->stop_tx() on empty buffer
905 struct tty_port *__tport = &__port->state->port; \
908 for (; (for_test) && (tx_ready); (for_post), __port->icount.tx++) { \
909 if (__port->x_char) { \
910 (ch) = __port->x_char; \
912 __port->x_char = 0; \
919 if (!kfifo_get(&__tport->xmit_fifo, &(ch))) \
927 pending = kfifo_len(&__tport->xmit_fifo); \
932 __port->ops->stop_tx(__port); \
939 * uart_port_tx_limited -- transmit helper for uart_port with count limiting
940 * @port: uart port
958 * action before potential invocation of ops->stop_tx() happens. If the
961 * For all of them, @port->lock is held, interrupts are locally disabled and
967 __count--); \
971 * uart_port_tx_limited_flags -- transmit helper for uart_port with count limiting with flags
972 * @port: uart port
985 __count--); \
989 * uart_port_tx -- transmit helper for uart_port
990 * @port: uart port
1002 * uart_port_tx_flags -- transmit helper for uart_port with flags
1003 * @port: uart port
1028 u64 fifo_timeout = (u64)READ_ONCE(port->frame_time) * port->fifosize; in uart_fifo_timeout()
1041 return timeout > 6 ? (timeout / 2 - 2) : 1; in uart_poll_timeout()
1094 return uart_console(port) && console_is_registered_locked(port->cons); in uart_console_registered_locked()
1099 return uart_console(port) && console_is_registered(port->cons); in uart_console_registered()
1118 int uart_register_driver(struct uart_driver *uart);
1119 void uart_unregister_driver(struct uart_driver *uart);
1135 struct tty_struct *tty = port->state->port.tty; in uart_tx_stopped()
1136 if ((tty && tty->flow.stopped) || port->hw_stopped) in uart_tx_stopped()
1143 return !!(uport->status & UPSTAT_CTS_ENABLE); in uart_cts_enabled()
1150 return ((uport->status & mask) == UPSTAT_CTS_ENABLE); in uart_softcts_mode()
1172 if (!port->sysrq) in uart_handle_sysrq_char()
1175 if (ch && time_before(jiffies, port->sysrq)) { in uart_handle_sysrq_char()
1178 port->sysrq = 0; in uart_handle_sysrq_char()
1184 port->sysrq = 0; in uart_handle_sysrq_char()
1191 if (!port->sysrq) in uart_prepare_sysrq_char()
1194 if (ch && time_before(jiffies, port->sysrq)) { in uart_prepare_sysrq_char()
1196 port->sysrq_ch = ch; in uart_prepare_sysrq_char()
1197 port->sysrq = 0; in uart_prepare_sysrq_char()
1203 port->sysrq = 0; in uart_prepare_sysrq_char()
1212 if (!port->has_sysrq) { in uart_unlock_and_check_sysrq()
1217 sysrq_ch = port->sysrq_ch; in uart_unlock_and_check_sysrq()
1218 port->sysrq_ch = 0; in uart_unlock_and_check_sysrq()
1231 if (!port->has_sysrq) { in uart_unlock_and_check_sysrq_irqrestore()
1236 sysrq_ch = port->sysrq_ch; in uart_unlock_and_check_sysrq_irqrestore()
1237 port->sysrq_ch = 0; in uart_unlock_and_check_sysrq_irqrestore()
1269 struct uart_state *state = port->state; in uart_handle_break() local
1271 if (port->handle_break) in uart_handle_break()
1272 port->handle_break(port); in uart_handle_break()
1275 if (port->has_sysrq && uart_console(port)) { in uart_handle_break()
1276 if (!port->sysrq) { in uart_handle_break()
1277 port->sysrq = jiffies + SYSRQ_TIMEOUT; in uart_handle_break()
1280 port->sysrq = 0; in uart_handle_break()
1283 if (port->flags & UPF_SAK) in uart_handle_break()
1284 do_SAK(state->port.tty); in uart_handle_break()
1289 * UART_ENABLE_MS - determine if port should enable modem status irqs
1291 #define UART_ENABLE_MS(port,cflag) ((port)->flags & UPF_HARDPPS_CD || \