Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp498509imm; Wed, 25 Jul 2018 00:37:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfCy7KJ3b2/Z51NFPPi2mbKsYR4eMbT5+CWuSso4pIe3ginuLU9/Be/1FjXo7f6bvLMwb07 X-Received: by 2002:a17:902:6e09:: with SMTP id u9-v6mr19488044plk.13.1532504255389; Wed, 25 Jul 2018 00:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532504255; cv=none; d=google.com; s=arc-20160816; b=wzPind8PB3YW9bLC06MFE7LieKn35lla2TqcEZ+zVH/s/Q4XlhCws25tX8QduUzGAJ WcY9GQNruv5a5dZJbbR9sF2bAdjHLXp7aXXvrGvtY2x0EHA6Az5p1Qwa3/GV1Yo3inPv wPqQX4ZyHp8/fevSxRbbmjq6biecqeZ4KB/f1S0WHDQxWgOj2+hbGHW53wVDc9wkbBj9 jG86xvoBHGcTRMOUA+2zyJBxSr30A+t8ct9lxMaeendSJdQYXRIitnQy3W13u9DkYnro wJAINCXnUq1oeIVfPGNQwuVWO4qYh6O//6aUs1tAKBXy7mpukIJi5UyfxrQyo7Q/jB+n 8lqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ybpHxpxNYVdP1CoNuUjaf3zjz9+p75rmcHoxfwPISWw=; b=hRUoLL7B6P50NDibIkHM5rPnbecYr3sVzn13RpRmlB5MMkAxwVxwOh9hfVA7cAsUe7 c6tU3TNaiBWpm0nnwUY29Lf4NUTBQtdvaSM43hpgKpNtiFuP+vcP4D9ecHcrk29QtZQ0 tcofDqJ5oisUWy08JLIY0yfA/J99gRJKdJ8htF0mbM6MD2IXMLCb0O5CBFS0oc5ePb0l Y3Z2t9AkDMNYOhGgK+BC4r1+6JkxOjso4Jco/5XocYTrV61jk7k84p0VtfkaV4dy96q8 SmCkr4WbSGPKLuAvS2WujAza7ZcQE/fIQ9W5Ru4g6Vh7stn5FUXbtaQZHc0Ki7JXwzb4 p23w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13-v6si13371731pgh.642.2018.07.25.00.37.20; Wed, 25 Jul 2018 00:37:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728608AbeGYIqy (ORCPT + 99 others); Wed, 25 Jul 2018 04:46:54 -0400 Received: from mail.bootlin.com ([62.4.15.54]:54106 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728421AbeGYIqw (ORCPT ); Wed, 25 Jul 2018 04:46:52 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id E40C5207AB; Wed, 25 Jul 2018 09:36:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from dell-desktop.home (AAubervilliers-681-1-78-122.w90-88.abo.wanadoo.fr [90.88.20.122]) by mail.bootlin.com (Postfix) with ESMTPSA id 96C9320618; Wed, 25 Jul 2018 09:36:24 +0200 (CEST) From: =?UTF-8?q?Myl=C3=A8ne=20Josserand?= To: dmitry.torokhov@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, thomas.petazzoni@bootlin.com, mylene.josserand@bootlin.com Subject: [PATCH v4 1/3] Input: edt-ft5x06 - Add support for regulator Date: Wed, 25 Jul 2018 09:34:08 +0200 Message-Id: <20180725073410.730-2-mylene.josserand@bootlin.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180725073410.730-1-mylene.josserand@bootlin.com> References: <20180725073410.730-1-mylene.josserand@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the support of regulator to use it as VCC source. Signed-off-by: Mylène Josserand Reviewed-by: Rob Herring --- .../bindings/input/touchscreen/edt-ft5x06.txt | 1 + drivers/input/touchscreen/edt-ft5x06.c | 43 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt index 025cf8c9324a..48e975b9c1aa 100644 --- a/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt +++ b/Documentation/devicetree/bindings/input/touchscreen/edt-ft5x06.txt @@ -30,6 +30,7 @@ Required properties: Optional properties: - reset-gpios: GPIO specification for the RESET input - wake-gpios: GPIO specification for the WAKE input + - vcc-supply: Regulator that supplies the touchscreen - pinctrl-names: should be "default" - pinctrl-0: a phandle pointing to the pin settings for the diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 1e18ca0d1b4e..dcde719094f7 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -39,6 +39,7 @@ #include #include #include +#include #define WORK_REGISTER_THRESHOLD 0x00 #define WORK_REGISTER_REPORT_RATE 0x08 @@ -91,6 +92,7 @@ struct edt_ft5x06_ts_data { struct touchscreen_properties prop; u16 num_x; u16 num_y; + struct regulator *vcc; struct gpio_desc *reset_gpio; struct gpio_desc *wake_gpio; @@ -963,6 +965,13 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) } } +static void edt_ft5x06_disable_regulator(void *arg) +{ + struct edt_ft5x06_ts_data *data = arg; + + regulator_disable(data->vcc); +} + static int edt_ft5x06_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -991,6 +1000,28 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, tsdata->max_support_points = chip_data->max_support_points; + tsdata->vcc = devm_regulator_get(&client->dev, "vcc"); + if (IS_ERR(tsdata->vcc)) { + error = PTR_ERR(tsdata->vcc); + if (error != -EPROBE_DEFER) + dev_err(&client->dev, "failed to request regulator: %d\n", + error); + return error; + } + + error = regulator_enable(tsdata->vcc); + if (error < 0) { + dev_err(&client->dev, "failed to enable vcc: %d\n", + error); + return error; + } + + error = devm_add_action_or_reset(&client->dev, + edt_ft5x06_disable_regulator, + tsdata); + if (error) + return error; + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(tsdata->reset_gpio)) { @@ -1120,9 +1151,12 @@ static int edt_ft5x06_ts_remove(struct i2c_client *client) static int __maybe_unused edt_ft5x06_ts_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); + struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); if (device_may_wakeup(dev)) enable_irq_wake(client->irq); + else + regulator_disable(tsdata->vcc); return 0; } @@ -1130,9 +1164,18 @@ static int __maybe_unused edt_ft5x06_ts_suspend(struct device *dev) static int __maybe_unused edt_ft5x06_ts_resume(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); + struct edt_ft5x06_ts_data *tsdata = i2c_get_clientdata(client); + int ret; if (device_may_wakeup(dev)) disable_irq_wake(client->irq); + else { + ret = regulator_enable(tsdata->vcc); + if (ret < 0) { + dev_err(dev, "failed to enable vcc: %d\n", ret); + return ret; + } + } return 0; } -- 2.11.0