[PATCH v7 8/9] Input: axp20x-pek: Add AXP192 support
From: Molnár Máté via B4 Relay
Date: Sat Dec 05 2026 - 22:10:15 EST
From: Molnár Máté <matemolnar88@xxxxxxxxx>
The AXP192 has no rising/falling edge interrupts for the power key.
It only raises short-press and long-press events, after the key has
been released. Add an axp192-pek variant that reports each of those as
a complete press, so userspace sees a normal KEY_POWER press/release.
Set the variant info before the input device is registered, as the
interrupt handler now uses it.
Signed-off-by: Molnár Máté <matemolnar88@xxxxxxxxx>
---
drivers/input/misc/axp20x-pek.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index a02cdabcf..739da57ca 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -35,6 +35,11 @@ struct axp20x_info {
unsigned int startup_mask;
const struct axp20x_time *shutdown_time;
unsigned int shutdown_mask;
+ /*
+ * The PMIC only reports short and long presses after the button is
+ * released, not the edges, so each event is a complete press.
+ */
+ bool press_events_only;
};
struct axp20x_pek {
@@ -78,6 +83,14 @@ static const struct axp20x_info axp20x_info = {
.shutdown_mask = AXP20X_PEK_SHUTDOWN_MASK,
};
+static const struct axp20x_info axp192_info = {
+ .startup_time = startup_time,
+ .startup_mask = AXP20X_PEK_STARTUP_MASK,
+ .shutdown_time = shutdown_time,
+ .shutdown_mask = AXP20X_PEK_SHUTDOWN_MASK,
+ .press_events_only = true,
+};
+
static const struct axp20x_info axp221_info = {
.startup_time = axp221_startup_time,
.startup_mask = AXP20X_PEK_STARTUP_MASK,
@@ -200,6 +213,15 @@ static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
struct input_dev *idev = pwr;
struct axp20x_pek *axp20x_pek = input_get_drvdata(idev);
+ if (axp20x_pek->info->press_events_only) {
+ input_report_key(idev, KEY_POWER, true);
+ input_sync(idev);
+ input_report_key(idev, KEY_POWER, false);
+ input_sync(idev);
+
+ return IRQ_HANDLED;
+ }
+
/*
* The power-button is connected to ground so a falling edge (dbf)
* means it is pressed.
@@ -311,6 +333,7 @@ static int axp20x_pek_probe(struct platform_device *pdev)
return -ENOMEM;
axp20x_pek->axp20x = dev_get_drvdata(pdev->dev.parent);
+ axp20x_pek->info = (struct axp20x_info *)match->driver_data;
if (axp20x_pek_should_register_input(axp20x_pek)) {
error = axp20x_pek_probe_input_device(axp20x_pek, pdev);
@@ -318,8 +341,6 @@ static int axp20x_pek_probe(struct platform_device *pdev)
return error;
}
- axp20x_pek->info = (struct axp20x_info *)match->driver_data;
-
platform_set_drvdata(pdev, axp20x_pek);
return 0;
@@ -393,6 +414,10 @@ static const struct platform_device_id axp_pek_id_match[] = {
.name = "axp20x-pek",
.driver_data = (kernel_ulong_t)&axp20x_info,
},
+ {
+ .name = "axp192-pek",
+ .driver_data = (kernel_ulong_t)&axp192_info,
+ },
{
.name = "axp221-pek",
.driver_data = (kernel_ulong_t)&axp221_info,
--
2.43.0