From patchwork Sun Jan 1 21:30:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9493021 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1343F60453 for ; Sun, 1 Jan 2017 21:30:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0455A2621D for ; Sun, 1 Jan 2017 21:30:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EABCB267EC; Sun, 1 Jan 2017 21:30:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89F172621D for ; Sun, 1 Jan 2017 21:30:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755144AbdAAVaI (ORCPT ); Sun, 1 Jan 2017 16:30:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58582 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754636AbdAAVaI (ORCPT ); Sun, 1 Jan 2017 16:30:08 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7FDDEC0092AF; Sun, 1 Jan 2017 21:30:08 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-7-169.ams2.redhat.com [10.36.7.169]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v01LU6CV005752; Sun, 1 Jan 2017 16:30:07 -0500 From: Hans de Goede To: Dmitry Torokhov Cc: "russianneuromancer @ ya . ru" , Gregor Riepl , linux-input@vger.kernel.org, Hans de Goede Subject: [PATCH] Input: silead - Add support for ACPI bus power methods Date: Sun, 1 Jan 2017 22:30:04 +0100 Message-Id: <20170101213004.31050-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sun, 01 Jan 2017 21:30:08 +0000 (UTC) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On some x86 tablets we cannot directly access the GPIOs as they are claimed by the ACPI tables, so first try using acpi_bus_set_power and if that works use that instead of directly accessing the GPIO. Signed-off-by: Hans de Goede --- drivers/input/touchscreen/silead.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c index f502c84..d3dd9bb 100644 --- a/drivers/input/touchscreen/silead.c +++ b/drivers/input/touchscreen/silead.c @@ -30,6 +30,7 @@ #include #include +#include #include #define SILEAD_TS_NAME "silead_ts" @@ -71,6 +72,7 @@ enum silead_ts_power { struct silead_ts_data { struct i2c_client *client; + bool acpi_power; struct gpio_desc *gpio_power; struct input_dev *input; char fw_name[64]; @@ -125,7 +127,14 @@ static void silead_ts_set_power(struct i2c_client *client, { struct silead_ts_data *data = i2c_get_clientdata(client); - if (data->gpio_power) { + if (data->acpi_power) { +#ifdef CONFIG_ACPI + int ret = acpi_bus_set_power(ACPI_HANDLE(&client->dev), + state ? ACPI_STATE_D0 : ACPI_STATE_D3); + if (ret) + dev_err(&client->dev, "Power error %d\n", ret); +#endif + } else if (data->gpio_power) { gpiod_set_value_cansleep(data->gpio_power, state); msleep(SILEAD_POWER_SLEEP); } @@ -465,12 +474,21 @@ static int silead_ts_probe(struct i2c_client *client, if (client->irq <= 0) return -ENODEV; - /* Power GPIO pin */ - data->gpio_power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW); - if (IS_ERR(data->gpio_power)) { - if (PTR_ERR(data->gpio_power) != -EPROBE_DEFER) - dev_err(dev, "Shutdown GPIO request failed\n"); - return PTR_ERR(data->gpio_power); + /* Power handling, try ACPI companion method first then GPIO */ +#ifdef CONFIG_ACPI + if (ACPI_COMPANION(&client->dev) && + acpi_bus_set_power(ACPI_HANDLE(&client->dev), ACPI_STATE_D3) == 0) + data->acpi_power = true; + else +#endif + { + data->gpio_power = devm_gpiod_get_optional(dev, "power", + GPIOD_OUT_LOW); + if (IS_ERR(data->gpio_power)) { + if (PTR_ERR(data->gpio_power) != -EPROBE_DEFER) + dev_err(dev, "Power GPIO request failed\n"); + return PTR_ERR(data->gpio_power); + } } error = silead_ts_setup(client);