From patchwork Tue Feb 12 11:24:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10807773 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 C1AF96C2 for ; Tue, 12 Feb 2019 11:25:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B16D22A673 for ; Tue, 12 Feb 2019 11:25:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5EA32A710; Tue, 12 Feb 2019 11:25: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=-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 3CC572A673 for ; Tue, 12 Feb 2019 11:25:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729484AbfBLLZD (ORCPT ); Tue, 12 Feb 2019 06:25:03 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:34739 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729466AbfBLLY6 (ORCPT ); Tue, 12 Feb 2019 06:24:58 -0500 Received: by mail-pl1-f195.google.com with SMTP id w4so1167586plz.1 for ; Tue, 12 Feb 2019 03:24:58 -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=KymeUwjgm1K3Y8XpxtdBBwhSts22Nd+Sh6iYQzrT0QA=; b=OMjXcPzd7yYj9evtSeUM1prt5u0z6HVdH8LS6bH42VWdypGwM9vtoVklqWPDQkHeTf ti/kuDFFLwT8nyVH7ey2UklJ5mL/btGhac3KGK9n/SbO3kGY5x3tBlZpEdldidnjwsk7 gh6HPtkGzpyqBNf6qpkxv+fUgyEKOx/+P3fFA= 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=KymeUwjgm1K3Y8XpxtdBBwhSts22Nd+Sh6iYQzrT0QA=; b=iXZsf0cKV8tRsk8K4uf0bZ1hbgATSvRb/5NwZ5VIr49UV+lBQjnI9MaM0X4TIWNVJK apOqtao6dlQru0rDr2yEzLvmhwRNSmn0VZ9EwOFP3nNLbwAAGHIGcfoGvAJF3UUCxV6Q zHN+i+CD0Td06Y5b/KrCzy0xRB88BzMcEw8E4kOgF9Q0g1YEqpsH7lqw/5OPFHeyqZlX 4R4mB93h/o14aBHEjP9MsYZp3xlbcHctMhuxJIMdTwFfOi4jEW+NlCRilH9AgKxzdLrw 6FkwCXfpyHz1hkyK8Yce6ON2wpYEuMel9cU2KOreT2bbJswUh+HIMdcICveEIFOhotJ2 Rrwg== X-Gm-Message-State: AHQUAuY6AnhJIm8ao3VIgL40Sntki3QlApYw8KLdKrymURMtXYJbIAp8 bpMXexlb6vhuLi+DydnuATcAIw== X-Google-Smtp-Source: AHgI3IZw60aAAchUpY16XpvuA+i8sfcAb3jxXBzGpTa0jZ273epu3pEv6Q9I0VV1zHZffTgRjiSqyQ== X-Received: by 2002:a17:902:b615:: with SMTP id b21mr3533559pls.338.1549970697857; Tue, 12 Feb 2019 03:24:57 -0800 (PST) Received: from localhost.localdomain ([115.97.184.151]) by smtp.gmail.com with ESMTPSA id q28sm22399460pgl.35.2019.02.12.03.24.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Feb 2019 03:24:57 -0800 (PST) From: Jagan Teki To: Dmitry Torokhov , Bastien Nocera , Rob Herring Cc: Henrik Rydberg , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Mark Rutland , Jagan Teki Subject: [PATCH v4 2/4] Input: goodix - Add AVDD28-supply regulator support Date: Tue, 12 Feb 2019 16:54:37 +0530 Message-Id: <20190212112439.2025-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190212112439.2025-1-jagan@amarulasolutions.com> References: <20190212112439.2025-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 | 44 ++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index f2d9c2c41885..e92b90be1ac2 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; @@ -761,6 +763,13 @@ static void goodix_config_cb(const struct firmware *cfg, void *ctx) complete_all(&ts->firmware_loading_complete); } +static void goodix_disable_regulator(void *arg) +{ + struct goodix_ts_data *ts = arg; + + regulator_disable(ts->avdd28); +} + static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -786,25 +795,46 @@ 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; + } + + error = devm_add_action_or_reset(&client->dev, + goodix_disable_regulator, ts); + 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; + 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,17 +853,21 @@ 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)