drivers/tty/serial/mps2-uart.c
Source file repositories/reference/linux-study-clean/drivers/tty/serial/mps2-uart.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/serial/mps2-uart.c- Extension
.c- Size
- 15034 bytes
- Lines
- 636
- Domain
- Driver Families
- Bucket
- drivers/tty
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitops.hlinux/clk.hlinux/console.hlinux/io.hlinux/kernel.hlinux/of.hlinux/platform_device.hlinux/serial_core.hlinux/tty_flip.hlinux/types.hlinux/idr.h
Detected Declarations
struct mps2_uart_portfunction mps2_uart_write8function mps2_uart_read8function mps2_uart_write32function mps2_uart_tx_emptyfunction mps2_uart_set_mctrlfunction mps2_uart_stop_txfunction mps2_uart_tx_charsfunction mps2_uart_start_txfunction mps2_uart_stop_rxfunction mps2_uart_break_ctlfunction mps2_uart_rxirqfunction mps2_uart_txirqfunction mps2_uart_oerrirqfunction mps2_uart_combinedirqfunction mps2_uart_startupfunction mps2_uart_shutdownfunction mps2_uart_set_termiosfunction mps2_uart_release_portfunction mps2_uart_config_portfunction mps2_uart_verify_portfunction mps2_uart_console_putcharfunction mps2_uart_console_writefunction mps2_uart_console_setupfunction mps2_early_putcharfunction mps2_early_writefunction mps2_early_console_setupfunction mps2_of_get_portfunction mps2_init_portfunction mps2_serial_probefunction mps2_uart_init
Annotated Snippet
struct mps2_uart_port {
struct uart_port port;
struct clk *clk;
unsigned int tx_irq;
unsigned int rx_irq;
unsigned int flags;
};
static inline struct mps2_uart_port *to_mps2_port(struct uart_port *port)
{
return container_of(port, struct mps2_uart_port, port);
}
static void mps2_uart_write8(struct uart_port *port, u8 val, unsigned int off)
{
struct mps2_uart_port *mps_port = to_mps2_port(port);
writeb(val, mps_port->port.membase + off);
}
static u8 mps2_uart_read8(struct uart_port *port, unsigned int off)
{
struct mps2_uart_port *mps_port = to_mps2_port(port);
return readb(mps_port->port.membase + off);
}
static void mps2_uart_write32(struct uart_port *port, u32 val, unsigned int off)
{
struct mps2_uart_port *mps_port = to_mps2_port(port);
writel_relaxed(val, mps_port->port.membase + off);
}
static unsigned int mps2_uart_tx_empty(struct uart_port *port)
{
u8 status = mps2_uart_read8(port, UARTn_STATE);
return (status & UARTn_STATE_TX_FULL) ? 0 : TIOCSER_TEMT;
}
static void mps2_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
}
static unsigned int mps2_uart_get_mctrl(struct uart_port *port)
{
return TIOCM_CAR | TIOCM_CTS | TIOCM_DSR;
}
static void mps2_uart_stop_tx(struct uart_port *port)
{
u8 control = mps2_uart_read8(port, UARTn_CTRL);
control &= ~UARTn_CTRL_TX_INT_ENABLE;
mps2_uart_write8(port, control, UARTn_CTRL);
}
static void mps2_uart_tx_chars(struct uart_port *port)
{
u8 ch;
uart_port_tx(port, ch,
mps2_uart_tx_empty(port),
mps2_uart_write8(port, ch, UARTn_DATA));
}
static void mps2_uart_start_tx(struct uart_port *port)
{
u8 control = mps2_uart_read8(port, UARTn_CTRL);
control |= UARTn_CTRL_TX_INT_ENABLE;
mps2_uart_write8(port, control, UARTn_CTRL);
/*
* We've just unmasked the TX IRQ and now slow-starting via
* polling; if there is enough data to fill up the internal
* write buffer in one go, the TX IRQ should assert, at which
* point we switch to fully interrupt-driven TX.
*/
mps2_uart_tx_chars(port);
}
static void mps2_uart_stop_rx(struct uart_port *port)
{
u8 control = mps2_uart_read8(port, UARTn_CTRL);
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk.h`, `linux/console.h`, `linux/io.h`, `linux/kernel.h`, `linux/of.h`, `linux/platform_device.h`, `linux/serial_core.h`.
- Detected declarations: `struct mps2_uart_port`, `function mps2_uart_write8`, `function mps2_uart_read8`, `function mps2_uart_write32`, `function mps2_uart_tx_empty`, `function mps2_uart_set_mctrl`, `function mps2_uart_stop_tx`, `function mps2_uart_tx_chars`, `function mps2_uart_start_tx`, `function mps2_uart_stop_rx`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.