drivers/input/misc/pm8941-pwrkey.c
Source file repositories/reference/linux-study-clean/drivers/input/misc/pm8941-pwrkey.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/input/misc/pm8941-pwrkey.c- Extension
.c- Size
- 12526 bytes
- Lines
- 487
- 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/delay.hlinux/errno.hlinux/input.hlinux/interrupt.hlinux/kernel.hlinux/ktime.hlinux/log2.hlinux/module.hlinux/of.hlinux/of_address.hlinux/platform_device.hlinux/reboot.hlinux/regmap.h
Detected Declarations
struct pm8941_datastruct pm8941_pwrkeyfunction pm8941_reboot_notifyfunction pm8941_pwrkey_irqfunction pm8941_pwrkey_sw_debounce_initfunction pm8941_pwrkey_suspendfunction pm8941_pwrkey_resumefunction pm8941_pwrkey_probefunction pm8941_pwrkey_remove
Annotated Snippet
struct pm8941_data {
unsigned int pull_up_bit;
unsigned int status_bit;
bool supports_ps_hold_poff_config;
bool supports_debounce_config;
bool has_pon_pbs;
bool wakeup_source_default;
const char *name;
const char *phys;
};
struct pm8941_pwrkey {
struct device *dev;
int irq;
u32 baseaddr;
u32 pon_pbs_baseaddr;
struct regmap *regmap;
struct input_dev *input;
unsigned int revision;
unsigned int subtype;
struct notifier_block reboot_notifier;
u32 code;
u32 sw_debounce_time_us;
ktime_t sw_debounce_end_time;
bool last_status;
const struct pm8941_data *data;
};
static int pm8941_reboot_notify(struct notifier_block *nb,
unsigned long code, void *unused)
{
struct pm8941_pwrkey *pwrkey = container_of(nb, struct pm8941_pwrkey,
reboot_notifier);
unsigned int enable_reg;
unsigned int reset_type;
int error;
/* PMICs with revision 0 have the enable bit in same register as ctrl */
if (pwrkey->revision == 0)
enable_reg = PON_PS_HOLD_RST_CTL;
else
enable_reg = PON_PS_HOLD_RST_CTL2;
error = regmap_update_bits(pwrkey->regmap,
pwrkey->baseaddr + enable_reg,
PON_PS_HOLD_ENABLE,
0);
if (error)
dev_err(pwrkey->dev,
"unable to clear ps hold reset enable: %d\n",
error);
/*
* Updates of PON_PS_HOLD_ENABLE requires 3 sleep cycles between
* writes.
*/
usleep_range(100, 1000);
switch (code) {
case SYS_HALT:
case SYS_POWER_OFF:
reset_type = PON_PS_HOLD_TYPE_SHUTDOWN;
break;
case SYS_RESTART:
default:
if (reboot_mode == REBOOT_WARM)
reset_type = PON_PS_HOLD_TYPE_WARM_RESET;
else
reset_type = PON_PS_HOLD_TYPE_HARD_RESET;
break;
}
error = regmap_update_bits(pwrkey->regmap,
pwrkey->baseaddr + PON_PS_HOLD_RST_CTL,
PON_PS_HOLD_TYPE_MASK,
reset_type);
if (error)
dev_err(pwrkey->dev, "unable to set ps hold reset type: %d\n",
error);
error = regmap_update_bits(pwrkey->regmap,
pwrkey->baseaddr + enable_reg,
PON_PS_HOLD_ENABLE,
PON_PS_HOLD_ENABLE);
if (error)
dev_err(pwrkey->dev, "unable to re-set enable: %d\n", error);
return NOTIFY_DONE;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/errno.h`, `linux/input.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/ktime.h`, `linux/log2.h`, `linux/module.h`.
- Detected declarations: `struct pm8941_data`, `struct pm8941_pwrkey`, `function pm8941_reboot_notify`, `function pm8941_pwrkey_irq`, `function pm8941_pwrkey_sw_debounce_init`, `function pm8941_pwrkey_suspend`, `function pm8941_pwrkey_resume`, `function pm8941_pwrkey_probe`, `function pm8941_pwrkey_remove`.
- 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.