From patchwork Wed Dec 5 23:52:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10715121 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 0220D13BB for ; Wed, 5 Dec 2018 23:52:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4BDF2E1CD for ; Wed, 5 Dec 2018 23:52:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D64612E1F8; Wed, 5 Dec 2018 23:52:57 +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 BAC4D2E1CD for ; Wed, 5 Dec 2018 23:52:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728991AbeLEXwe (ORCPT ); Wed, 5 Dec 2018 18:52:34 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:36726 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727762AbeLEXwd (ORCPT ); Wed, 5 Dec 2018 18:52:33 -0500 Received: by mail-wm1-f68.google.com with SMTP id a18so14718060wmj.1 for ; Wed, 05 Dec 2018 15:52:32 -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=rBYjCviXbp1GB9pLzlbZBcnM5Y0HUWSor8mlLMpmZyM=; b=SFZLKqa07jB+I+9eKm/4rEpndVBtrkls+WtaeK//lYJ70sIBn921bc3UrDOUl7o+cH iuTSK1kY1gKmCK5ghMdhMwZfGOJlZjxdm8DIfzb6VgLA6OOtd3yHi9bQnrNDnObYXwks gcD/1l75Mf6FjBOWHVcX+vSwEYaKtF866HsuI= 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=rBYjCviXbp1GB9pLzlbZBcnM5Y0HUWSor8mlLMpmZyM=; b=JXXWmB5py8JMv7mLcDkfRAlp5nr6CUXKxRl5i+Jm/chCEys/+ZU6cvQ2aeQqE1keRZ VI/cp0cBCXxomCyuuJts4gjm6Mz0AXjN27duyUE2PAMTNfO+KwvNY1HbE99/m8GcnZ/y jBPtzEBl1+c1Fbm7jozerjBFuBfyiogkrk7c55dgEn7wJV0wHb1rkkSw8e/sV6NXK8PK OMU7H51cXK4Wv+vXkGHBRv9KX5/R0+mUuPYP1BmciTeYMewqEWTD0ys89ZF0buDJb7sC ksZ5/kxM9KfhOxFAXWfRq+jk98mlNwk/XMifNHTAc71VinElrlHeQSRx/VkcEIwJ/v4P bQeA== X-Gm-Message-State: AA+aEWaNqQVrVcbVPbk1qoNBYx0P3GHWJleyXHM7ueAcDxVbSBTIiPZ0 JdklZth8JPMDBjlCEp/g5jp7FA== X-Google-Smtp-Source: AFSGD/XQDNliKlJmlnBnT0V5lCbVyFo0/Mnwytx7hEowZ/u54DhqIbdefL5WpZooQ8qwGr6IzCxRLA== X-Received: by 2002:a1c:f8f:: with SMTP id 137mr17208559wmp.96.1544053951508; Wed, 05 Dec 2018 15:52:31 -0800 (PST) Received: from localhost.localdomain (ip-161-243.sn-213-198.clouditalia.com. [213.198.161.243]) by smtp.gmail.com with ESMTPSA id x15sm19113324wrs.27.2018.12.05.15.52.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Dec 2018 15:52:30 -0800 (PST) From: Jagan Teki To: Dmitry Torokhov , Chen-Yu Tsai , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Trimarchi , linux-amarula@amarulasolutions.com Cc: Jagan Teki Subject: [PATCH v2 2/4] Input: goodix - Add ADVV28-supply regulator support Date: Thu, 6 Dec 2018 05:22:18 +0530 Message-Id: <20181205235220.3461-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181205235220.3461-1-jagan@amarulasolutions.com> References: <20181205235220.3461-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 --- Changes for v2: - disable regulator in remove - fix to setup regulator in probe code 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);