From patchwork Fri Jan 4 16:00:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonzalez, Alex" X-Patchwork-Id: 10748419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE3C414E5 for ; Fri, 4 Jan 2019 16:01:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E284287F5 for ; Fri, 4 Jan 2019 16:01:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90302287CE; Fri, 4 Jan 2019 16:01:04 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 15C7F2880A for ; Fri, 4 Jan 2019 16:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728190AbfADQBC (ORCPT ); Fri, 4 Jan 2019 11:01:02 -0500 Received: from mail1.bemta24.messagelabs.com ([67.219.250.113]:14321 "EHLO mail1.bemta24.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727192AbfADQBC (ORCPT ); Fri, 4 Jan 2019 11:01:02 -0500 Received: from [67.219.250.197] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-2.bemta.az-b.us-west-2.aws.symcld.net id 1C/4A-21206-C338F2C5; Fri, 04 Jan 2019 16:01:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOIsWRWlGSWpSXmKPExsXi5LtOQNemWT/ GoG8Bk8XhRS8YLb5+u81ucfPTN1aLy7vmsDmweOycdZfd49e2NSwenzfJBTBHsWbmJeVXJLBm TDt8ir3gpVjF26cNjA2MD4S6GLk4hARWMUosen2bHcLZwiix7vR/IIeTg01AR2LK/sMsILaIg LjEtSNnweLMApUSz35vZgOxhQVsJX5Nm8EKYrMIqEjcfrCGCcTmFXCT2LjoN5gtISAncfNcJz OIzSngLrHv0zRGEFsIqObjjw9sEPWCEidnPmGBmC8hcfDFC2aIGmWJLSsuMELMUZBYe+A80wR G/llIWmYhaVnAyLSK0SKpKDM9oyQ3MTNH19DAQNfQ0EjX0NhE19DSQC+xSjdJr7RYtzy1uETX SC+xvFivuDI3OSdFLy+1ZBMjMIBTCtr27WB8sTz9EKMkB5OSKG8as36MEF9SfkplRmJxRnxRa U5q8SFGGQ4OJQnemY1AOcGi1PTUirTMHGAswaQlOHiURHhvg6R5iwsSc4sz0yFSpxgVpcR5zz YAJQRAEhmleXBtsPi9xCgrJczLyMDAIMRTkFqUm1mCKv+KUZyDUUmYdxPIFJ7MvBK46a+AFjM BLTaR0AFZXJKIkJJqYGwKeCX+sCFh5sPuUOVV02TfXww0tlvIJabert276qRi4GX/Y2/0Z1+b dy1ufpmnjpfs880xaszXI44Ws+/YJ7a0TfrFRj6n9u9vPf5XsPREvroUwP/BLieCR03g8SufC bmLz/1uX/JuSlBn7PG7C7vrAz0V5veweE6Nj5y37DSX61KDWQ//WSixFGckGmoxFxUnAgC7Q8 tX2gIAAA== X-Env-Sender: Alex.Gonzalez@digi.com X-Msg-Ref: server-6.tower-345.messagelabs.com!1546617658!6169452!1 X-Originating-IP: [66.77.174.16] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.14.24; banners=-,-,- X-VirusChecked: Checked Received: (qmail 3039 invoked from network); 4 Jan 2019 16:00:59 -0000 Received: from owa.digi.com (HELO MCL-VMS-XCH01.digi.com) (66.77.174.16) by server-6.tower-345.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 4 Jan 2019 16:00:59 -0000 Received: from MTK-SMS-XCH01.digi.com (10.10.8.195) by MCL-VMS-XCH01.digi.com (10.5.8.49) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 4 Jan 2019 10:00:58 -0600 Received: from log-linux-hp-agonzal.digi.com (10.101.2.214) by MTK-SMS-XCH01.digi.com (10.10.8.195) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 4 Jan 2019 10:00:58 -0600 From: Alex Gonzalez To: CC: , , , Subject: [PATCH] Input: goodix - decouple irq and reset lines Date: Fri, 4 Jan 2019 17:00:48 +0100 Message-ID: <1546617648-23445-2-git-send-email-alex.gonzalez@digi.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1546617648-23445-1-git-send-email-alex.gonzalez@digi.com> References: <1546617648-23445-1-git-send-email-alex.gonzalez@digi.com> MIME-Version: 1.0 X-Originating-IP: [10.101.2.214] 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 The Goodix touch controller allows the use of two optional GPIOs (RESET and INT) to reset the touch controller, select the I2C address of the device and exit the device from sleep mode. The current implementation requires both GPIOs to be provided, however, it is possible to provide only the INT line and not to have the RESET line available but pulled-up. Designs that only provide the INT line are able to operate the touch on the default I2C address but will not be able to reset the touch via software or place the device in sleep mode. Signed-off-by: Alex Gonzalez --- drivers/input/touchscreen/goodix.c | 59 ++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index f2d9c2c41885..8d96b0b771b6 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -484,34 +484,39 @@ static int goodix_reset(struct goodix_ts_data *ts) { int error; - /* begin select I2C slave addr */ - error = gpiod_direction_output(ts->gpiod_rst, 0); - if (error) - return error; + if (ts->gpiod_rst) { + /* begin select I2C slave addr */ + error = gpiod_direction_output(ts->gpiod_rst, 0); + if (error) + return error; - msleep(20); /* T2: > 10ms */ + msleep(20); /* T2: > 10ms */ - /* HIGH: 0x28/0x29, LOW: 0xBA/0xBB */ - error = gpiod_direction_output(ts->gpiod_int, ts->client->addr == 0x14); - if (error) - return error; + /* HIGH: 0x28/0x29, LOW: 0xBA/0xBB */ + error = gpiod_direction_output(ts->gpiod_int, + ts->client->addr == 0x14); + if (error) + return error; - usleep_range(100, 2000); /* T3: > 100us */ + usleep_range(100, 2000); /* T3: > 100us */ - error = gpiod_direction_output(ts->gpiod_rst, 1); - if (error) - return error; + error = gpiod_direction_output(ts->gpiod_rst, 1); + if (error) + return error; - usleep_range(6000, 10000); /* T4: > 5ms */ + usleep_range(6000, 10000); /* T4: > 5ms */ - /* end select I2C slave addr */ - error = gpiod_direction_input(ts->gpiod_rst); - if (error) - return error; + /* end select I2C slave addr */ + error = gpiod_direction_input(ts->gpiod_rst); + if (error) + return error; + } - error = goodix_int_sync(ts); - if (error) - return error; + if (ts->gpiod_int) { + error = goodix_int_sync(ts); + if (error) + return error; + } return 0; } @@ -786,13 +791,11 @@ static int goodix_ts_probe(struct i2c_client *client, if (error) return error; - if (ts->gpiod_int && ts->gpiod_rst) { - /* reset the controller */ - error = goodix_reset(ts); - if (error) { - dev_err(&client->dev, "Controller reset failed.\n"); - return error; - } + /* reset the controller */ + error = goodix_reset(ts); + if (error) { + dev_err(&client->dev, "Controller reset failed.\n"); + return error; } error = goodix_i2c_test(client);