From patchwork Fri Dec 8 21:54:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mylene JOSSERAND X-Patchwork-Id: 10103391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C21A0602A0 for ; Fri, 8 Dec 2017 21:57:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3F3D28F7C for ; Fri, 8 Dec 2017 21:57:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A876E28F83; Fri, 8 Dec 2017 21:57:14 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2FFB928F7C for ; Fri, 8 Dec 2017 21:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JH82nUWeu+DbxULXfQtk+dAAz03babF6hRaYJERic+k=; b=Ws1iJuwmu1fGan eX3jV5SNc6HArEgf3dLIbMqmSaTZBbv07RgUcgERq2mO8iiVxD3Vi6wtBxpUQNcPp3vE4+zkOFXnL 3HQXI3g/YLE+qX9c+X1ZefJE6kF60JLL1cUf/xhWmWA4PNYganxIDsPgMpsbAhLCREVJWl1qWKNK9 TdMd51l4EhMEQzn4I+flp0HtwwBQeTHhUa52fHXQB04/D4mjvtqpbbEWL0k4FY4mbcpM3742cZyCD KmQ3C/UONQJVBrlYzhW4hocGmZdZSdSp5sMYTgW38aeoLdc+etV5FYnpBiyiInUlV1oYbB7bE7Jv4 w2ucpvE0x7ajEEUSXhfg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eNQdl-0004jT-O0; Fri, 08 Dec 2017 21:57:05 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eNQc0-0002GG-KL for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2017 21:55:22 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id B92872093A; Fri, 8 Dec 2017 22:54:58 +0100 (CET) Received: from dell-desktop.home (vol75-h03-176-137-37-244.dsl.sta.abo.bbox.fr [176.137.37.244]) by mail.free-electrons.com (Postfix) with ESMTPSA id 06EE120950; Fri, 8 Dec 2017 22:54:47 +0100 (CET) From: =?UTF-8?q?Myl=C3=A8ne=20Josserand?= To: robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, maxime.ripard@free-electrons.com, wens@csie.org, dmitry.torokhov@gmail.com, linux-input@vger.kernel.org Subject: [PATCH 4/5] Input: edt-ft5x06 - Add support for regulator Date: Fri, 8 Dec 2017 22:54:18 +0100 Message-Id: <20171208215419.30396-5-mylene.josserand@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171208215419.30396-1-mylene.josserand@free-electrons.com> References: <20171208215419.30396-1-mylene.josserand@free-electrons.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171208_135516_837148_698E4041 X-CRM114-Status: GOOD ( 13.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, simon.budig@kernelconcepts.de, mylene.josserand@free-electrons.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add the support of regulator to use them as VCC source. Signed-off-by: Mylène Josserand --- drivers/input/touchscreen/edt-ft5x06.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index c53a3d7239e7..44b0e04a8f35 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 *supply; struct gpio_desc *reset_gpio; struct gpio_desc *wake_gpio; @@ -993,6 +995,23 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, tsdata->max_support_points = chip_data->max_support_points; + tsdata->supply = devm_regulator_get_optional(&client->dev, "power"); + if (IS_ERR(tsdata->supply)) { + error = PTR_ERR(tsdata->supply); + dev_err(&client->dev, "failed to request regulator: %d\n", + error); + return error; + }; + + if (tsdata->supply) { + error = regulator_enable(tsdata->supply); + if (error < 0) { + dev_err(&client->dev, "failed to enable supply: %d\n", + error); + return error; + } + } + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(tsdata->reset_gpio)) { @@ -1122,20 +1141,34 @@ 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); + if (tsdata->supply) + regulator_disable(tsdata->supply); + return 0; } 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); + if (tsdata->supply) { + ret = regulator_enable(tsdata->supply); + if (ret < 0) { + dev_err(dev, "failed to enable supply: %d\n", ret); + return ret; + } + } + return 0; }