drivers/input/keyboard/pxa27x_keypad.c
Source file repositories/reference/linux-study-clean/drivers/input/keyboard/pxa27x_keypad.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/keyboard/pxa27x_keypad.c- Extension
.c- Size
- 18620 bytes
- Lines
- 707
- 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/bits.hlinux/bitfield.hlinux/kernel.hlinux/module.hlinux/interrupt.hlinux/input.hlinux/io.hlinux/device.hlinux/platform_device.hlinux/property.hlinux/clk.hlinux/err.hlinux/input/matrix_keypad.hlinux/slab.hlinux/of.h
Detected Declarations
struct pxa27x_keypad_rotarystruct pxa27x_keypadfunction pxa27x_keypad_matrix_key_parsefunction pxa27x_keypad_direct_key_parsefunction pxa27x_keypad_rotary_parsefunction pxa27x_keypad_parse_propertiesfunction pxa27x_keypad_scan_matrixfunction rotary_deltafunction report_rotary_eventfunction pxa27x_keypad_scan_rotaryfunction pxa27x_keypad_scan_directfunction pxa27x_keypad_irq_handlerfunction pxa27x_keypad_configfunction pxa27x_keypad_openfunction pxa27x_keypad_closefunction pxa27x_keypad_suspendfunction pxa27x_keypad_resumefunction pxa27x_keypad_probe
Annotated Snippet
struct pxa27x_keypad_rotary {
unsigned short *key_codes;
int rel_code;
bool enabled;
};
struct pxa27x_keypad {
struct clk *clk;
struct input_dev *input_dev;
void __iomem *mmio_base;
int irq;
unsigned int matrix_key_rows;
unsigned int matrix_key_cols;
unsigned int row_shift;
unsigned int direct_key_num;
unsigned int direct_key_mask;
bool direct_key_low_active;
/* key debounce interval */
unsigned int debounce_interval;
unsigned short keycodes[MAX_KEYPAD_KEYS];
/* state row bits of each column scan */
u32 matrix_key_state[MAX_MATRIX_KEY_COLS];
u32 direct_key_state;
struct pxa27x_keypad_rotary rotary[MAX_ROTARY_ENCODERS];
};
static int pxa27x_keypad_matrix_key_parse(struct pxa27x_keypad *keypad)
{
struct input_dev *input_dev = keypad->input_dev;
struct device *dev = input_dev->dev.parent;
int error;
error = matrix_keypad_parse_properties(dev, &keypad->matrix_key_rows,
&keypad->matrix_key_cols);
if (error)
return error;
if (keypad->matrix_key_rows > MAX_MATRIX_KEY_ROWS ||
keypad->matrix_key_cols > MAX_MATRIX_KEY_COLS) {
dev_err(dev, "rows or cols exceeds maximum value\n");
return -EINVAL;
}
keypad->row_shift = get_count_order(keypad->matrix_key_cols);
error = matrix_keypad_build_keymap(NULL, NULL,
keypad->matrix_key_rows,
keypad->matrix_key_cols,
keypad->keycodes, input_dev);
if (error)
return error;
return 0;
}
static int pxa27x_keypad_direct_key_parse(struct pxa27x_keypad *keypad)
{
struct input_dev *input_dev = keypad->input_dev;
struct device *dev = input_dev->dev.parent;
unsigned short code;
int count;
int i;
int error;
error = device_property_read_u32(dev, "marvell,direct-key-count",
&keypad->direct_key_num);
if (error) {
/*
* If do not have marvel,direct-key-count defined,
* it means direct key is not supported.
*/
return error == -EINVAL ? 0 : error;
}
error = device_property_read_u32(dev, "marvell,direct-key-mask",
&keypad->direct_key_mask);
if (error) {
if (error != -EINVAL)
return error;
/*
* If marvell,direct-key-mask is not defined, driver will use
* a default value based on number of direct keys set up.
Annotation
- Immediate include surface: `linux/bits.h`, `linux/bitfield.h`, `linux/kernel.h`, `linux/module.h`, `linux/interrupt.h`, `linux/input.h`, `linux/io.h`, `linux/device.h`.
- Detected declarations: `struct pxa27x_keypad_rotary`, `struct pxa27x_keypad`, `function pxa27x_keypad_matrix_key_parse`, `function pxa27x_keypad_direct_key_parse`, `function pxa27x_keypad_rotary_parse`, `function pxa27x_keypad_parse_properties`, `function pxa27x_keypad_scan_matrix`, `function rotary_delta`, `function report_rotary_event`, `function pxa27x_keypad_scan_rotary`.
- 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.