drivers/input/keyboard/tc3589x-keypad.c
Source file repositories/reference/linux-study-clean/drivers/input/keyboard/tc3589x-keypad.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/keyboard/tc3589x-keypad.c- Extension
.c- Size
- 13513 bytes
- Lines
- 510
- 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/input.hlinux/platform_device.hlinux/input/matrix_keypad.hlinux/i2c.hlinux/slab.hlinux/mfd/tc3589x.hlinux/device.h
Detected Declarations
struct tc3589x_keypad_platform_datastruct tc_keypadfunction tc3589x_keypad_init_key_hardwarefunction tc3589x_keypad_irqfunction tc3589x_keypad_enablefunction tc3589x_keypad_disablefunction tc3589x_keypad_openfunction tc3589x_keypad_closefunction tc3589x_keypad_of_probefunction tc3589x_keypad_probefunction tc3589x_keypad_suspendfunction tc3589x_keypad_resume
Annotated Snippet
struct tc3589x_keypad_platform_data {
const struct matrix_keymap_data *keymap_data;
u8 krow;
u8 kcol;
u8 debounce_period;
u8 settle_time;
unsigned long irqtype;
bool enable_wakeup;
bool no_autorepeat;
};
/**
* struct tc_keypad - data structure used by keypad driver
* @tc3589x: pointer to tc35893
* @input: pointer to input device object
* @board: keypad platform device
* @krow: number of rows
* @kcol: number of columns
* @keymap: matrix scan code table for keycodes
* @keypad_stopped: holds keypad status
*/
struct tc_keypad {
struct tc3589x *tc3589x;
struct input_dev *input;
const struct tc3589x_keypad_platform_data *board;
unsigned int krow;
unsigned int kcol;
unsigned short *keymap;
bool keypad_stopped;
};
static int tc3589x_keypad_init_key_hardware(struct tc_keypad *keypad)
{
int ret;
struct tc3589x *tc3589x = keypad->tc3589x;
const struct tc3589x_keypad_platform_data *board = keypad->board;
/* validate platform configuration */
if (board->kcol > TC3589x_MAX_KPCOL || board->krow > TC3589x_MAX_KPROW)
return -EINVAL;
/* configure KBDSIZE 4 LSbits for cols and 4 MSbits for rows */
ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSIZE,
(board->krow << KP_ROW_SHIFT) | board->kcol);
if (ret < 0)
return ret;
/* configure dedicated key config, no dedicated key selected */
ret = tc3589x_reg_write(tc3589x, TC3589x_KBCFG_LSB, DEDICATED_KEY_VAL);
if (ret < 0)
return ret;
ret = tc3589x_reg_write(tc3589x, TC3589x_KBCFG_MSB, DEDICATED_KEY_VAL);
if (ret < 0)
return ret;
/* Configure settle time */
ret = tc3589x_reg_write(tc3589x, TC3589x_KBDSETTLE_REG,
board->settle_time);
if (ret < 0)
return ret;
/* Configure debounce time */
ret = tc3589x_reg_write(tc3589x, TC3589x_KBDBOUNCE,
board->debounce_period);
if (ret < 0)
return ret;
/* Start of initialise keypad GPIOs */
ret = tc3589x_set_bits(tc3589x, TC3589x_IOCFG, 0x0, IOCFG_IG);
if (ret < 0)
return ret;
/* Configure pull-up resistors for all row GPIOs */
ret = tc3589x_reg_write(tc3589x, TC3589x_IOPULLCFG0_LSB,
TC3589x_PULLUP_ALL_MASK);
if (ret < 0)
return ret;
ret = tc3589x_reg_write(tc3589x, TC3589x_IOPULLCFG0_MSB,
TC3589x_PULLUP_ALL_MASK);
if (ret < 0)
return ret;
/* Configure pull-up resistors for all column GPIOs */
ret = tc3589x_reg_write(tc3589x, TC3589x_IOPULLCFG1_LSB,
TC3589x_PULLUP_ALL_MASK);
if (ret < 0)
return ret;
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/input.h`, `linux/platform_device.h`, `linux/input/matrix_keypad.h`, `linux/i2c.h`, `linux/slab.h`, `linux/mfd/tc3589x.h`.
- Detected declarations: `struct tc3589x_keypad_platform_data`, `struct tc_keypad`, `function tc3589x_keypad_init_key_hardware`, `function tc3589x_keypad_irq`, `function tc3589x_keypad_enable`, `function tc3589x_keypad_disable`, `function tc3589x_keypad_open`, `function tc3589x_keypad_close`, `function tc3589x_keypad_of_probe`, `function tc3589x_keypad_probe`.
- 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.