From patchwork Sat Dec 15 15:18:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10732271 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 3375713BF for ; Sat, 15 Dec 2018 15:18:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F4362A20B for ; Sat, 15 Dec 2018 15:18:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13E492A21A; Sat, 15 Dec 2018 15:18:34 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 A8B0F2A20B for ; Sat, 15 Dec 2018 15:18:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730529AbeLOPSc (ORCPT ); Sat, 15 Dec 2018 10:18:32 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:44473 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729687AbeLOPSc (ORCPT ); Sat, 15 Dec 2018 10:18:32 -0500 Received: by mail-yw1-f65.google.com with SMTP id i22so3521480ywa.11 for ; Sat, 15 Dec 2018 07:18:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=duKzC7XIbmzTlndaKTXS3J2cZIplwvKfqW+lEcLnAYs=; b=evQM7WvDHyHl5fGSTI8wfMF0MVUtL2cz6E7uBIpl/mRLocsnoZoNG/BWNFKcMelVse pCSXMYRL00wTxKRlXOXxw8dYrzCRO/Kk9mCH3H1UJmvVXNzdFIxLWUpcBTtsnU8dbLTC DUwgmHRuqA0HB5CAJXV3yzHkMkzWRL1ecxcV8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=duKzC7XIbmzTlndaKTXS3J2cZIplwvKfqW+lEcLnAYs=; b=JW4PKqS+R16uXVCQrEGkT1Z4i1gusDhtHJAZhoMIvSYjhXmR0i/XCO+TLC5O7dHsbH MCTz6/sVTUIbAtQ9fjwd2Dt0XTODBuEcEEdGbGPmEWzZKhewNbLu9+RfUQTucfjLJHml eXsil4Nnqz4axgYa/0q3qTGvZiCbBkAO7rG0oYL7r8GEmEO7casJAV8JNha3oc8QYlCF n0j/C/FGD5I5XEvO7EUJw66Yp6FMGx7YEEnmVd9KdVLGIxOnvU0w8uFWSuuPShqt3OD2 eSRfqbaZIHYbr+V0bZzuMZFJzzhU+XXlISRLoz4uduBn4WtHmhri7hnCtAQtTFXMC7rs koPQ== X-Gm-Message-State: AA+aEWaE3rCYSL6qCrkbfl8kDBZg4fCte6SuGLmweMTB7mriIIHwahTs AiaeDFfcQ1osJXAIhkpJwZ8NAQ== X-Google-Smtp-Source: AFSGD/Wi6tAd7HmjDwzb6rDJzvGE0fYLx4X4BSO1sbNxUJUmMsC65tNTm0UHMPKsvuNGTTEIO4Yqkg== X-Received: by 2002:a81:37c3:: with SMTP id e186mr7399784ywa.506.1544887111397; Sat, 15 Dec 2018 07:18:31 -0800 (PST) Received: from jagan-XPS-13-9350.homenet.telecomitalia.it (host211-95-static.0-79-b.business.telecomitalia.it. [79.0.95.211]) by smtp.gmail.com with ESMTPSA id x203sm2855664ywd.41.2018.12.15.07.18.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Dec 2018 07:18:30 -0800 (PST) From: Jagan Teki To: Dmitry Torokhov Cc: Chen-Yu Tsai , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Trimarchi , linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v3 2/4] Input: goodix - Add AVDD28-supply regulator support Date: Sat, 15 Dec 2018 20:48:00 +0530 Message-Id: <20181215151802.18592-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181215151802.18592-1-jagan@amarulasolutions.com> References: <20181215151802.18592-1-jagan@amarulasolutions.com> MIME-Version: 1.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 Goodix CTP controllers have AVDD28 pin connected to voltage regulator which may not be turned on by default, like for GT5663. Add support for such ctp used boards by adding voltage regulator handling code to goodix ctp driver. Signed-off-by: Jagan Teki --- drivers/input/touchscreen/goodix.c | 33 +++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index f2d9c2c41885..7371f6946098 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,7 @@ struct goodix_ts_data { struct touchscreen_properties prop; unsigned int max_touch_num; unsigned int int_trigger_type; + struct regulator *avdd28; struct gpio_desc *gpiod_int; struct gpio_desc *gpiod_rst; u16 id; @@ -786,25 +788,41 @@ static int goodix_ts_probe(struct i2c_client *client, if (error) return error; + ts->avdd28 = devm_regulator_get(&client->dev, "AVDD28"); + if (IS_ERR(ts->avdd28)) { + error = PTR_ERR(ts->avdd28); + if (error != -EPROBE_DEFER) + dev_err(&client->dev, + "Failed to get AVDD28 regulator: %d\n", error); + return error; + } + + /* power the controller */ + error = regulator_enable(ts->avdd28); + if (error) { + dev_err(&client->dev, "Controller fail to enable AVDD28\n"); + 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; + goto error; } } error = goodix_i2c_test(client); if (error) { dev_err(&client->dev, "I2C communication failure: %d\n", error); - return error; + goto error; } error = goodix_read_version(ts); if (error) { dev_err(&client->dev, "Read version failed.\n"); - return error; + goto error; } ts->chip = goodix_get_chip_data(ts->id); @@ -823,23 +841,28 @@ static int goodix_ts_probe(struct i2c_client *client, dev_err(&client->dev, "Failed to invoke firmware loader: %d\n", error); - return error; + goto error; } return 0; } else { error = goodix_configure_dev(ts); if (error) - return error; + goto error; } return 0; + +error: + regulator_disable(ts->avdd28); + return error; } static int goodix_ts_remove(struct i2c_client *client) { struct goodix_ts_data *ts = i2c_get_clientdata(client); + regulator_disable(ts->avdd28); if (ts->gpiod_int && ts->gpiod_rst) wait_for_completion(&ts->firmware_loading_complete);