drivers/input/keyboard/samsung-keypad.c
Source file repositories/reference/linux-study-clean/drivers/input/keyboard/samsung-keypad.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/keyboard/samsung-keypad.c- Extension
.c- Size
- 15005 bytes
- Lines
- 595
- 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/clk.hlinux/delay.hlinux/err.hlinux/input.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/platform_device.hlinux/pm.hlinux/pm_runtime.hlinux/slab.hlinux/of.hlinux/sched.hlinux/input/samsung-keypad.h
Detected Declarations
struct samsung_chip_infostruct samsung_keypadfunction samsung_keypad_scanfunction samsung_keypad_reportfunction samsung_keypad_irqfunction samsung_keypad_startfunction samsung_keypad_stopfunction samsung_keypad_openfunction samsung_keypad_closefunction samsung_keypad_parse_dtfunction for_each_child_of_nodefunction samsung_keypad_parse_dtfunction samsung_keypad_probefunction samsung_keypad_runtime_suspendfunction samsung_keypad_runtime_resumefunction samsung_keypad_toggle_wakeupfunction samsung_keypad_suspendfunction samsung_keypad_resume
Annotated Snippet
struct samsung_chip_info {
unsigned int column_shift;
};
struct samsung_keypad {
const struct samsung_chip_info *chip;
struct input_dev *input_dev;
struct platform_device *pdev;
struct clk *clk;
void __iomem *base;
wait_queue_head_t wait;
bool stopped;
bool wake_enabled;
int irq;
unsigned int row_shift;
unsigned int rows;
unsigned int cols;
unsigned int row_state[SAMSUNG_MAX_COLS];
unsigned short keycodes[];
};
static void samsung_keypad_scan(struct samsung_keypad *keypad,
unsigned int *row_state)
{
unsigned int col;
unsigned int val;
for (col = 0; col < keypad->cols; col++) {
val = SAMSUNG_KEYIFCOL_MASK & ~BIT(col);
val <<= keypad->chip->column_shift;
writel(val, keypad->base + SAMSUNG_KEYIFCOL);
mdelay(1);
val = readl(keypad->base + SAMSUNG_KEYIFROW);
row_state[col] = ~val & GENMASK(keypad->rows - 1, 0);
}
/* KEYIFCOL reg clear */
writel(0, keypad->base + SAMSUNG_KEYIFCOL);
}
static bool samsung_keypad_report(struct samsung_keypad *keypad,
unsigned int *row_state)
{
struct input_dev *input_dev = keypad->input_dev;
unsigned int changed;
unsigned int pressed;
unsigned int key_down = 0;
unsigned int val;
unsigned int col, row;
for (col = 0; col < keypad->cols; col++) {
changed = row_state[col] ^ keypad->row_state[col];
key_down |= row_state[col];
if (!changed)
continue;
for (row = 0; row < keypad->rows; row++) {
if (!(changed & BIT(row)))
continue;
pressed = row_state[col] & BIT(row);
dev_dbg(&keypad->input_dev->dev,
"key %s, row: %d, col: %d\n",
pressed ? "pressed" : "released", row, col);
val = MATRIX_SCAN_CODE(row, col, keypad->row_shift);
input_event(input_dev, EV_MSC, MSC_SCAN, val);
input_report_key(input_dev,
keypad->keycodes[val], pressed);
}
input_sync(keypad->input_dev);
}
memcpy(keypad->row_state, row_state, sizeof(keypad->row_state));
return key_down;
}
static irqreturn_t samsung_keypad_irq(int irq, void *dev_id)
{
struct samsung_keypad *keypad = dev_id;
unsigned int row_state[SAMSUNG_MAX_COLS];
bool key_down;
pm_runtime_get_sync(&keypad->pdev->dev);
Annotation
- Immediate include surface: `linux/bits.h`, `linux/clk.h`, `linux/delay.h`, `linux/err.h`, `linux/input.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`.
- Detected declarations: `struct samsung_chip_info`, `struct samsung_keypad`, `function samsung_keypad_scan`, `function samsung_keypad_report`, `function samsung_keypad_irq`, `function samsung_keypad_start`, `function samsung_keypad_stop`, `function samsung_keypad_open`, `function samsung_keypad_close`, `function samsung_keypad_parse_dt`.
- 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.