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