linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] input: axp20x-pek: Switch to acpi_dev_present and check for ACPI0011 too
@ 2017-05-19 14:06 Hans de Goede
  2017-05-19 14:06 ` [PATCH 2/2] input: axp20x-pek: Add wakeup support Hans de Goede
  2017-05-19 14:13 ` [PATCH 1/2] input: axp20x-pek: Switch to acpi_dev_present and check for ACPI0011 too Hans de Goede
  0 siblings, 2 replies; 3+ messages in thread
From: Hans de Goede @ 2017-05-19 14:06 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Hans de Goede, linux-input

acpi_dev_found checks that there is a matching ACPI node, but it
may be disabled (_STA method returns 0) in which case the
soc_button_array driver will not bind to it and axp20x-pek should
handle the power-button.

This commit switches from acpi_dev_found to acpi_dev_present to
avoid not registering an input-dev for the powerbutton when there
is a disabled PNP0C40 device.

The ACPI-6.0 standard defines a standard gpio button device using
the ACPI0011 HID replacing the custom PNP0C40 gpio device, many
newer devices define both PNP0C40 and ACPI0011 devices enabling one
or the other depending on whether the BIOS thinks it is going to boot
Android or Windows.

This commit adds a check for the ACPI0011 device, so that if
either device is present *and* enabled we don't register an input-dev
for the powerbutton.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Switch from acpi_dev_found to acpi_dev_present
---
 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 7ac790b94392..3f1f9434eb9a 100644
--- a/drivers/input/misc/axp20x-pek.c
+++ b/drivers/input/misc/axp20x-pek.c
@@ -280,11 +280,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_present("INTCFD9", NULL, -1) ||
+				 acpi_dev_present("ACPI0011", NULL, -1)))
 			register_input_device = false;
 	}
 #endif
-- 
2.12.2


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

* [PATCH 2/2] input: axp20x-pek: Add wakeup support
  2017-05-19 14:06 [PATCH 1/2] input: axp20x-pek: Switch to acpi_dev_present and check for ACPI0011 too Hans de Goede
@ 2017-05-19 14:06 ` Hans de Goede
  2017-05-19 14:13 ` [PATCH 1/2] input: axp20x-pek: Switch to acpi_dev_present and check for ACPI0011 too Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2017-05-19 14:06 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 3f1f9434eb9a..6b1998b2e436 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;
 }
 
@@ -317,10 +320,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.12.2


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

* Re: [PATCH 1/2] input: axp20x-pek: Switch to acpi_dev_present and check for ACPI0011 too
  2017-05-19 14:06 [PATCH 1/2] input: axp20x-pek: Switch to acpi_dev_present and check for ACPI0011 too Hans de Goede
  2017-05-19 14:06 ` [PATCH 2/2] input: axp20x-pek: Add wakeup support Hans de Goede
@ 2017-05-19 14:13 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2017-05-19 14:13 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input

Hi,

Note this series is v2, something went wrong causing that to
not show in the Subject, sorry.

Regards,

Hans

On 19-05-17 16:06, Hans de Goede wrote:
> acpi_dev_found checks that there is a matching ACPI node, but it
> may be disabled (_STA method returns 0) in which case the
> soc_button_array driver will not bind to it and axp20x-pek should
> handle the power-button.
> 
> This commit switches from acpi_dev_found to acpi_dev_present to
> avoid not registering an input-dev for the powerbutton when there
> is a disabled PNP0C40 device.
> 
> The ACPI-6.0 standard defines a standard gpio button device using
> the ACPI0011 HID replacing the custom PNP0C40 gpio device, many
> newer devices define both PNP0C40 and ACPI0011 devices enabling one
> or the other depending on whether the BIOS thinks it is going to boot
> Android or Windows.
> 
> This commit adds a check for the ACPI0011 device, so that if
> either device is present *and* enabled we don't register an input-dev
> for the powerbutton.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> Changes in v2:
> -Switch from acpi_dev_found to acpi_dev_present
> ---
>   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 7ac790b94392..3f1f9434eb9a 100644
> --- a/drivers/input/misc/axp20x-pek.c
> +++ b/drivers/input/misc/axp20x-pek.c
> @@ -280,11 +280,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_present("INTCFD9", NULL, -1) ||
> +				 acpi_dev_present("ACPI0011", NULL, -1)))
>   			register_input_device = false;
>   	}
>   #endif
> 

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

end of thread, other threads:[~2017-05-19 14:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-19 14:06 [PATCH 1/2] input: axp20x-pek: Switch to acpi_dev_present and check for ACPI0011 too Hans de Goede
2017-05-19 14:06 ` [PATCH 2/2] input: axp20x-pek: Add wakeup support Hans de Goede
2017-05-19 14:13 ` [PATCH 1/2] input: axp20x-pek: Switch to acpi_dev_present and check for ACPI0011 too Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).