From patchwork Mon Dec 3 10:15:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10709103 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 B88FF13BF for ; Mon, 3 Dec 2018 10:16:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A85F52B069 for ; Mon, 3 Dec 2018 10:16:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B4B92B06E; Mon, 3 Dec 2018 10:16:28 +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 2B2CD2B069 for ; Mon, 3 Dec 2018 10:16:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726050AbeLCKQu (ORCPT ); Mon, 3 Dec 2018 05:16:50 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:45308 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbeLCKQ1 (ORCPT ); Mon, 3 Dec 2018 05:16:27 -0500 Received: by mail-wr1-f66.google.com with SMTP id v6so11451643wrr.12 for ; Mon, 03 Dec 2018 02:16:02 -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=MX6hF1WvT6/jnjg/Hvxrw/jbX1gmvj02z43j9IhctPk=; b=ctOtaMPGCmFOsRrqLmlS+E6Vf5lZ8qOMRYKnnfunQTf7jPddBD4Q5tt6umguIojCEq svzBj6FKXHKdjaclTZh12ET5K/gRPnVZLmEl1EYH7z9QIKUQ5QYGqsHgSQVKfgyKZaqw BCRT0CB1J7fK1u+aQQ6PLGAMYUdPKWUF/rHVU= 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=MX6hF1WvT6/jnjg/Hvxrw/jbX1gmvj02z43j9IhctPk=; b=VdCz8butpb1FTWsxAq7luB2+vrGTX93xbzzbLhp45srZnQVczeodqpx6mGPXR5t0kq nTOuGTAaDvUNlLhaHhpRhSV2ckNQSBSTdn43BjpNW2IH38W8QLlcKJd8odTMq+IXBjNf RqS2k7738zGvMpVD4uvvHo4mhhI+nDed7lbXKFDrHOlnD6LLEp+0ZZIcBghdTk9VPfpT WhwyPNLwm5/tIn382/oLT3MypyDa4HNxoazs2QYyWTYmbmtbuec4jQ3woC2mTMka+WiB QJIr8tJNKK7BkK6jD2wGyBnEH38Nk+TZW7wYDcCYbLXcFdJBfps0Irj0rHqDCcyOHKtd thSA== X-Gm-Message-State: AA+aEWa7nzSw3Fak61WKAE+gLLYl2Omlzc7SouFSTJ7BdT72Yp+59Rbr 0e92ZZB6DD3fdwfpGtH3+brt4A== X-Google-Smtp-Source: AFSGD/XZrkrloQ5/rvxj/0OMNRHVR0EheGpmH5OuudxmqmlBlo2LoDkZaoKHippBpsUviaxdeZIqzA== X-Received: by 2002:a5d:448f:: with SMTP id j15mr9244659wrq.108.1543832161996; Mon, 03 Dec 2018 02:16:01 -0800 (PST) Received: from localhost.localdomain (conf.hotelmediterraneo.com. [2.228.78.71]) by smtp.gmail.com with ESMTPSA id f192sm5832158wmd.12.2018.12.03.02.16.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Dec 2018 02:16:01 -0800 (PST) From: Jagan Teki To: Maxime Ripard , Rob Herring , Chen-Yu Tsai , Dmitry Torokhov , linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Lee Jones , linux-sunxi@googlegroups.com Cc: Jagan Teki Subject: [PATCH 6/9] Input: goodix - Add vcc-supply regulator support Date: Mon, 3 Dec 2018 15:45:44 +0530 Message-Id: <20181203101547.16835-6-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20181203101547.16835-1-jagan@amarulasolutions.com> References: <20181203101547.16835-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 vcc-supply property is need for some Goodix CTP controller like GT5663 where 3.3V external pull-up regulator connected via controller VCC pin. So, enable the regulator for those it attached the vcc-supply. Signed-off-by: Jagan Teki --- drivers/input/touchscreen/goodix.c | 39 ++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index f2d9c2c41885..7adcf1491609 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 *vcc; struct gpio_desc *gpiod_int; struct gpio_desc *gpiod_rst; u16 id; @@ -58,6 +60,7 @@ struct goodix_ts_data { #define GOODIX_GPIO_INT_NAME "irq" #define GOODIX_GPIO_RST_NAME "reset" +#define GOODIX_VCC_CTP_NAME "vcc" #define GOODIX_MAX_HEIGHT 4096 #define GOODIX_MAX_WIDTH 4096 @@ -525,12 +528,24 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts) { int error; struct device *dev; + struct regulator *regulator; struct gpio_desc *gpiod; if (!ts->client) return -EINVAL; dev = &ts->client->dev; + regulator = devm_regulator_get(dev, GOODIX_VCC_CTP_NAME); + if (IS_ERR(regulator)) { + error = PTR_ERR(regulator); + if (error != -EPROBE_DEFER) + dev_err(dev, "Failed to get vcc regulator: %d\n", + error); + return error; + } + + ts->vcc = regulator; + /* Get the interrupt GPIO pin number */ gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_INT_NAME, GPIOD_IN); if (IS_ERR(gpiod)) { @@ -786,25 +801,34 @@ static int goodix_ts_probe(struct i2c_client *client, if (error) return error; + /* power the controller */ + if (ts->vcc) { + error = regulator_enable(ts->vcc); + if (error) { + dev_err(&client->dev, "Controller fail to enable vcc\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,17 +847,22 @@ 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: + if (ts->vcc) + regulator_disable(ts->vcc); + return error; } static int goodix_ts_remove(struct i2c_client *client)