drivers/input/misc/pf1550-onkey.c
Source file repositories/reference/linux-study-clean/drivers/input/misc/pf1550-onkey.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/misc/pf1550-onkey.c- Extension
.c- Size
- 4964 bytes
- Lines
- 198
- 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/err.hlinux/input.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/mfd/pf1550.hlinux/platform_device.h
Detected Declarations
struct onkey_drv_datafunction pf1550_onkey_irq_handlerfunction pf1550_onkey_probefunction pf1550_onkey_suspendfunction pf1550_onkey_resume
Annotated Snippet
struct onkey_drv_data {
struct device *dev;
const struct pf1550_ddata *pf1550;
bool wakeup;
struct input_dev *input;
};
static irqreturn_t pf1550_onkey_irq_handler(int irq, void *data)
{
struct onkey_drv_data *onkey = data;
struct platform_device *pdev = to_platform_device(onkey->dev);
int i, state, irq_type = -1;
for (i = 0; i < PF1550_ONKEY_IRQ_NR; i++)
if (irq == platform_get_irq(pdev, i))
irq_type = i;
switch (irq_type) {
case PF1550_ONKEY_IRQ_PUSHI:
state = 0;
break;
case PF1550_ONKEY_IRQ_1SI:
case PF1550_ONKEY_IRQ_2SI:
case PF1550_ONKEY_IRQ_3SI:
case PF1550_ONKEY_IRQ_4SI:
case PF1550_ONKEY_IRQ_8SI:
state = 1;
break;
default:
dev_err(onkey->dev, "onkey interrupt: irq %d occurred\n",
irq_type);
return IRQ_HANDLED;
}
input_event(onkey->input, EV_KEY, KEY_POWER, state);
input_sync(onkey->input);
return IRQ_HANDLED;
}
static int pf1550_onkey_probe(struct platform_device *pdev)
{
struct onkey_drv_data *onkey;
struct input_dev *input;
bool key_power = false;
int i, irq, error;
onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL);
if (!onkey)
return -ENOMEM;
onkey->dev = &pdev->dev;
onkey->pf1550 = dev_get_drvdata(pdev->dev.parent);
if (!onkey->pf1550->regmap)
return dev_err_probe(&pdev->dev, -ENODEV,
"failed to get regmap\n");
onkey->wakeup = device_property_read_bool(pdev->dev.parent,
"wakeup-source");
if (device_property_read_bool(pdev->dev.parent,
"nxp,disable-key-power")) {
error = regmap_clear_bits(onkey->pf1550->regmap,
PF1550_PMIC_REG_PWRCTRL1,
PF1550_ONKEY_RST_EN);
if (error)
return dev_err_probe(&pdev->dev, error,
"failed: disable turn system off");
} else {
key_power = true;
}
input = devm_input_allocate_device(&pdev->dev);
if (!input)
return dev_err_probe(&pdev->dev, -ENOMEM,
"failed to allocate the input device\n");
input->name = pdev->name;
input->phys = "pf1550-onkey/input0";
input->id.bustype = BUS_HOST;
if (key_power)
input_set_capability(input, EV_KEY, KEY_POWER);
onkey->input = input;
platform_set_drvdata(pdev, onkey);
for (i = 0; i < PF1550_ONKEY_IRQ_NR; i++) {
irq = platform_get_irq(pdev, i);
Annotation
- Immediate include surface: `linux/err.h`, `linux/input.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/mfd/pf1550.h`, `linux/platform_device.h`.
- Detected declarations: `struct onkey_drv_data`, `function pf1550_onkey_irq_handler`, `function pf1550_onkey_probe`, `function pf1550_onkey_suspend`, `function pf1550_onkey_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.