drivers/input/serio/ioc3kbd.c
Source file repositories/reference/linux-study-clean/drivers/input/serio/ioc3kbd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/serio/ioc3kbd.c- Extension
.c- Size
- 4767 bytes
- Lines
- 222
- Domain
- Driver Families
- Bucket
- drivers/input
- 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/delay.hlinux/init.hlinux/io.hlinux/serio.hlinux/module.hlinux/platform_device.hasm/sn/ioc3.h
Detected Declarations
struct ioc3kbd_datafunction ioc3kbd_waitfunction ioc3kbd_writefunction ioc3kbd_startfunction ioc3kbd_stopfunction ioc3aux_writefunction ioc3aux_startfunction ioc3aux_stopfunction ioc3kbd_process_datafunction ioc3kbd_intrfunction ioc3kbd_probefunction ioc3kbd_remove
Annotated Snippet
struct ioc3kbd_data {
struct ioc3_serioregs __iomem *regs;
struct serio *kbd, *aux;
bool kbd_exists, aux_exists;
int irq;
};
static int ioc3kbd_wait(struct ioc3_serioregs __iomem *regs, u32 mask)
{
unsigned long timeout = 0;
while ((readl(®s->km_csr) & mask) && (timeout < 250)) {
udelay(50);
timeout++;
}
return (timeout >= 250) ? -ETIMEDOUT : 0;
}
static int ioc3kbd_write(struct serio *dev, u8 val)
{
struct ioc3kbd_data *d = dev->port_data;
int ret;
ret = ioc3kbd_wait(d->regs, KM_CSR_K_WRT_PEND);
if (ret)
return ret;
writel(val, &d->regs->k_wd);
return 0;
}
static int ioc3kbd_start(struct serio *dev)
{
struct ioc3kbd_data *d = dev->port_data;
d->kbd_exists = true;
return 0;
}
static void ioc3kbd_stop(struct serio *dev)
{
struct ioc3kbd_data *d = dev->port_data;
d->kbd_exists = false;
}
static int ioc3aux_write(struct serio *dev, u8 val)
{
struct ioc3kbd_data *d = dev->port_data;
int ret;
ret = ioc3kbd_wait(d->regs, KM_CSR_M_WRT_PEND);
if (ret)
return ret;
writel(val, &d->regs->m_wd);
return 0;
}
static int ioc3aux_start(struct serio *dev)
{
struct ioc3kbd_data *d = dev->port_data;
d->aux_exists = true;
return 0;
}
static void ioc3aux_stop(struct serio *dev)
{
struct ioc3kbd_data *d = dev->port_data;
d->aux_exists = false;
}
static void ioc3kbd_process_data(struct serio *dev, u32 data)
{
if (data & KM_RD_VALID_0)
serio_interrupt(dev, (data >> KM_RD_DATA_0_SHIFT) & 0xff, 0);
if (data & KM_RD_VALID_1)
serio_interrupt(dev, (data >> KM_RD_DATA_1_SHIFT) & 0xff, 0);
if (data & KM_RD_VALID_2)
serio_interrupt(dev, (data >> KM_RD_DATA_2_SHIFT) & 0xff, 0);
}
static irqreturn_t ioc3kbd_intr(int itq, void *dev_id)
{
struct ioc3kbd_data *d = dev_id;
u32 data_k, data_m;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/init.h`, `linux/io.h`, `linux/serio.h`, `linux/module.h`, `linux/platform_device.h`, `asm/sn/ioc3.h`.
- Detected declarations: `struct ioc3kbd_data`, `function ioc3kbd_wait`, `function ioc3kbd_write`, `function ioc3kbd_start`, `function ioc3kbd_stop`, `function ioc3aux_write`, `function ioc3aux_start`, `function ioc3aux_stop`, `function ioc3kbd_process_data`, `function ioc3kbd_intr`.
- Atlas domain: Driver Families / drivers/input.
- 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.