Skip to content

Commit 9747070

Browse files
jwrdegoededtor
authored andcommitted
Input: axp20x-pek - always register interrupt handlers
On some X86 devices we do not register an input-device, because the power-button is also handled by the soc_button_array (GPIO) input driver, and we want to avoid reporting power-button presses to userspace twice. Sofar when we did this we also did not register our interrupt handlers, since those were only necessary to report input events. But on at least 2 device models the Medion Akoya E1239T and the GPD win, the GPIO pin used by the soc_button_array driver for the power-button cannot wakeup the system from suspend. Why this does not work is not clear, I've tried comparing the value of all relevant registers on the Cherry Trail SoC, with those from models where this does work. I've checked: PMC registers: FUNC_DIS, FUNC_DIS2, SOIX_WAKE_EN, D3_STS_0, D3_STS_1, D3_STDBY_STS_0, D3_STDBY_STS_1; PMC ACPI I/O regs: PM1_STS_EN, GPE0a_EN and they all have identical contents in the working and non working cases. I suspect that the firmware either sets some unknown register to a value causing this, or that it turns off a power-plane which is necessary for GPIO wakeups to work during suspend. What does work on the Medion Akoya E1239T is letting the AXP288 wakeup the system on a power-button press (the GPD win has a different PMIC). Move the registering of the power-button press/release interrupt-handler from axp20x_pek_probe_input_device() to axp20x_pek_probe() so that the PMIC will wakeup the system on a power-button press, even if we do not register an input device. Signed-off-by: Hans de Goede <[email protected]> Acked-by: Chen-Yu Tsai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 18f4237 commit 9747070

File tree

1 file changed

+37
-35
lines changed

1 file changed

+37
-35
lines changed

drivers/input/misc/axp20x-pek.c

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,11 @@ ATTRIBUTE_GROUPS(axp20x);
205205

206206
static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
207207
{
208-
struct input_dev *idev = pwr;
209-
struct axp20x_pek *axp20x_pek = input_get_drvdata(idev);
208+
struct axp20x_pek *axp20x_pek = pwr;
209+
struct input_dev *idev = axp20x_pek->input;
210+
211+
if (!idev)
212+
return IRQ_HANDLED;
210213

211214
/*
212215
* The power-button is connected to ground so a falling edge (dbf)
@@ -225,22 +228,9 @@ static irqreturn_t axp20x_pek_irq(int irq, void *pwr)
225228
static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
226229
struct platform_device *pdev)
227230
{
228-
struct axp20x_dev *axp20x = axp20x_pek->axp20x;
229231
struct input_dev *idev;
230232
int error;
231233

232-
axp20x_pek->irq_dbr = platform_get_irq_byname(pdev, "PEK_DBR");
233-
if (axp20x_pek->irq_dbr < 0)
234-
return axp20x_pek->irq_dbr;
235-
axp20x_pek->irq_dbr = regmap_irq_get_virq(axp20x->regmap_irqc,
236-
axp20x_pek->irq_dbr);
237-
238-
axp20x_pek->irq_dbf = platform_get_irq_byname(pdev, "PEK_DBF");
239-
if (axp20x_pek->irq_dbf < 0)
240-
return axp20x_pek->irq_dbf;
241-
axp20x_pek->irq_dbf = regmap_irq_get_virq(axp20x->regmap_irqc,
242-
axp20x_pek->irq_dbf);
243-
244234
axp20x_pek->input = devm_input_allocate_device(&pdev->dev);
245235
if (!axp20x_pek->input)
246236
return -ENOMEM;
@@ -255,33 +245,13 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
255245

256246
input_set_drvdata(idev, axp20x_pek);
257247

258-
error = devm_request_any_context_irq(&pdev->dev, axp20x_pek->irq_dbr,
259-
axp20x_pek_irq, 0,
260-
"axp20x-pek-dbr", idev);
261-
if (error < 0) {
262-
dev_err(&pdev->dev, "Failed to request dbr IRQ#%d: %d\n",
263-
axp20x_pek->irq_dbr, error);
264-
return error;
265-
}
266-
267-
error = devm_request_any_context_irq(&pdev->dev, axp20x_pek->irq_dbf,
268-
axp20x_pek_irq, 0,
269-
"axp20x-pek-dbf", idev);
270-
if (error < 0) {
271-
dev_err(&pdev->dev, "Failed to request dbf IRQ#%d: %d\n",
272-
axp20x_pek->irq_dbf, error);
273-
return error;
274-
}
275-
276248
error = input_register_device(idev);
277249
if (error) {
278250
dev_err(&pdev->dev, "Can't register input device: %d\n",
279251
error);
280252
return error;
281253
}
282254

283-
device_init_wakeup(&pdev->dev, true);
284-
285255
return 0;
286256
}
287257

@@ -339,6 +309,18 @@ static int axp20x_pek_probe(struct platform_device *pdev)
339309

340310
axp20x_pek->axp20x = dev_get_drvdata(pdev->dev.parent);
341311

312+
axp20x_pek->irq_dbr = platform_get_irq_byname(pdev, "PEK_DBR");
313+
if (axp20x_pek->irq_dbr < 0)
314+
return axp20x_pek->irq_dbr;
315+
axp20x_pek->irq_dbr = regmap_irq_get_virq(
316+
axp20x_pek->axp20x->regmap_irqc, axp20x_pek->irq_dbr);
317+
318+
axp20x_pek->irq_dbf = platform_get_irq_byname(pdev, "PEK_DBF");
319+
if (axp20x_pek->irq_dbf < 0)
320+
return axp20x_pek->irq_dbf;
321+
axp20x_pek->irq_dbf = regmap_irq_get_virq(
322+
axp20x_pek->axp20x->regmap_irqc, axp20x_pek->irq_dbf);
323+
342324
if (axp20x_pek_should_register_input(axp20x_pek, pdev)) {
343325
error = axp20x_pek_probe_input_device(axp20x_pek, pdev);
344326
if (error)
@@ -347,6 +329,26 @@ static int axp20x_pek_probe(struct platform_device *pdev)
347329

348330
axp20x_pek->info = (struct axp20x_info *)match->driver_data;
349331

332+
error = devm_request_any_context_irq(&pdev->dev, axp20x_pek->irq_dbr,
333+
axp20x_pek_irq, 0,
334+
"axp20x-pek-dbr", axp20x_pek);
335+
if (error < 0) {
336+
dev_err(&pdev->dev, "Failed to request dbr IRQ#%d: %d\n",
337+
axp20x_pek->irq_dbr, error);
338+
return error;
339+
}
340+
341+
error = devm_request_any_context_irq(&pdev->dev, axp20x_pek->irq_dbf,
342+
axp20x_pek_irq, 0,
343+
"axp20x-pek-dbf", axp20x_pek);
344+
if (error < 0) {
345+
dev_err(&pdev->dev, "Failed to request dbf IRQ#%d: %d\n",
346+
axp20x_pek->irq_dbf, error);
347+
return error;
348+
}
349+
350+
device_init_wakeup(&pdev->dev, true);
351+
350352
platform_set_drvdata(pdev, axp20x_pek);
351353

352354
return 0;

0 commit comments

Comments
 (0)