88f3771
From fd4fb1f6633b21042ff084868323e15e708fe1cd Mon Sep 17 00:00:00 2001
88f3771
From: Hans de Goede <hdegoede@redhat.com>
88f3771
Date: Sun, 1 Jan 2017 22:11:20 +0100
88f3771
Subject: [PATCH 16/16] Input: silead: Do not try to directly access the GPIO
88f3771
 when using ACPI pm
88f3771
88f3771
On some x86 tablets we cannot directly access the GPIOs as they are
88f3771
claimed by the ACPI tables, so check it the i2c client is not being
88f3771
power-managed by ACPI before trying to get the power pin GPIO.
88f3771
88f3771
Note this is a workaround patch to fix this until Andy' gpiolib-ACPI
88f3771
patches which make gpiolib more strict land, once those are landed this
88f3771
patch is no longer needed.
88f3771
88f3771
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
88f3771
---
88f3771
 drivers/input/touchscreen/silead.c | 22 ++++++++++++++++------
88f3771
 1 file changed, 16 insertions(+), 6 deletions(-)
88f3771
88f3771
diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
88f3771
index c0ba40c09699..30fba3cbe277 100644
88f3771
--- a/drivers/input/touchscreen/silead.c
88f3771
+++ b/drivers/input/touchscreen/silead.c
88f3771
@@ -517,12 +518,21 @@ static int silead_ts_probe(struct i2c_client *client,
88f3771
 	if (error)
88f3771
 		return error;
88f3771
 
88f3771
-	/* Power GPIO pin */
88f3771
-	data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW);
88f3771
-	if (IS_ERR(data->gpio_power)) {
88f3771
-		if (PTR_ERR(data->gpio_power) != -EPROBE_DEFER)
88f3771
-			dev_err(dev, "Shutdown GPIO request failed\n");
88f3771
-		return PTR_ERR(data->gpio_power);
88f3771
+	/*
88f3771
+	 * If device power is not managed by ACPI, get the power_gpio
88f3771
+	 * and manage it ourselves.
88f3771
+	 */
88f3771
+#ifdef CONFIG_ACPI
88f3771
+	if (!acpi_bus_power_manageable(ACPI_HANDLE(dev)))
88f3771
+#endif
88f3771
+	{
88f3771
+		data->gpio_power = devm_gpiod_get_optional(dev, "power",
88f3771
+							   GPIOD_OUT_LOW);
88f3771
+		if (IS_ERR(data->gpio_power)) {
88f3771
+			if (PTR_ERR(data->gpio_power) != -EPROBE_DEFER)
88f3771
+				dev_err(dev, "Power GPIO request failed\n");
88f3771
+			return PTR_ERR(data->gpio_power);
88f3771
+		}
88f3771
 	}
88f3771
 
88f3771
 	error = silead_ts_setup(client);
88f3771
-- 
88f3771
2.13.0
88f3771