drivers/tty/serial/8250/8250_men_mcb.c
Source file repositories/reference/linux-study-clean/drivers/tty/serial/8250/8250_men_mcb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tty/serial/8250/8250_men_mcb.c- Extension
.c- Size
- 6629 bytes
- Lines
- 268
- 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/device.hlinux/kernel.hlinux/module.hlinux/io.hlinux/mcb.hlinux/serial.hlinux/serial_core.hlinux/serial_8250.h
Detected Declarations
struct serial_8250_men_mcb_datafunction men_lookup_uartclkfunction read_uarts_available_from_registerfunction read_serial_datafunction init_serial_datafunction serial_8250_men_mcb_probefunction serial_8250_men_mcb_remove
Annotated Snippet
struct serial_8250_men_mcb_data {
int num_ports;
int line[MEN_Z025_MAX_UARTS];
unsigned int offset[MEN_Z025_MAX_UARTS];
};
/*
* The Z125 16550-compatible UART has no fixed base clock assigned
* So, depending on the board we're on, we need to adjust the
* parameter in order to really set the correct baudrate, and
* do so if possible without user interaction
*/
static u32 men_lookup_uartclk(struct mcb_device *mdev)
{
/* use default value if board is not available below */
u32 clkval = 1041666;
dev_info(&mdev->dev, "%s on board %s\n",
dev_name(&mdev->dev),
mdev->bus->name);
if (strncmp(mdev->bus->name, "F075", 4) == 0)
clkval = 1041666;
else if (strncmp(mdev->bus->name, "F216", 4) == 0)
clkval = 1843200;
else if (strncmp(mdev->bus->name, "F210", 4) == 0)
clkval = 115200;
else if (strstr(mdev->bus->name, "215"))
clkval = 1843200;
else
dev_info(&mdev->dev,
"board not detected, using default uartclk\n");
clkval = clkval << 4;
return clkval;
}
static int read_uarts_available_from_register(struct resource *mem_res,
u8 *uarts_available)
{
void __iomem *mem;
int reg_value;
if (!request_mem_region(mem_res->start + MEN_Z025_REGISTER_OFFSET,
MEM_UART_REGISTER_SIZE, KBUILD_MODNAME)) {
return -EBUSY;
}
mem = ioremap(mem_res->start + MEN_Z025_REGISTER_OFFSET,
MEM_UART_REGISTER_SIZE);
if (!mem) {
release_mem_region(mem_res->start + MEN_Z025_REGISTER_OFFSET,
MEM_UART_REGISTER_SIZE);
return -ENOMEM;
}
reg_value = MEN_READ_REGISTER(mem);
iounmap(mem);
release_mem_region(mem_res->start + MEN_Z025_REGISTER_OFFSET,
MEM_UART_REGISTER_SIZE);
*uarts_available = reg_value >> 4;
return 0;
}
static int read_serial_data(struct mcb_device *mdev,
struct resource *mem_res,
struct serial_8250_men_mcb_data *serial_data)
{
u8 uarts_available;
int count = 0;
int mask;
int res;
int i;
res = read_uarts_available_from_register(mem_res, &uarts_available);
if (res < 0)
return res;
for (i = 0; i < MEN_Z025_MAX_UARTS; i++) {
mask = 0x1 << i;
switch (uarts_available & mask) {
case MEN_UART1_MASK:
serial_data->offset[count] = MEN_UART1_OFFSET;
count++;
break;
case MEN_UART2_MASK:
Annotation
- Immediate include surface: `linux/device.h`, `linux/kernel.h`, `linux/module.h`, `linux/io.h`, `linux/mcb.h`, `linux/serial.h`, `linux/serial_core.h`, `linux/serial_8250.h`.
- Detected declarations: `struct serial_8250_men_mcb_data`, `function men_lookup_uartclk`, `function read_uarts_available_from_register`, `function read_serial_data`, `function init_serial_data`, `function serial_8250_men_mcb_probe`, `function serial_8250_men_mcb_remove`.
- 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.