drivers/tty/serial/tegra-tcu.c
Source file repositories/reference/linux-study-clean/drivers/tty/serial/tegra-tcu.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/serial/tegra-tcu.c- Extension
.c- Size
- 7266 bytes
- Lines
- 303
- 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.
- 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/console.hlinux/mailbox_client.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/serial.hlinux/serial_core.hlinux/slab.hlinux/tty.hlinux/tty_flip.h
Detected Declarations
struct tegra_tcufunction tegra_tcu_uart_tx_emptyfunction tegra_tcu_uart_set_mctrlfunction tegra_tcu_uart_stop_txfunction tegra_tcu_writefunction tegra_tcu_uart_start_txfunction tegra_tcu_uart_stop_rxfunction tegra_tcu_uart_shutdownfunction tegra_tcu_console_writefunction tegra_tcu_console_setupfunction tegra_tcu_receivefunction tegra_tcu_probefunction tegra_tcu_remove
Annotated Snippet
struct tegra_tcu {
struct uart_driver driver;
#if IS_ENABLED(CONFIG_SERIAL_TEGRA_TCU_CONSOLE)
struct console console;
#endif
struct uart_port port;
struct mbox_client tx_client, rx_client;
struct mbox_chan *tx, *rx;
};
static unsigned int tegra_tcu_uart_tx_empty(struct uart_port *port)
{
return TIOCSER_TEMT;
}
static void tegra_tcu_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
}
static unsigned int tegra_tcu_uart_get_mctrl(struct uart_port *port)
{
return 0;
}
static void tegra_tcu_uart_stop_tx(struct uart_port *port)
{
}
static void tegra_tcu_write_one(struct tegra_tcu *tcu, u32 value,
unsigned int count)
{
void *msg;
value |= TCU_MBOX_NUM_BYTES(count);
msg = (void *)(unsigned long)value;
mbox_send_message(tcu->tx, msg);
mbox_flush(tcu->tx, 1000);
}
static void tegra_tcu_write(struct tegra_tcu *tcu, const char *s,
unsigned int count)
{
unsigned int written = 0, i = 0;
bool insert_nl = false;
u32 value = 0;
while (i < count) {
if (insert_nl) {
value |= TCU_MBOX_BYTE(written++, '\n');
insert_nl = false;
i++;
} else if (s[i] == '\n') {
value |= TCU_MBOX_BYTE(written++, '\r');
insert_nl = true;
} else {
value |= TCU_MBOX_BYTE(written++, s[i++]);
}
if (written == 3) {
tegra_tcu_write_one(tcu, value, 3);
value = written = 0;
}
}
if (written)
tegra_tcu_write_one(tcu, value, written);
}
static void tegra_tcu_uart_start_tx(struct uart_port *port)
{
struct tegra_tcu *tcu = port->private_data;
struct tty_port *tport = &port->state->port;
unsigned char *tail;
unsigned int count;
for (;;) {
count = kfifo_out_linear_ptr(&tport->xmit_fifo, &tail,
UART_XMIT_SIZE);
if (!count)
break;
tegra_tcu_write(tcu, tail, count);
uart_xmit_advance(port, count);
}
uart_write_wakeup(port);
}
static void tegra_tcu_uart_stop_rx(struct uart_port *port)
Annotation
- Immediate include surface: `linux/console.h`, `linux/mailbox_client.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/serial.h`, `linux/serial_core.h`, `linux/slab.h`.
- Detected declarations: `struct tegra_tcu`, `function tegra_tcu_uart_tx_empty`, `function tegra_tcu_uart_set_mctrl`, `function tegra_tcu_uart_stop_tx`, `function tegra_tcu_write`, `function tegra_tcu_uart_start_tx`, `function tegra_tcu_uart_stop_rx`, `function tegra_tcu_uart_shutdown`, `function tegra_tcu_console_write`, `function tegra_tcu_console_setup`.
- 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.
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.