drivers/tty/serial/mvebu-uart.c
Source file repositories/reference/linux-study-clean/drivers/tty/serial/mvebu-uart.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/serial/mvebu-uart.c- Extension
.c- Size
- 42178 bytes
- Lines
- 1532
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/clk-provider.hlinux/console.hlinux/delay.hlinux/device.hlinux/init.hlinux/io.hlinux/iopoll.hlinux/math64.hlinux/of.hlinux/of_address.hlinux/of_device.hlinux/of_irq.hlinux/of_platform.hlinux/platform_device.hlinux/serial.hlinux/serial_core.hlinux/slab.hlinux/tty.hlinux/tty_flip.h
Detected Declarations
struct uart_regs_layoutstruct uart_flagsstruct mvebu_uart_driver_datastruct mvebu_uart_pm_regsstruct mvebu_uartstruct mvebu_uart_clockstruct mvebu_uart_clock_basefunction mvebu_uart_tx_emptyfunction mvebu_uart_get_mctrlfunction mvebu_uart_set_mctrlfunction mvebu_uart_start_txfunction mvebu_uart_stop_rxfunction mvebu_uart_break_ctlfunction mvebu_uart_rx_charsfunction mvebu_uart_tx_charsfunction mvebu_uart_isrfunction mvebu_uart_rx_isrfunction mvebu_uart_tx_isrfunction mvebu_uart_startupfunction mvebu_uart_shutdownfunction mvebu_uart_baud_rate_setfunction mvebu_uart_set_termiosfunction mvebu_uart_release_portfunction mvebu_uart_get_poll_charfunction mvebu_uart_put_poll_charfunction mvebu_uart_putcfunction mvebu_uart_putc_early_writefunction mvebu_uart_early_console_setupfunction wait_for_xmitrfunction wait_for_xmitefunction mvebu_uart_console_putcharfunction mvebu_uart_console_writefunction mvebu_uart_console_setupfunction mvebu_uart_console_initfunction mvebu_uart_suspendfunction mvebu_uart_resumefunction mvebu_uart_probefunction mvebu_uart_clock_preparefunction mvebu_uart_clock_enablefunction mvebu_uart_clock_disablefunction mvebu_uart_clock_is_enabledfunction mvebu_uart_clock_save_contextfunction mvebu_uart_clock_restore_contextfunction mvebu_uart_clock_recalc_ratefunction mvebu_uart_clock_determine_ratefunction mvebu_uart_clock_set_ratefunction mvebu_uart_clock_registerfunction mvebu_uart_clock_probe
Annotated Snippet
struct uart_regs_layout {
unsigned int rbr;
unsigned int tsh;
unsigned int ctrl;
unsigned int intr;
};
/* Diverging flags */
struct uart_flags {
unsigned int ctrl_tx_rdy_int;
unsigned int ctrl_rx_rdy_int;
unsigned int stat_tx_rdy;
unsigned int stat_rx_rdy;
};
/* Driver data, a structure for each UART port */
struct mvebu_uart_driver_data {
bool is_ext;
struct uart_regs_layout regs;
struct uart_flags flags;
};
/* Saved registers during suspend */
struct mvebu_uart_pm_regs {
unsigned int rbr;
unsigned int tsh;
unsigned int ctrl;
unsigned int intr;
unsigned int stat;
unsigned int brdv;
unsigned int osamp;
};
/* MVEBU UART driver structure */
struct mvebu_uart {
struct uart_port *port;
struct clk *clk;
int irq[UART_IRQ_COUNT];
struct mvebu_uart_driver_data *data;
#if defined(CONFIG_PM)
struct mvebu_uart_pm_regs pm_regs;
#endif /* CONFIG_PM */
};
static struct mvebu_uart *to_mvuart(struct uart_port *port)
{
return (struct mvebu_uart *)port->private_data;
}
#define IS_EXTENDED(port) (to_mvuart(port)->data->is_ext)
#define UART_RBR(port) (to_mvuart(port)->data->regs.rbr)
#define UART_TSH(port) (to_mvuart(port)->data->regs.tsh)
#define UART_CTRL(port) (to_mvuart(port)->data->regs.ctrl)
#define UART_INTR(port) (to_mvuart(port)->data->regs.intr)
#define CTRL_TX_RDY_INT(port) (to_mvuart(port)->data->flags.ctrl_tx_rdy_int)
#define CTRL_RX_RDY_INT(port) (to_mvuart(port)->data->flags.ctrl_rx_rdy_int)
#define STAT_TX_RDY(port) (to_mvuart(port)->data->flags.stat_tx_rdy)
#define STAT_RX_RDY(port) (to_mvuart(port)->data->flags.stat_rx_rdy)
static struct uart_port mvebu_uart_ports[MVEBU_NR_UARTS];
static DEFINE_SPINLOCK(mvebu_uart_lock);
/* Core UART Driver Operations */
static unsigned int mvebu_uart_tx_empty(struct uart_port *port)
{
unsigned long flags;
unsigned int st;
uart_port_lock_irqsave(port, &flags);
st = readl(port->membase + UART_STAT);
uart_port_unlock_irqrestore(port, flags);
return (st & STAT_TX_EMP) ? TIOCSER_TEMT : 0;
}
static unsigned int mvebu_uart_get_mctrl(struct uart_port *port)
{
return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
}
static void mvebu_uart_set_mctrl(struct uart_port *port,
unsigned int mctrl)
{
/*
* Even if we do not support configuring the modem control lines, this
* function must be proided to the serial core
*/
Annotation
- Immediate include surface: `linux/clk.h`, `linux/clk-provider.h`, `linux/console.h`, `linux/delay.h`, `linux/device.h`, `linux/init.h`, `linux/io.h`, `linux/iopoll.h`.
- Detected declarations: `struct uart_regs_layout`, `struct uart_flags`, `struct mvebu_uart_driver_data`, `struct mvebu_uart_pm_regs`, `struct mvebu_uart`, `struct mvebu_uart_clock`, `struct mvebu_uart_clock_base`, `function mvebu_uart_tx_empty`, `function mvebu_uart_get_mctrl`, `function mvebu_uart_set_mctrl`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.