drivers/input/misc/tps65218-pwrbutton.c
Source file repositories/reference/linux-study-clean/drivers/input/misc/tps65218-pwrbutton.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/misc/tps65218-pwrbutton.c- Extension
.c- Size
- 3868 bytes
- Lines
- 161
- 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/init.hlinux/input.hlinux/interrupt.hlinux/kernel.hlinux/mfd/tps65217.hlinux/mfd/tps65218.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/slab.h
Detected Declarations
struct tps6521x_datastruct tps6521x_pwrbuttonfunction tps6521x_pb_irqfunction tps6521x_pb_probe
Annotated Snippet
struct tps6521x_data {
unsigned int reg_status;
unsigned int pb_mask;
const char *name;
};
static const struct tps6521x_data tps65217_data = {
.reg_status = TPS65217_REG_STATUS,
.pb_mask = TPS65217_STATUS_PB,
.name = "tps65217_pwrbutton",
};
static const struct tps6521x_data tps65218_data = {
.reg_status = TPS65218_REG_STATUS,
.pb_mask = TPS65218_STATUS_PB_STATE,
.name = "tps65218_pwrbutton",
};
struct tps6521x_pwrbutton {
struct device *dev;
struct regmap *regmap;
struct input_dev *idev;
const struct tps6521x_data *data;
char phys[32];
};
static const struct of_device_id of_tps6521x_pb_match[] = {
{ .compatible = "ti,tps65217-pwrbutton", .data = &tps65217_data },
{ .compatible = "ti,tps65218-pwrbutton", .data = &tps65218_data },
{ },
};
MODULE_DEVICE_TABLE(of, of_tps6521x_pb_match);
static irqreturn_t tps6521x_pb_irq(int irq, void *_pwr)
{
struct tps6521x_pwrbutton *pwr = _pwr;
const struct tps6521x_data *tps_data = pwr->data;
unsigned int reg;
int error;
error = regmap_read(pwr->regmap, tps_data->reg_status, ®);
if (error) {
dev_err(pwr->dev, "can't read register: %d\n", error);
goto out;
}
if (reg & tps_data->pb_mask) {
input_report_key(pwr->idev, KEY_POWER, 1);
pm_wakeup_event(pwr->dev, 0);
} else {
input_report_key(pwr->idev, KEY_POWER, 0);
}
input_sync(pwr->idev);
out:
return IRQ_HANDLED;
}
static int tps6521x_pb_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct tps6521x_pwrbutton *pwr;
struct input_dev *idev;
const struct of_device_id *match;
int error;
int irq;
match = of_match_node(of_tps6521x_pb_match, dev->of_node);
if (!match)
return -ENXIO;
pwr = devm_kzalloc(dev, sizeof(*pwr), GFP_KERNEL);
if (!pwr)
return -ENOMEM;
pwr->data = match->data;
idev = devm_input_allocate_device(dev);
if (!idev)
return -ENOMEM;
idev->name = pwr->data->name;
snprintf(pwr->phys, sizeof(pwr->phys), "%s/input0",
pwr->data->name);
idev->phys = pwr->phys;
idev->dev.parent = dev;
idev->id.bustype = BUS_I2C;
input_set_capability(idev, EV_KEY, KEY_POWER);
Annotation
- Immediate include surface: `linux/init.h`, `linux/input.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/mfd/tps65217.h`, `linux/mfd/tps65218.h`, `linux/module.h`, `linux/of.h`.
- Detected declarations: `struct tps6521x_data`, `struct tps6521x_pwrbutton`, `function tps6521x_pb_irq`, `function tps6521x_pb_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.