From patchwork Thu Mar 21 08:21:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 178 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id EE73A3F9B9 for ; Thu, 21 Mar 2019 09:21:25 +0100 (CET) Received: by mail-pf1-f199.google.com with SMTP id 14sf4897567pfh.10 for ; Thu, 21 Mar 2019 01:21:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1553156484; cv=pass; d=google.com; s=arc-20160816; b=W70Cfo6GTjUoZR12h63VvAWMGKFVXASTpLBa8pi0gBv8iltr8hOjjcCyBazy+9b6GH sTwRdqDh6IzKaRu/W/icpD8nYnyc9RiUOjznElpLSSS/BfezYCxO10iHnKuhxifEwNEK si7AwBbhPeN2PLxwKQ972Pfx55nvRcL9mbT5D52NziZew+0nQGJpralaekdkczEFipOr ayQkLdh7b/SS5x1c3CNP6YOyQ9j3VrCSshQK0VVt1YXFFgDsWexk308YcjdZvWcDYaIq 2BhgqnaPGXrtsCXiGeTyz8EapaFThNBc5oRchsRLEOGjQIzGeD/t+obDRZ/6G26Dcfvp 4GUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=uMijz6cHH7uZLYVr3vbC5y9gkYPxgOAi3QKfQcvtiL0=; b=e2MDjSf2GdSc96ZvIZOFjZtSURfSkHTmdIVNNQFCzxlz0em4vy+OSv2l3K4S7z/R+O P6dxIflPlddk0JVi762SQtu7hemt2NhpNZRU8fhVhjWZ7WlaKIAhu2u/CqGdCzC6AtwK m1aetH2k580Rmlw2ypkbezSlOGDtglfrssm1iHpcXE8ELZa3HyDvX6UYd6fWkCSFj10a tHpox5EQLUMLMdvl9kYD9THEtJ/jx8AEO6BvTXib/ET2WME0HDn9HgeK3AkjSVca6RV3 r0Gq61ld8VHOj33g78woSfzWCd9XGpmV7AC6iQMeJqWkTZr/iUbBhMrJYDmUs5zyu4YK AIiA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BI0LV8Tt; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com 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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=uMijz6cHH7uZLYVr3vbC5y9gkYPxgOAi3QKfQcvtiL0=; b=WoM6yA8as9MYS2IyZRoGQe/Da6yP28nJqei3d2a4ijGzR7Gg39pHwFDtC4neqBTYBq yRRiPMY6HRHDTehFGMG68vHz5qVCMQkye+vpCO/FeMqtESQj1sxkU4gxIHEkK07qWCly 2LS/9R3cfesfFukTCQ6C+JzKhX5J7I7a1NQg4= 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=uMijz6cHH7uZLYVr3vbC5y9gkYPxgOAi3QKfQcvtiL0=; b=owWFxGge8FWazxgsCKp6eUSut8CJ9niklNCICblC9NrCbgOOVQjyv6QhFHAY1QrTSY uG+r9waTKT+NZ9gC8Y1dJ1GQZ+irF2Fy9r9mPJwxFScGd+9u1btfpieOr5Ph3AL7BybJ Gja7c97hFvDhJC+7Xsvyp90AhNY73Ar6yhtWif4NLShrrT62xntRDYPUIPq8V4dghHEa k4jbFCCs0tJ7+fWpW6qN6jizGu7KQ8HLSNBrzfj6cl2YceDMwrKynPe+NagY2lRewywo 9fhO2a4Y/FB0JJT2bwxNhlYA3BwBgWCbM3RfMO6QoYnuLBX34BNpkOVdrJ/0DIvTwWs+ Y72g== X-Gm-Message-State: APjAAAXapRu+JyDUT70IoBbXt80f1Ksi7CNUCrWYX0USkuelYz0BUvcE 0FgY5x7m/BF6KIxs7F9HGm16lYgm X-Google-Smtp-Source: APXvYqw8UvjwdPXO+T01H3KdSOmR51CEx9boWrZ7p0DT54h0Cp0F1r/+MRuAdYCMQIr7PDaVADBsSA== X-Received: by 2002:a62:7553:: with SMTP id q80mr103049pfc.17.1553156484805; Thu, 21 Mar 2019 01:21:24 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:164d:: with SMTP id 74ls2066034pfw.7.gmail; Thu, 21 Mar 2019 01:21:24 -0700 (PDT) X-Received: by 2002:a65:50c8:: with SMTP id s8mr2191071pgp.308.1553156484410; Thu, 21 Mar 2019 01:21:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553156484; cv=none; d=google.com; s=arc-20160816; b=tcCWftqdggR62u3IqhrdqGhLeyK/yLbkSU9FJpIIaME1tykl/13kJgE9QO4SwWMwnE N7kKGs+7KnJj7bFthRTNl+jXu5IWCjVZtd8PJqGuvqej2cRvccmjonDAOpNftCJRYw9T WhoslvWJFzJqa9j7m58zuCORIpS/MCdsj/5cdlkBY3+lNZRvLuiWfMRpxt0KJkW5sSVc CNp8rqrih5Qa+ZBwCRcMarGHwI89Gy6dCXroENXL8SOgiUouTysWSNyQ9r69lccR8udn NlegkP3MvDP0/orw/6fWacl70BL6MZjyngUg+YHZD/kvYuE0da0B5Xsh+hHyaLS/94ZL exyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=z/xVWk5dO82lfFtPDZKsgcg1B373xfEKm8H/gQlJdy0=; b=YSRO3DalWd8cqjfEYAl4Ts4t3hmmk/lQz8y6vPeoc/1EMq4wbKa09bXOK7BqsW8Cft 1kg1FxICajDe/Q6ULZZ/jP9KUgtpfsO1ru5fDshRbO4KKDDZnvbwQp7t+1YC8TV3GK7H JZZqm9VgOMhC2mG05o7hSSp63Q1AJEKEW7QSWUMG2GKphNN8qNQ1kLjk/bUnZOlEcDZq cioT3IgkHJlGth6GE458oYndLMZWDuEyufOwU7ZGhGHN1ywHvfIMjPTHmQlPkELl+oQs WRUhTtiEFKreiXFqBCJtbMKdOzklJMIFJe1ExiCQsldfctzQD7hkU54iJJ+Mlbpce9T8 5hXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BI0LV8Tt; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id o19sor4470347pfa.65.2019.03.21.01.21.24 for (Google Transport Security); Thu, 21 Mar 2019 01:21:24 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:aa7:82d7:: with SMTP id f23mr2151127pfn.114.1553156484117; Thu, 21 Mar 2019 01:21:24 -0700 (PDT) Received: from localhost.localdomain ([49.206.202.234]) by smtp.gmail.com with ESMTPSA id b138sm6288681pfb.48.2019.03.21.01.21.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Mar 2019 01:21:23 -0700 (PDT) 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 , linux-amarula@amarulasolutions.com, Michael Trimarchi , Jagan Teki Subject: [PATCH v7 2/4] Input: goodix - Add regulators suppot Date: Thu, 21 Mar 2019 13:51:02 +0530 Message-Id: <20190321082104.2874-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190321082104.2874-1-jagan@amarulasolutions.com> References: <20190321082104.2874-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=BI0LV8Tt; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Goodix CTP controllers require AVDD28, VDDIO regulators for power-on sequence. The delay between these regualtor operations as per Power-on Timing from datasheet[1] is 0 (T1 >= 0 usec). So, enable and disable these regulators in proper order using normal regulator functions without any delay in between. [1] GT5663 Datasheet_English_20151106_Rev.01 Signed-off-by: Jagan Teki --- drivers/input/touchscreen/goodix.c | 58 ++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index f57d82220a88..de5b80a08f41 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,8 @@ struct goodix_ts_data { struct touchscreen_properties prop; unsigned int max_touch_num; unsigned int int_trigger_type; + struct regulator *avdd28; + struct regulator *vddio; struct gpio_desc *gpiod_int; struct gpio_desc *gpiod_rst; u16 id; @@ -532,6 +535,24 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts) return -EINVAL; dev = &ts->client->dev; + ts->avdd28 = devm_regulator_get(dev, "AVDD28"); + if (IS_ERR(ts->avdd28)) { + error = PTR_ERR(ts->avdd28); + if (error != -EPROBE_DEFER) + dev_err(dev, + "Failed to get AVDD28 regulator: %d\n", error); + return error; + } + + ts->vddio = devm_regulator_get(dev, "VDDIO"); + if (IS_ERR(ts->vddio)) { + error = PTR_ERR(ts->vddio); + if (error != -EPROBE_DEFER) + dev_err(dev, + "Failed to get VDDIO regulator: %d\n", error); + return error; + } + /* Get the interrupt GPIO pin number */ gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_INT_NAME, GPIOD_IN); if (IS_ERR(gpiod)) { @@ -764,6 +785,17 @@ 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; + + if (!IS_ERR(ts->vddio)) + regulator_disable(ts->vddio); + + if (!IS_ERR(ts->avdd28)) + regulator_disable(ts->avdd28); +} + static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -789,6 +821,32 @@ static int goodix_ts_probe(struct i2c_client *client, if (error) return error; + error = devm_add_action_or_reset(&client->dev, + goodix_disable_regulator, ts); + if (error) + return error; + + /* power the controller */ + if (!IS_ERR(ts->avdd28)) { + error = regulator_enable(ts->avdd28); + if (error) { + dev_err(&client->dev, + "Failed to enable AVDD28 regulator: %d\n", + error); + return error; + } + } + + if (!IS_ERR(ts->vddio)) { + error = regulator_enable(ts->vddio); + if (error) { + dev_err(&client->dev, + "Failed to enable VDDIO regulator: %d\n", + error); + return error; + } + } + if (ts->gpiod_int && ts->gpiod_rst) { /* reset the controller */ error = goodix_reset(ts);