drivers/tty/serial/8250/8250_uniphier.c
Source file repositories/reference/linux-study-clean/drivers/tty/serial/8250/8250_uniphier.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/serial/8250/8250_uniphier.c- Extension
.c- Size
- 7561 bytes
- Lines
- 297
- 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/clk.hlinux/console.hlinux/io.hlinux/module.hlinux/of.hlinux/platform_device.h8250.h
Detected Declarations
struct uniphier8250_privfunction uniphier_early_console_setupfunction uniphier_serial_infunction uniphier_serial_outfunction uniphier_serial_dl_readfunction uniphier_serial_dl_writefunction uniphier_uart_probefunction uniphier_uart_removefunction uniphier_uart_suspendfunction uniphier_uart_resume
Annotated Snippet
struct uniphier8250_priv {
int line;
struct clk *clk;
spinlock_t atomic_write_lock;
};
#ifdef CONFIG_SERIAL_8250_CONSOLE
static int __init uniphier_early_console_setup(struct earlycon_device *device,
const char *options)
{
if (!device->port.membase)
return -ENODEV;
/* This hardware always expects MMIO32 register interface. */
device->port.iotype = UPIO_MEM32;
device->port.regshift = UNIPHIER_UART_REGSHIFT;
/*
* Do not touch the divisor register in early_serial8250_setup();
* we assume it has been initialized by a boot loader.
*/
device->baud = 0;
return early_serial8250_setup(device, options);
}
OF_EARLYCON_DECLARE(uniphier, "socionext,uniphier-uart",
uniphier_early_console_setup);
#endif
/*
* The register map is slightly different from that of 8250.
* IO callbacks must be overridden for correct access to FCR, LCR, MCR and SCR.
*/
static u32 uniphier_serial_in(struct uart_port *p, unsigned int offset)
{
unsigned int valshift = 0;
switch (offset) {
case UART_SCR:
/* No SCR for this hardware. Use CHAR as a scratch register */
valshift = 8;
offset = UNIPHIER_UART_CHAR_FCR;
break;
case UART_LCR:
valshift = 8;
fallthrough;
case UART_MCR:
offset = UNIPHIER_UART_LCR_MCR;
break;
default:
offset <<= UNIPHIER_UART_REGSHIFT;
break;
}
/*
* The return value must be masked with 0xff because some registers
* share the same offset that must be accessed by 32-bit write/read.
* 8 or 16 bit access to this hardware result in unexpected behavior.
*/
return (readl(p->membase + offset) >> valshift) & 0xff;
}
static void uniphier_serial_out(struct uart_port *p, unsigned int offset, u32 value)
{
unsigned int valshift = 0;
bool normal = false;
switch (offset) {
case UART_SCR:
/* No SCR for this hardware. Use CHAR as a scratch register */
valshift = 8;
fallthrough;
case UART_FCR:
offset = UNIPHIER_UART_CHAR_FCR;
break;
case UART_LCR:
valshift = 8;
/* Divisor latch access bit does not exist. */
value &= ~UART_LCR_DLAB;
fallthrough;
case UART_MCR:
offset = UNIPHIER_UART_LCR_MCR;
break;
default:
offset <<= UNIPHIER_UART_REGSHIFT;
normal = true;
break;
}
if (normal) {
Annotation
- Immediate include surface: `linux/clk.h`, `linux/console.h`, `linux/io.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `8250.h`.
- Detected declarations: `struct uniphier8250_priv`, `function uniphier_early_console_setup`, `function uniphier_serial_in`, `function uniphier_serial_out`, `function uniphier_serial_dl_read`, `function uniphier_serial_dl_write`, `function uniphier_uart_probe`, `function uniphier_uart_remove`, `function uniphier_uart_suspend`, `function uniphier_uart_resume`.
- 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.