drivers/input/keyboard/tegra-kbc.c
Source file repositories/reference/linux-study-clean/drivers/input/keyboard/tegra-kbc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/keyboard/tegra-kbc.c- Extension
.c- Size
- 20224 bytes
- Lines
- 791
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/kernel.hlinux/module.hlinux/input.hlinux/platform_device.hlinux/delay.hlinux/io.hlinux/interrupt.hlinux/of.hlinux/property.hlinux/clk.hlinux/slab.hlinux/input/matrix_keypad.hlinux/reset.hlinux/err.h
Detected Declarations
struct tegra_kbc_hw_supportstruct tegra_kbc_pin_cfgstruct tegra_kbcenum tegra_pin_typefunction tegra_kbc_report_released_keysfunction tegra_kbc_report_pressed_keysfunction tegra_kbc_report_keysfunction tegra_kbc_set_fifo_interruptfunction tegra_kbc_keypress_timerfunction tegra_kbc_isrfunction tegra_kbc_setup_wakekeysfunction tegra_kbc_config_pinsfunction tegra_kbc_startfunction tegra_kbc_stopfunction scoped_guardfunction tegra_kbc_openfunction tegra_kbc_closefunction tegra_kbc_check_pin_cfgfunction tegra_kbc_parse_dtfunction tegra_kbc_probefunction tegra_kbc_set_keypress_interruptfunction tegra_kbc_suspendfunction tegra_kbc_resume
Annotated Snippet
struct tegra_kbc_hw_support {
int max_rows;
int max_columns;
};
struct tegra_kbc_pin_cfg {
enum tegra_pin_type type;
unsigned char num;
};
struct tegra_kbc {
struct device *dev;
unsigned int debounce_cnt;
unsigned int repeat_cnt;
struct tegra_kbc_pin_cfg pin_cfg[KBC_MAX_GPIO];
const struct matrix_keymap_data *keymap_data;
bool wakeup;
void __iomem *mmio;
struct input_dev *idev;
int irq;
spinlock_t lock;
unsigned int repoll_dly;
unsigned long cp_dly_jiffies;
unsigned int cp_to_wkup_dly;
bool use_fn_map;
bool use_ghost_filter;
bool keypress_caused_wake;
unsigned short keycode[KBC_MAX_KEY * 2];
unsigned short current_keys[KBC_MAX_KPENT];
unsigned int num_pressed_keys;
u32 wakeup_key;
struct timer_list timer;
struct clk *clk;
struct reset_control *rst;
const struct tegra_kbc_hw_support *hw_support;
int max_keys;
int num_rows_and_columns;
};
static void tegra_kbc_report_released_keys(struct input_dev *input,
unsigned short old_keycodes[],
unsigned int old_num_keys,
unsigned short new_keycodes[],
unsigned int new_num_keys)
{
unsigned int i, j;
for (i = 0; i < old_num_keys; i++) {
for (j = 0; j < new_num_keys; j++)
if (old_keycodes[i] == new_keycodes[j])
break;
if (j == new_num_keys)
input_report_key(input, old_keycodes[i], 0);
}
}
static void tegra_kbc_report_pressed_keys(struct input_dev *input,
unsigned char scancodes[],
unsigned short keycodes[],
unsigned int num_pressed_keys)
{
unsigned int i;
for (i = 0; i < num_pressed_keys; i++) {
input_event(input, EV_MSC, MSC_SCAN, scancodes[i]);
input_report_key(input, keycodes[i], 1);
}
}
static void tegra_kbc_report_keys(struct tegra_kbc *kbc)
{
unsigned char scancodes[KBC_MAX_KPENT];
unsigned short keycodes[KBC_MAX_KPENT];
u32 val = 0;
unsigned int i;
unsigned int num_down = 0;
bool fn_keypress = false;
bool key_in_same_row = false;
bool key_in_same_col = false;
for (i = 0; i < KBC_MAX_KPENT; i++) {
if ((i % 4) == 0)
val = readl(kbc->mmio + KBC_KP_ENT0_0 + i);
if (val & 0x80) {
unsigned int col = val & 0x07;
unsigned int row = (val >> 3) & 0x0f;
unsigned char scancode =
MATRIX_SCAN_CODE(row, col, KBC_ROW_SHIFT);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/input.h`, `linux/platform_device.h`, `linux/delay.h`, `linux/io.h`, `linux/interrupt.h`, `linux/of.h`.
- Detected declarations: `struct tegra_kbc_hw_support`, `struct tegra_kbc_pin_cfg`, `struct tegra_kbc`, `enum tegra_pin_type`, `function tegra_kbc_report_released_keys`, `function tegra_kbc_report_pressed_keys`, `function tegra_kbc_report_keys`, `function tegra_kbc_set_fifo_interrupt`, `function tegra_kbc_keypress_timer`, `function tegra_kbc_isr`.
- Atlas domain: Driver Families / drivers/input.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.