drivers/tty/serial/samsung_tty.c
Source file repositories/reference/linux-study-clean/drivers/tty/serial/samsung_tty.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/serial/samsung_tty.c- Extension
.c- Size
- 72319 bytes
- Lines
- 2858
- Domain
- Driver Families
- Bucket
- drivers/tty
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/console.hlinux/clk.hlinux/cpufreq.hlinux/delay.hlinux/dma-mapping.hlinux/dmaengine.hlinux/init.hlinux/io.hlinux/ioport.hlinux/math.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/serial.hlinux/serial_core.hlinux/serial_s3c.hlinux/slab.hlinux/sysrq.hlinux/tty.hlinux/tty_flip.hlinux/types.hasm/irq.h
Detected Declarations
struct s3c24xx_uart_infostruct s3c24xx_serial_drv_datastruct s3c24xx_uart_dmastruct s3c24xx_uart_portstruct samsung_early_console_dataenum s3c24xx_port_typefunction rd_regfunction wr_regfunction s3c24xx_set_bitfunction s3c24xx_clear_bitfunction s3c24xx_serial_txempty_nofifofunction s3c24xx_serial_rx_enablefunction s3c24xx_serial_rx_disablefunction s3c24xx_serial_stop_txfunction s3c24xx_serial_tx_dma_completefunction enable_tx_dmafunction enable_tx_piofunction s3c24xx_serial_start_tx_piofunction s3c24xx_serial_start_tx_dmafunction s3c24xx_serial_start_next_txfunction s3c24xx_serial_start_txfunction s3c24xx_uart_copy_rx_to_ttyfunction s3c24xx_serial_stop_rxfunction s3c24xx_serial_rx_fifocntfunction s3c24xx_serial_rx_dma_completefunction s3c64xx_start_rx_dmafunction enable_rx_dmafunction enable_rx_piofunction s3c24xx_serial_rx_chars_dmafunction s3c24xx_serial_rx_drain_fifofunction s3c24xx_serial_rx_chars_piofunction s3c24xx_serial_rx_irqfunction s3c24xx_serial_tx_charsfunction s3c24xx_serial_tx_irqfunction s3c64xx_serial_handle_irqfunction apple_serial_handle_irqfunction s3c24xx_serial_tx_emptyfunction s3c24xx_serial_get_mctrlfunction s3c24xx_serial_set_mctrlfunction s3c24xx_serial_break_ctlfunction s3c24xx_serial_request_dmafunction s3c24xx_serial_release_dmafunction s3c64xx_serial_shutdownfunction apple_s5l_serial_shutdownfunction s3c64xx_serial_startupfunction apple_s5l_serial_startupfunction s3c24xx_serial_pmfunction clock
Annotated Snippet
module_init(samsung_serial_init);
module_exit(samsung_serial_exit);
#ifdef CONFIG_SERIAL_SAMSUNG_CONSOLE
/*
* Early console.
*/
static void wr_reg_barrier(const struct uart_port *port, u32 reg, u32 val)
{
switch (port->iotype) {
case UPIO_MEM:
writeb(val, portaddr(port, reg));
break;
case UPIO_MEM32:
writel(val, portaddr(port, reg));
break;
default:
break;
}
}
struct samsung_early_console_data {
u32 txfull_mask;
u32 rxfifo_mask;
};
static void samsung_early_busyuart(const struct uart_port *port)
{
while (!(readl(port->membase + S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXFE))
;
}
static void samsung_early_busyuart_fifo(const struct uart_port *port)
{
const struct samsung_early_console_data *data = port->private_data;
while (readl(port->membase + S3C2410_UFSTAT) & data->txfull_mask)
;
}
static void samsung_early_putc(struct uart_port *port, unsigned char c)
{
if (readl(port->membase + S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE)
samsung_early_busyuart_fifo(port);
else
samsung_early_busyuart(port);
wr_reg_barrier(port, S3C2410_UTXH, c);
}
static void samsung_early_write(struct console *con, const char *s,
unsigned int n)
{
struct earlycon_device *dev = con->data;
uart_console_write(&dev->port, s, n, samsung_early_putc);
}
static int samsung_early_read(struct console *con, char *s, unsigned int n)
{
struct earlycon_device *dev = con->data;
const struct samsung_early_console_data *data = dev->port.private_data;
int num_read = 0;
u32 ch, ufstat;
while (num_read < n) {
ufstat = rd_regl(&dev->port, S3C2410_UFSTAT);
if (!(ufstat & data->rxfifo_mask))
break;
ch = rd_reg(&dev->port, S3C2410_URXH);
if (ch == NO_POLL_CHAR)
break;
s[num_read++] = ch;
}
return num_read;
}
static int __init samsung_early_console_setup(struct earlycon_device *device,
const char *opt)
{
if (!device->port.membase)
return -ENODEV;
device->con->write = samsung_early_write;
device->con->read = samsung_early_read;
return 0;
}
Annotation
- Immediate include surface: `linux/console.h`, `linux/clk.h`, `linux/cpufreq.h`, `linux/delay.h`, `linux/dma-mapping.h`, `linux/dmaengine.h`, `linux/init.h`, `linux/io.h`.
- Detected declarations: `struct s3c24xx_uart_info`, `struct s3c24xx_serial_drv_data`, `struct s3c24xx_uart_dma`, `struct s3c24xx_uart_port`, `struct samsung_early_console_data`, `enum s3c24xx_port_type`, `function rd_reg`, `function wr_reg`, `function s3c24xx_set_bit`, `function s3c24xx_clear_bit`.
- Atlas domain: Driver Families / drivers/tty.
- Implementation status: integration 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.