drivers/input/keyboard/tm2-touchkey.c
Source file repositories/reference/linux-study-clean/drivers/input/keyboard/tm2-touchkey.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/keyboard/tm2-touchkey.c- Extension
.c- Size
- 9672 bytes
- Lines
- 367
- 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/bitops.hlinux/delay.hlinux/device.hlinux/i2c.hlinux/input.hlinux/interrupt.hlinux/irq.hlinux/leds.hlinux/module.hlinux/of.hlinux/pm.hlinux/regulator/consumer.h
Detected Declarations
struct touchkey_variantstruct tm2_touchkey_datafunction tm2_touchkey_led_brightness_setfunction tm2_touchkey_power_enablefunction tm2_touchkey_power_disablefunction tm2_touchkey_irq_handlerfunction tm2_touchkey_probefunction tm2_touchkey_suspendfunction tm2_touchkey_resume
Annotated Snippet
struct touchkey_variant {
u8 keycode_reg;
u8 base_reg;
u8 cmd_led_on;
u8 cmd_led_off;
bool no_reg;
bool fixed_regulator;
};
struct tm2_touchkey_data {
struct i2c_client *client;
struct input_dev *input_dev;
struct led_classdev led_dev;
struct regulator *vdd;
struct regulator_bulk_data regulators[3];
const struct touchkey_variant *variant;
u32 keycodes[4];
int num_keycodes;
};
static const struct touchkey_variant tm2_touchkey_variant = {
.keycode_reg = 0x03,
.base_reg = 0x00,
.cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON,
.cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF,
};
static const struct touchkey_variant midas_touchkey_variant = {
.keycode_reg = 0x00,
.base_reg = 0x00,
.cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON,
.cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF,
};
static struct touchkey_variant aries_touchkey_variant = {
.no_reg = true,
.fixed_regulator = true,
.cmd_led_on = ARIES_TOUCHKEY_CMD_LED_ON,
.cmd_led_off = ARIES_TOUCHKEY_CMD_LED_OFF,
};
static const struct touchkey_variant tc360_touchkey_variant = {
.keycode_reg = 0x00,
.base_reg = 0x00,
.fixed_regulator = true,
.cmd_led_on = TM2_TOUCHKEY_CMD_LED_ON,
.cmd_led_off = TM2_TOUCHKEY_CMD_LED_OFF,
};
static int tm2_touchkey_led_brightness_set(struct led_classdev *led_dev,
enum led_brightness brightness)
{
struct tm2_touchkey_data *touchkey =
container_of(led_dev, struct tm2_touchkey_data, led_dev);
u32 volt;
u8 data;
if (brightness == LED_OFF) {
volt = TM2_TOUCHKEY_LED_VOLTAGE_MIN;
data = touchkey->variant->cmd_led_off;
} else {
volt = TM2_TOUCHKEY_LED_VOLTAGE_MAX;
data = touchkey->variant->cmd_led_on;
}
if (!touchkey->variant->fixed_regulator)
regulator_set_voltage(touchkey->vdd, volt, volt);
return touchkey->variant->no_reg ?
i2c_smbus_write_byte(touchkey->client, data) :
i2c_smbus_write_byte_data(touchkey->client,
touchkey->variant->base_reg, data);
}
static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey)
{
int error;
error = regulator_bulk_enable(ARRAY_SIZE(touchkey->regulators),
touchkey->regulators);
if (error)
return error;
/* waiting for device initialization, at least 150ms */
msleep(150);
return 0;
}
static void tm2_touchkey_power_disable(void *data)
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/delay.h`, `linux/device.h`, `linux/i2c.h`, `linux/input.h`, `linux/interrupt.h`, `linux/irq.h`, `linux/leds.h`.
- Detected declarations: `struct touchkey_variant`, `struct tm2_touchkey_data`, `function tm2_touchkey_led_brightness_set`, `function tm2_touchkey_power_enable`, `function tm2_touchkey_power_disable`, `function tm2_touchkey_irq_handler`, `function tm2_touchkey_probe`, `function tm2_touchkey_suspend`, `function tm2_touchkey_resume`.
- 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.