From patchwork Tue Jun 27 16:24:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 9812783 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 7E77F603F2 for ; Tue, 27 Jun 2017 16:25:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BFCE1FF21 for ; Tue, 27 Jun 2017 16:25:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 603D028592; Tue, 27 Jun 2017 16:25:03 +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, UNPARSEABLE_RELAY 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 759AA283A5 for ; Tue, 27 Jun 2017 16:25:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753180AbdF0QY5 (ORCPT ); Tue, 27 Jun 2017 12:24:57 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:58490 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752498AbdF0QYo (ORCPT ); Tue, 27 Jun 2017 12:24:44 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 8427C260B71 From: Sebastian Reichel To: Sebastian Reichel , Nick Dyer , Dmitry Torokhov , linux-input@vger.kernel.org Cc: Henrik Rydberg , Rob Herring , Mark Rutland , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Martyn Welch , Sebastian Reichel Subject: [PATCH] atmel_mxt_ts: Add support for reset line Date: Tue, 27 Jun 2017 18:24:38 +0200 Message-Id: <20170627162438.10108-1-sebastian.reichel@collabora.co.uk> X-Mailer: git-send-email 2.11.0 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 From: Martyn Welch At least some of the Atmel Maxtouch touchscreen controllers have a reset pin. If this is not driven correctly the device will be held in reset and will not respond. Add support for driving the reset line via GPIO as is found in other such drivers. Signed-off-by: Martyn Welch [add reset cycle during probe, minor style fixes, add DT binding] Signed-off-by: Sebastian Reichel Acked-by: Rob Herring --- .../devicetree/bindings/input/atmel,maxtouch.txt | 2 ++ drivers/input/touchscreen/atmel_mxt_ts.c | 27 +++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt index 1852906517ab..23e3abc3fdef 100644 --- a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt +++ b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt @@ -22,6 +22,8 @@ Optional properties for main touchpad device: experiment to determine which bit corresponds to which input. Use KEY_RESERVED for unused padding values. +- reset-gpios: GPIO specifier for the touchscreen's reset pin (active low) + Example: touch@4b { diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index dd042a9b0aaa..b84bf973fe36 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -300,6 +301,7 @@ struct mxt_data { u8 multitouch; struct t7_config t7_cfg; struct mxt_dbg dbg; + struct gpio_desc *reset_gpio; /* Cached parameters from object table */ u16 T5_address; @@ -3135,12 +3137,26 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) init_completion(&data->reset_completion); init_completion(&data->crc_completion); + data->reset_gpio = gpiod_get_optional(&client->dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(data->reset_gpio)) { + error = PTR_ERR(data->reset_gpio); + dev_err(&client->dev, "Failed to get reset gpio: %d\n", error); + goto err_free_mem; + } + + if (data->reset_gpio) { + msleep(MXT_RESET_TIME); + gpiod_set_value(data->reset_gpio, 1); + msleep(MXT_RESET_TIME); + } + error = request_threaded_irq(client->irq, NULL, mxt_interrupt, pdata->irqflags | IRQF_ONESHOT, client->name, data); if (error) { dev_err(&client->dev, "Failed to register interrupt\n"); - goto err_free_mem; + goto err_free_gpio; } disable_irq(client->irq); @@ -3163,6 +3179,11 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) mxt_free_object_table(data); err_free_irq: free_irq(client->irq, data); +err_free_gpio: + if (data->reset_gpio) { + gpiod_set_value(data->reset_gpio, 0); + gpiod_put(data->reset_gpio); + } err_free_mem: kfree(data); return error; @@ -3174,6 +3195,10 @@ static int mxt_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); free_irq(data->irq, data); + if (data->reset_gpio) { + gpiod_set_value(data->reset_gpio, 0); + gpiod_put(data->reset_gpio); + } mxt_free_input_device(data); mxt_free_object_table(data); kfree(data);