All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] input: axp20x-pek: fixes + improvements
@ 2017-04-17 20:13 Hans de Goede
  2017-04-17 20:13 ` [PATCH 1/3] input: axp20x-pek: Only check for "INTCFD9" ACPI device on Cherry Trail Hans de Goede
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hans de Goede @ 2017-04-17 20:13 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Hans de Goede, linux-input

Hi Dmitry,

Here are 3 patches for the axp20x-pek driver, the first one is a
regression-fix for a patch you've already queued up for 4.12 !

The other 2 are normal improvements / fixes.

Regards,

Hans

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] input: axp20x-pek: Only check for "INTCFD9" ACPI device on Cherry Trail
  2017-04-17 20:13 [PATCH 1/3] input: axp20x-pek: fixes + improvements Hans de Goede
@ 2017-04-17 20:13 ` Hans de Goede
  2017-04-17 20:13 ` [PATCH 2/3] input: axp20x-pek: Check for ACPI0011 gpio button device too Hans de Goede
  2017-04-17 20:13 ` [PATCH 3/3] input: axp20x-pek: Add wakeup support Hans de Goede
  2 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2017-04-17 20:13 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Hans de Goede, linux-input

Commit 9b13a4ca8d2c ("Input: axp20x-pek - do not register input device
on some systems") added a check for the INTCFD9 ACPI device which also
handles the powerbutton as on some systems the powerbutton is connected
to both the PMIC, handled by axp20x-pek, and to a gpio on the SoC, handled
by soc_button_array which attaches itself to the INTCFD9 ACPI device.

Testing + comparing DSDTs has shown that this only happens on Cherry
Trail devices with an AXP288 PMIC, the AXP288 PMIC is also used on
Bay Trail devices but there the power button is only connected to
the PMIC and not handled by soc_button_array.

This means that the INTCFD9 check has caused a regression on Bay Trail
devices, causing power-button presses to no longer be seen.

This commit fixes this by limiting the check to devices where the ACPI
node for the AXP288 contains a _HRV (hardware revision) attribute with
a value of 3 which indicates we are dealing with a Cherry Trail platform.

Fixes: 9b13a4ca8d2c ("Input: axp20x-pek - do not register input ...")
Reported-by: Сергей Трусов <t.rus76@ya.ru>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/input/misc/axp20x-pek.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index dbd2c89..5382e09 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -259,6 +259,11 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
 static int axp20x_pek_probe(struct platform_device *pdev)
 {
 	struct axp20x_pek *axp20x_pek;
+	bool register_input_device = true;
+#ifdef CONFIG_ACPI
+	unsigned long long hrv = 0;
+	acpi_status status;
+#endif
 	int error;
 
 	axp20x_pek = devm_kzalloc(&pdev->dev, sizeof(struct axp20x_pek),
@@ -268,12 +273,25 @@ static int axp20x_pek_probe(struct platform_device *pdev)
 
 	axp20x_pek->axp20x = dev_get_drvdata(pdev->dev.parent);
 
-	/*
-	 * Do not register the input device if there is an "INTCFD9"
-	 * gpio button ACPI device, that handles the power button too,
-	 * and otherwise we end up reporting all presses twice.
-	 */
-	if (!acpi_dev_found("INTCFD9")) {
+#ifdef CONFIG_ACPI
+	if (axp20x_pek->axp20x->variant == AXP288_ID) {
+		status = acpi_evaluate_integer(ACPI_HANDLE(pdev->dev.parent),
+					       "_HRV", NULL, &hrv);
+		if (ACPI_FAILURE(status))
+			dev_err(&pdev->dev, "Failed to get PMIC hardware revision\n");
+
+		/*
+		 * On Cherry Trail platforms (hrv == 3), do not register the
+		 * input device if there is an "INTCFD9" gpio
+		 * button ACPI device, as that handles the power button too,
+		 * and otherwise we end up reporting all presses twice.
+		 */
+		if (hrv == 3 && acpi_dev_found("INTCFD9"))
+			register_input_device = false;
+	}
+#endif
+
+	if (register_input_device) {
 		error = axp20x_pek_probe_input_device(axp20x_pek, pdev);
 		if (error)
 			return error;
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] input: axp20x-pek: Check for ACPI0011 gpio button device too
  2017-04-17 20:13 [PATCH 1/3] input: axp20x-pek: fixes + improvements Hans de Goede
  2017-04-17 20:13 ` [PATCH 1/3] input: axp20x-pek: Only check for "INTCFD9" ACPI device on Cherry Trail Hans de Goede
@ 2017-04-17 20:13 ` Hans de Goede
  2017-04-17 20:13 ` [PATCH 3/3] input: axp20x-pek: Add wakeup support Hans de Goede
  2 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2017-04-17 20:13 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Hans de Goede, linux-input

The ACPI-6.0 standard defines a standard gpio button device using
the ACPI0011 HID replacing the custom PNP0C40 gpio device used on
many devices with an AXP288 pmic. All DSDTs I've seen for Cherry
Trail devices with an AXP288 pmic define both a PNP0C40 and an
ACPI0011 ACPI device, enabling one or the other depending on whether
the BIOS thinks it is going to boot Android or Windows.

But in the future we may see some Windows only devices only defining
the ACPI0011 device, so lets check for both.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/input/misc/axp20x-pek.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index 5382e09..be50a7f 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -282,11 +282,12 @@ static int axp20x_pek_probe(struct platform_device *pdev)
 
 		/*
 		 * On Cherry Trail platforms (hrv == 3), do not register the
-		 * input device if there is an "INTCFD9" gpio
+		 * input device if there is an "INTCFD9" or "ACPI0011" gpio
 		 * button ACPI device, as that handles the power button too,
 		 * and otherwise we end up reporting all presses twice.
 		 */
-		if (hrv == 3 && acpi_dev_found("INTCFD9"))
+		if (hrv == 3 && (acpi_dev_found("INTCFD9") ||
+				 acpi_dev_found("ACPI0011")))
 			register_input_device = false;
 	}
 #endif
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] input: axp20x-pek: Add wakeup support
  2017-04-17 20:13 [PATCH 1/3] input: axp20x-pek: fixes + improvements Hans de Goede
  2017-04-17 20:13 ` [PATCH 1/3] input: axp20x-pek: Only check for "INTCFD9" ACPI device on Cherry Trail Hans de Goede
  2017-04-17 20:13 ` [PATCH 2/3] input: axp20x-pek: Check for ACPI0011 gpio button device too Hans de Goede
@ 2017-04-17 20:13 ` Hans de Goede
  2 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2017-04-17 20:13 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Hans de Goede, linux-input

At least on devices with the AXP288 PMIC the device is expected to
wakeup from suspend when the power-button gets pressed, add support
for this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/input/misc/axp20x-pek.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/input/misc/axp20x-pek.c b/drivers/input/misc/axp20x-pek.c
index be50a7f..5b37a3a 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -253,6 +253,9 @@ static int axp20x_pek_probe_input_device(struct axp20x_pek *axp20x_pek,
 		return error;
 	}
 
+	if (axp20x_pek->axp20x->variant == AXP288_ID)
+		enable_irq_wake(axp20x_pek->irq_dbr);
+
 	return 0;
 }
 
@@ -319,10 +322,35 @@ static int axp20x_pek_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static int __maybe_unused axp20x_pek_resume_noirq(struct device *dev)
+{
+	struct axp20x_pek *axp20x_pek = dev_get_drvdata(dev);
+
+	if (axp20x_pek->axp20x->variant != AXP288_ID)
+		return 0;
+
+	/*
+	 * Clear interrupts from button presses during suspend, to avoid
+	 * a wakeup power-button press getting reported to userspace.
+	 */
+	regmap_write(axp20x_pek->axp20x->regmap,
+		     AXP20X_IRQ1_STATE + AXP288_IRQ_POKN / 8,
+		     BIT(AXP288_IRQ_POKN % 8));
+
+	return 0;
+}
+
+const struct dev_pm_ops axp20x_pek_pm_ops = {
+#ifdef CONFIG_PM_SLEEP
+	.resume_noirq = axp20x_pek_resume_noirq,
+#endif
+};
+
 static struct platform_driver axp20x_pek_driver = {
 	.probe		= axp20x_pek_probe,
 	.driver		= {
 		.name		= "axp20x-pek",
+		.pm		= &axp20x_pek_pm_ops,
 	},
 };
 module_platform_driver(axp20x_pek_driver);
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-17 20:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-17 20:13 [PATCH 1/3] input: axp20x-pek: fixes + improvements Hans de Goede
2017-04-17 20:13 ` [PATCH 1/3] input: axp20x-pek: Only check for "INTCFD9" ACPI device on Cherry Trail Hans de Goede
2017-04-17 20:13 ` [PATCH 2/3] input: axp20x-pek: Check for ACPI0011 gpio button device too Hans de Goede
2017-04-17 20:13 ` [PATCH 3/3] input: axp20x-pek: Add wakeup support Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.