From patchwork Sun May 9 22:34:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 432880 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp2335750jao; Sun, 9 May 2021 15:34:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjbpaCSw3oZAvoWZTRaRebJ4DFGKZarU2H33Ox20h49wxU0TQ2cHEg2/rfq7B5mTf9Is9z X-Received: by 2002:a17:906:1b09:: with SMTP id o9mr22571396ejg.102.1620599677637; Sun, 09 May 2021 15:34:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620599677; cv=none; d=google.com; s=arc-20160816; b=dAtztguRKicEvVZyIKWDeC3twMU/dL9adQLBAfpA91/4L3VnZE9C9PlJ/SCr+0uy31 rNkb43SrEaXphIP/F8YSQxcsORSeeiPWin0DXBpWmvT7RCjo0uCK/h4vRi0pmYSe7Yq2 69CPj1SYquVK5u+Mt8dtzsMzsE9NqS9Z6PT3wLLf9BluNkiRZu2zIl+wdGlJ9/zD1qvl yWEc1fCw2ol+W3tuZRdQbnZQZbNccUIE+JjixdiFktjxqSqxyU2pwOup4arYQrulnpPz zOuCyuCYf4FCy5Iycc1uMuLPjrZZDp1bURNSzKG34dltY+rk670MlELa5V2OF9EvnOBe 4UwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/XEFvoPEC4OvoR2e/02RptgwEhAcqU67gkc7kt6cnxs=; b=H6fxpnz/SnfFE5sCx0DyeAq/78HVlbVG/9v/SDjbbcsKAMTpKwg743F6VJYVFZtBiT 3NlxjPDk0Gw7tiyMQETNICE0jIXDeAvi2+cIiwDsIy7i4hNbFO0Ulnux+hbH26Qvcy/+ s6OWRQnCZIWa/yMHCw3m5+rJXpQ7AAk6w5JslsNrN5uYQS66m/fNwpwpH9Cmwas7gDOR AbfyWojx9x9vc/JJ9qh8UM+X9hV0EZuWYnCjxhBe6ul3XiBOQfv3QeIXzzEFEzm4PVdZ DZF0OOjM6iX1HOY41uRJ+57rQPJKQVNi34N4FTJwOtFNSI3G4ecFx/eG+3mcJgxI5/06 v6tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xndKYbbw; spf=pass (google.com: domain of linux-input-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n2si8741324eda.470.2021.05.09.15.34.37; Sun, 09 May 2021 15:34:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-input-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xndKYbbw; spf=pass (google.com: domain of linux-input-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229847AbhEIWfj (ORCPT + 1 other); Sun, 9 May 2021 18:35:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbhEIWfi (ORCPT ); Sun, 9 May 2021 18:35:38 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDFE8C061573 for ; Sun, 9 May 2021 15:34:33 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id h4so20604037lfv.0 for ; Sun, 09 May 2021 15:34:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/XEFvoPEC4OvoR2e/02RptgwEhAcqU67gkc7kt6cnxs=; b=xndKYbbwsWOL44jQWznLh01SJuKlxf9TFsfpLaVW2PXcvwI2AH9SooYs7kIe07vS2v PY4UWTyhodMl7F4kzjPAwg1D+iDeUgL+NNncnU+4X3+OU0B4UFylY4ddnmeCz1Ho8Cc7 pRFYCi9fLzD0yuvEweM/KI6/ALJ7ostMq6VQ1+kX7y25la5pSCDiaxt+cHIaKDwmqJAD mQi0RzeEhDCXIt7L6J+YMbGFNJOlBjp9VX6R3qZzsGWuHSp/sV4CEAYJ4vo0bRjejS5G EALJM5fAO0VeoC4x6ICE45gAZ8PtEyGAR3LXXf2KsGamWBhZVMjgFdjfxWqadyorinb/ xfJw== 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=/XEFvoPEC4OvoR2e/02RptgwEhAcqU67gkc7kt6cnxs=; b=EZZzIXTmXvmX8Re9mOeUAn4Tv+tsBB9b0Yjne9f7o7ElU5LP83BBdke+7zuN0SZR8f /wcMeCdswFw4seMCa5uxKN2AhYN5CM3Dd4ZLhC74WYh0Mw5PrGxKJRXfCW+vpM7qfj65 J78HiBIhWC1exieDKjUZQv9LxYB6wQN3jQSF4eo6qi2jTFMEBu0EFIKb6eJC0gFN1M+o yomwM9bVT/zFvCFiLS3vHrK+j3GQdnOWJ9Obxnxp9Johdeo3DYaTJBtYh8ZP1X1YMXdr p6EIRqlizsKAxDd/76V73bjWJBxb9alfMNt6V2Ut47l7+LjQwgNl0IKh0SHme8dHSOyC MBfA== X-Gm-Message-State: AOAM533ih1jM+KX6Jy9ICmiAFW5hEqsMx9ID4sJCjMtEfcgVwMgzsjx8 5YAr86HNQSfrg/BaTp1e8iIZhuuDvUtDOg== X-Received: by 2002:a19:f707:: with SMTP id z7mr14421374lfe.653.1620599672289; Sun, 09 May 2021 15:34:32 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id a16sm2022257lfl.51.2021.05.09.15.34.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 May 2021 15:34:32 -0700 (PDT) From: Linus Walleij To: Ferruh Yigit , Dmitry Torokhov , Javier Martinez Canillas Cc: Henrik Rydberg , linux-input@vger.kernel.org, Linus Walleij Subject: [PATCH 3/3 v5] Input: cyttsp - Obtain regulators Date: Mon, 10 May 2021 00:34:16 +0200 Message-Id: <20210509223416.346104-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210509223416.346104-1-linus.walleij@linaro.org> References: <20210509223416.346104-1-linus.walleij@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org The CYTTSP TMA340 chips have two supplies: VCPIN and VDD for analog and digital voltage respectively. Add some minimal code to obtain and enable these regulators if need be. Reviewed-by: Javier Martinez Canillas Signed-off-by: Linus Walleij --- ChangeLog v3->v5: - Rebase on v5.13-rc1 ChangeLog v1->v3: - Collect Javier's reviewed-by. --- drivers/input/touchscreen/cyttsp_core.c | 30 +++++++++++++++++++++++-- drivers/input/touchscreen/cyttsp_core.h | 2 ++ 2 files changed, 30 insertions(+), 2 deletions(-) -- 2.30.2 diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c index 106dd4962785..5af4d034b36b 100644 --- a/drivers/input/touchscreen/cyttsp_core.c +++ b/drivers/input/touchscreen/cyttsp_core.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "cyttsp_core.h" @@ -628,6 +629,19 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, ts->bus_ops = bus_ops; ts->irq = irq; + /* + * VCPIN is the analog voltage supply + * VDD is the digital voltage supply + */ + ts->regulators[0].supply = "vcpin"; + ts->regulators[1].supply = "vdd"; + error = devm_regulator_bulk_get(dev, ARRAY_SIZE(ts->regulators), + ts->regulators); + if (error) { + dev_err(dev, "Failed to get regulators: %d\n", error); + return ERR_PTR(error); + } + ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(ts->reset_gpio)) { error = PTR_ERR(ts->reset_gpio); @@ -673,20 +687,32 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops, return ERR_PTR(error); } + error = regulator_bulk_enable(ARRAY_SIZE(ts->regulators), + ts->regulators); + if (error) { + dev_err(dev, "Cannot enable regulators: %d\n", error); + return ERR_PTR(error); + } + cyttsp_hard_reset(ts); error = cyttsp_power_on(ts); if (error) - return ERR_PTR(error); + goto err_dis_reg; error = input_register_device(input_dev); if (error) { dev_err(ts->dev, "failed to register input device: %d\n", error); - return ERR_PTR(error); + goto err_dis_reg; } return ts; + +err_dis_reg: + regulator_bulk_disable(ARRAY_SIZE(ts->regulators), + ts->regulators); + return ERR_PTR(error); } EXPORT_SYMBOL_GPL(cyttsp_probe); diff --git a/drivers/input/touchscreen/cyttsp_core.h b/drivers/input/touchscreen/cyttsp_core.h index 9bc4fe7e6ac5..8eba9d8ba74a 100644 --- a/drivers/input/touchscreen/cyttsp_core.h +++ b/drivers/input/touchscreen/cyttsp_core.h @@ -23,6 +23,7 @@ #include #include #include +#include #define CY_NUM_RETRY 16 /* max number of retries for read ops */ @@ -122,6 +123,7 @@ struct cyttsp { enum cyttsp_state state; bool suspended; + struct regulator_bulk_data regulators[2]; struct gpio_desc *reset_gpio; bool use_hndshk; u8 act_dist;