drivers/tty/serial/timbuart.c
Source file repositories/reference/linux-study-clean/drivers/tty/serial/timbuart.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/serial/timbuart.c- Extension
.c- Size
- 12259 bytes
- Lines
- 497
- 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/pci.hlinux/interrupt.hlinux/serial_core.hlinux/tty.hlinux/tty_flip.hlinux/kernel.hlinux/platform_device.hlinux/ioport.hlinux/slab.hlinux/module.htimbuart.h
Detected Declarations
struct timbuart_portfunction timbuart_stop_rxfunction timbuart_stop_txfunction timbuart_start_txfunction timbuart_tx_emptyfunction timbuart_flush_bufferfunction timbuart_rx_charsfunction timbuart_tx_charsfunction timbuart_handle_tx_portfunction timbuart_handle_rx_portfunction timbuart_taskletfunction timbuart_get_mctrlfunction timbuart_set_mctrlfunction timbuart_mctrl_checkfunction timbuart_break_ctlfunction timbuart_shutdownfunction get_bindexfunction timbuart_set_termiosfunction timbuart_release_portfunction timbuart_request_portfunction timbuart_handleinterruptfunction timbuart_config_portfunction timbuart_verify_portfunction timbuart_probefunction timbuart_remove
Annotated Snippet
struct timbuart_port {
struct uart_port port;
struct tasklet_struct tasklet;
int usedma;
u32 last_ier;
struct platform_device *dev;
};
static int baudrates[] = {9600, 19200, 38400, 57600, 115200, 230400, 460800,
921600, 1843200, 3250000};
static void timbuart_mctrl_check(struct uart_port *port, u32 isr, u32 *ier);
static irqreturn_t timbuart_handleinterrupt(int irq, void *devid);
static void timbuart_stop_rx(struct uart_port *port)
{
/* spin lock held by upper layer, disable all RX interrupts */
u32 ier = ioread32(port->membase + TIMBUART_IER) & ~RXFLAGS;
iowrite32(ier, port->membase + TIMBUART_IER);
}
static void timbuart_stop_tx(struct uart_port *port)
{
/* spinlock held by upper layer, disable TX interrupt */
u32 ier = ioread32(port->membase + TIMBUART_IER) & ~TXBAE;
iowrite32(ier, port->membase + TIMBUART_IER);
}
static void timbuart_start_tx(struct uart_port *port)
{
struct timbuart_port *uart =
container_of(port, struct timbuart_port, port);
/* do not transfer anything here -> fire off the tasklet */
tasklet_schedule(&uart->tasklet);
}
static unsigned int timbuart_tx_empty(struct uart_port *port)
{
u32 isr = ioread32(port->membase + TIMBUART_ISR);
return (isr & TXBE) ? TIOCSER_TEMT : 0;
}
static void timbuart_flush_buffer(struct uart_port *port)
{
if (!timbuart_tx_empty(port)) {
u8 ctl = ioread8(port->membase + TIMBUART_CTRL) |
TIMBUART_CTRL_FLSHTX;
iowrite8(ctl, port->membase + TIMBUART_CTRL);
iowrite32(TXBF, port->membase + TIMBUART_ISR);
}
}
static void timbuart_rx_chars(struct uart_port *port)
{
struct tty_port *tport = &port->state->port;
while (ioread32(port->membase + TIMBUART_ISR) & RXDP) {
u8 ch = ioread8(port->membase + TIMBUART_RXFIFO);
port->icount.rx++;
tty_insert_flip_char(tport, ch, TTY_NORMAL);
}
tty_flip_buffer_push(tport);
dev_dbg(port->dev, "%s - total read %d bytes\n",
__func__, port->icount.rx);
}
static void timbuart_tx_chars(struct uart_port *port)
{
unsigned char ch;
while (!(ioread32(port->membase + TIMBUART_ISR) & TXBF) &&
uart_fifo_get(port, &ch))
iowrite8(ch, port->membase + TIMBUART_TXFIFO);
dev_dbg(port->dev,
"%s - total written %d bytes, CTL: %x, RTS: %x, baud: %x\n",
__func__,
port->icount.tx,
ioread8(port->membase + TIMBUART_CTRL),
port->mctrl & TIOCM_RTS,
ioread8(port->membase + TIMBUART_BAUDRATE));
}
static void timbuart_handle_tx_port(struct uart_port *port, u32 isr, u32 *ier)
Annotation
- Immediate include surface: `linux/pci.h`, `linux/interrupt.h`, `linux/serial_core.h`, `linux/tty.h`, `linux/tty_flip.h`, `linux/kernel.h`, `linux/platform_device.h`, `linux/ioport.h`.
- Detected declarations: `struct timbuart_port`, `function timbuart_stop_rx`, `function timbuart_stop_tx`, `function timbuart_start_tx`, `function timbuart_tx_empty`, `function timbuart_flush_buffer`, `function timbuart_rx_chars`, `function timbuart_tx_chars`, `function timbuart_handle_tx_port`, `function timbuart_handle_rx_port`.
- 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.