drivers/input/keyboard/adp5588-keys.c
Source file repositories/reference/linux-study-clean/drivers/input/keyboard/adp5588-keys.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/keyboard/adp5588-keys.c- Extension
.c- Size
- 24201 bytes
- Lines
- 874
- 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/bits.hlinux/delay.hlinux/errno.hlinux/gpio/consumer.hlinux/gpio/driver.hlinux/i2c.hlinux/input.hlinux/input/matrix_keypad.hlinux/interrupt.hlinux/irq.hlinux/ktime.hlinux/module.hlinux/mod_devicetable.hlinux/pinctrl/pinconf-generic.hlinux/platform_device.hlinux/pm.hlinux/regulator/consumer.hlinux/slab.hlinux/timekeeping.h
Detected Declarations
struct adp5588_kpadfunction adp5588_readfunction adp5588_writefunction adp5588_gpio_get_valuefunction adp5588_gpio_set_valuefunction adp5588_gpio_set_configfunction adp5588_gpio_direction_inputfunction adp5588_gpio_direction_outputfunction adp5588_build_gpiomapfunction adp5588_irq_bus_lockfunction adp5588_irq_bus_sync_unlockfunction adp5588_irq_maskfunction adp5588_irq_unmaskfunction adp5588_irq_set_typefunction adp5588_gpio_addfunction adp5588_gpiomap_get_hwirqfunction adp5588_gpio_irq_handlefunction adp5588_report_eventsfunction adp5588_hard_irqfunction adp5588_thread_irqfunction adp5588_setupfunction adp5588_fw_parsefunction possiblefunction adp5588_probefunction adp5588_removefunction adp5588_suspendfunction adp5588_resume
Annotated Snippet
struct adp5588_kpad {
struct i2c_client *client;
struct input_dev *input;
ktime_t irq_time;
unsigned long delay;
u32 row_shift;
u32 rows;
u32 cols;
u32 unlock_keys[2];
int nkeys_unlock;
bool gpio_only;
unsigned short keycode[ADP5588_KEYMAPSIZE];
unsigned char gpiomap[ADP5588_MAXGPIO];
struct gpio_chip gc;
struct mutex gpio_lock; /* Protect cached dir, dat_out */
u8 dat_out[3];
u8 dir[3];
u8 int_en[3];
u8 irq_mask[3];
u8 pull_dis[3];
};
static int adp5588_read(struct i2c_client *client, u8 reg)
{
int ret = i2c_smbus_read_byte_data(client, reg);
if (ret < 0)
dev_err(&client->dev, "Read Error\n");
return ret;
}
static int adp5588_write(struct i2c_client *client, u8 reg, u8 val)
{
return i2c_smbus_write_byte_data(client, reg, val);
}
static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned int off)
{
struct adp5588_kpad *kpad = gpiochip_get_data(chip);
unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
int val;
guard(mutex)(&kpad->gpio_lock);
if (kpad->dir[bank] & bit)
val = kpad->dat_out[bank];
else
val = adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank);
return !!(val & bit);
}
static int adp5588_gpio_set_value(struct gpio_chip *chip, unsigned int off,
int val)
{
struct adp5588_kpad *kpad = gpiochip_get_data(chip);
unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
guard(mutex)(&kpad->gpio_lock);
if (val)
kpad->dat_out[bank] |= bit;
else
kpad->dat_out[bank] &= ~bit;
return adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank,
kpad->dat_out[bank]);
}
static int adp5588_gpio_set_config(struct gpio_chip *chip, unsigned int off,
unsigned long config)
{
struct adp5588_kpad *kpad = gpiochip_get_data(chip);
unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
bool pull_disable;
switch (pinconf_to_config_param(config)) {
case PIN_CONFIG_BIAS_PULL_UP:
pull_disable = false;
break;
case PIN_CONFIG_BIAS_DISABLE:
pull_disable = true;
break;
default:
return -ENOTSUPP;
}
Annotation
- Immediate include surface: `linux/bits.h`, `linux/delay.h`, `linux/errno.h`, `linux/gpio/consumer.h`, `linux/gpio/driver.h`, `linux/i2c.h`, `linux/input.h`, `linux/input/matrix_keypad.h`.
- Detected declarations: `struct adp5588_kpad`, `function adp5588_read`, `function adp5588_write`, `function adp5588_gpio_get_value`, `function adp5588_gpio_set_value`, `function adp5588_gpio_set_config`, `function adp5588_gpio_direction_input`, `function adp5588_gpio_direction_output`, `function adp5588_build_gpiomap`, `function adp5588_irq_bus_lock`.
- 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.