drivers/tty/serial/meson_uart.c
Source file repositories/reference/linux-study-clean/drivers/tty/serial/meson_uart.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/serial/meson_uart.c- Extension
.c- Size
- 21586 bytes
- Lines
- 857
- 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/clk.hlinux/console.hlinux/delay.hlinux/init.hlinux/io.hlinux/iopoll.hlinux/module.hlinux/kernel.hlinux/of.hlinux/platform_device.hlinux/serial.hlinux/serial_core.hlinux/tty.hlinux/tty_flip.h
Detected Declarations
struct meson_uart_datafunction meson_uart_set_mctrlfunction meson_uart_tx_emptyfunction meson_uart_stop_txfunction meson_uart_stop_rxfunction meson_uart_shutdownfunction meson_uart_start_txfunction meson_receive_charsfunction meson_uart_interruptfunction probefunction meson_uart_startupfunction meson_uart_change_speedfunction meson_uart_set_termiosfunction meson_uart_verify_portfunction meson_uart_release_portfunction meson_uart_request_portfunction meson_uart_config_portfunction contextfunction meson_uart_poll_put_charfunction meson_uart_enable_tx_enginefunction meson_console_putcharfunction meson_serial_port_writefunction meson_serial_console_writefunction meson_serial_console_setupfunction meson_serial_early_console_writefunction meson_serial_early_console_setupfunction meson_uart_probe_clocksfunction meson_uart_probefunction meson_uart_remove
Annotated Snippet
struct meson_uart_data {
struct uart_driver *uart_driver;
bool has_xtal_div2;
};
static void meson_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
}
static unsigned int meson_uart_get_mctrl(struct uart_port *port)
{
return TIOCM_CTS;
}
static unsigned int meson_uart_tx_empty(struct uart_port *port)
{
u32 val;
val = readl(port->membase + AML_UART_STATUS);
val &= (AML_UART_TX_EMPTY | AML_UART_XMIT_BUSY);
return (val == AML_UART_TX_EMPTY) ? TIOCSER_TEMT : 0;
}
static void meson_uart_stop_tx(struct uart_port *port)
{
u32 val;
val = readl(port->membase + AML_UART_CONTROL);
val &= ~AML_UART_TX_INT_EN;
writel(val, port->membase + AML_UART_CONTROL);
}
static void meson_uart_stop_rx(struct uart_port *port)
{
u32 val;
val = readl(port->membase + AML_UART_CONTROL);
val &= ~AML_UART_RX_EN;
writel(val, port->membase + AML_UART_CONTROL);
}
static void meson_uart_shutdown(struct uart_port *port)
{
unsigned long flags;
u32 val;
free_irq(port->irq, port);
uart_port_lock_irqsave(port, &flags);
val = readl(port->membase + AML_UART_CONTROL);
val &= ~AML_UART_RX_EN;
val &= ~(AML_UART_RX_INT_EN | AML_UART_TX_INT_EN);
writel(val, port->membase + AML_UART_CONTROL);
uart_port_unlock_irqrestore(port, flags);
}
static void meson_uart_start_tx(struct uart_port *port)
{
struct tty_port *tport = &port->state->port;
unsigned char ch;
u32 val;
if (uart_tx_stopped(port)) {
meson_uart_stop_tx(port);
return;
}
while (!(readl(port->membase + AML_UART_STATUS) & AML_UART_TX_FULL)) {
if (port->x_char) {
writel(port->x_char, port->membase + AML_UART_WFIFO);
port->icount.tx++;
port->x_char = 0;
continue;
}
if (!uart_fifo_get(port, &ch))
break;
writel(ch, port->membase + AML_UART_WFIFO);
}
if (!kfifo_is_empty(&tport->xmit_fifo)) {
val = readl(port->membase + AML_UART_CONTROL);
val |= AML_UART_TX_INT_EN;
writel(val, port->membase + AML_UART_CONTROL);
}
if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
Annotation
- Immediate include surface: `linux/clk.h`, `linux/console.h`, `linux/delay.h`, `linux/init.h`, `linux/io.h`, `linux/iopoll.h`, `linux/module.h`, `linux/kernel.h`.
- Detected declarations: `struct meson_uart_data`, `function meson_uart_set_mctrl`, `function meson_uart_tx_empty`, `function meson_uart_stop_tx`, `function meson_uart_stop_rx`, `function meson_uart_shutdown`, `function meson_uart_start_tx`, `function meson_receive_chars`, `function meson_uart_interrupt`, `function probe`.
- 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.