drivers/input/keyboard/omap4-keypad.c
Source file repositories/reference/linux-study-clean/drivers/input/keyboard/omap4-keypad.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/keyboard/omap4-keypad.c- Extension
.c- Size
- 12824 bytes
- Lines
- 497
- 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/module.hlinux/interrupt.hlinux/platform_device.hlinux/clk.hlinux/errno.hlinux/io.hlinux/of.hlinux/input.hlinux/input/matrix_keypad.hlinux/slab.hlinux/pm_runtime.hlinux/pm_wakeirq.h
Detected Declarations
struct omap4_keypadfunction kbd_readlfunction kbd_writelfunction kbd_read_irqregfunction kbd_write_irqregfunction omap4_keypad_report_keysfunction for_each_set_bitfunction omap4_keypad_scan_keysfunction omap4_keypad_irq_handlerfunction omap4_keypad_irq_thread_fnfunction omap4_keypad_openfunction omap4_keypad_stopfunction omap4_keypad_closefunction omap4_keypad_parse_dtfunction omap4_keypad_check_revisionfunction omap4_keypad_runtime_suspendfunction omap4_disable_pmfunction omap4_keypad_probefunction omap4_keypad_remove
Annotated Snippet
struct omap4_keypad {
struct input_dev *input;
void __iomem *base;
unsigned int irq;
struct mutex lock; /* for key scan */
unsigned int rows;
unsigned int cols;
u32 reg_offset;
u32 irqreg_offset;
unsigned int row_shift;
bool no_autorepeat;
u64 keys;
unsigned short *keymap;
struct clk *fck;
};
static int kbd_readl(struct omap4_keypad *keypad_data, u32 offset)
{
return __raw_readl(keypad_data->base +
keypad_data->reg_offset + offset);
}
static void kbd_writel(struct omap4_keypad *keypad_data, u32 offset, u32 value)
{
__raw_writel(value,
keypad_data->base + keypad_data->reg_offset + offset);
}
static int kbd_read_irqreg(struct omap4_keypad *keypad_data, u32 offset)
{
return __raw_readl(keypad_data->base +
keypad_data->irqreg_offset + offset);
}
static void kbd_write_irqreg(struct omap4_keypad *keypad_data,
u32 offset, u32 value)
{
__raw_writel(value,
keypad_data->base + keypad_data->irqreg_offset + offset);
}
static int omap4_keypad_report_keys(struct omap4_keypad *keypad_data,
u64 keys, bool down)
{
struct input_dev *input_dev = keypad_data->input;
unsigned int col, row, code;
DECLARE_BITMAP(mask, 64);
unsigned long bit;
int events = 0;
bitmap_from_u64(mask, keys);
for_each_set_bit(bit, mask, keypad_data->rows * BITS_PER_BYTE) {
row = bit / BITS_PER_BYTE;
col = bit % BITS_PER_BYTE;
code = MATRIX_SCAN_CODE(row, col, keypad_data->row_shift);
input_event(input_dev, EV_MSC, MSC_SCAN, code);
input_report_key(input_dev, keypad_data->keymap[code], down);
events++;
}
if (events)
input_sync(input_dev);
return events;
}
static void omap4_keypad_scan_keys(struct omap4_keypad *keypad_data, u64 keys)
{
u64 changed;
guard(mutex)(&keypad_data->lock);
changed = keys ^ keypad_data->keys;
/*
* Report key up events separately and first. This matters in case we
* lost key-up interrupt and just now catching up.
*/
omap4_keypad_report_keys(keypad_data, changed & ~keys, false);
/* Report key down events */
omap4_keypad_report_keys(keypad_data, changed & keys, true);
keypad_data->keys = keys;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/platform_device.h`, `linux/clk.h`, `linux/errno.h`, `linux/io.h`, `linux/of.h`, `linux/input.h`.
- Detected declarations: `struct omap4_keypad`, `function kbd_readl`, `function kbd_writel`, `function kbd_read_irqreg`, `function kbd_write_irqreg`, `function omap4_keypad_report_keys`, `function for_each_set_bit`, `function omap4_keypad_scan_keys`, `function omap4_keypad_irq_handler`, `function omap4_keypad_irq_thread_fn`.
- 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.