From patchwork Thu Apr 21 20:11:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 8903681 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A9C049F457 for ; Thu, 21 Apr 2016 20:12:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C75492025A for ; Thu, 21 Apr 2016 20:12:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9BDE2026F for ; Thu, 21 Apr 2016 20:12:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751794AbcDUUMZ (ORCPT ); Thu, 21 Apr 2016 16:12:25 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:52198 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751742AbcDUUMX (ORCPT ); Thu, 21 Apr 2016 16:12:23 -0400 Received: from localhost.localdomain ([95.91.39.67]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0M3C4d-1bliNv1Vot-00swk6; Thu, 21 Apr 2016 22:11:32 +0200 From: Stefan Wahren To: Jonathan Cameron , Dmitry Torokhov , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Marek Vasut Cc: Fabio Estevam , Juergen Borleis , linux-iio@vger.kernel.org, linux-input@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stefan Wahren Subject: [PATCH RFT V2 3/3] iio: mxs-lradc: implement suspend/resume support Date: Thu, 21 Apr 2016 20:11:18 +0000 Message-Id: <1461269478-449-4-git-send-email-stefan.wahren@i2se.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1461269478-449-1-git-send-email-stefan.wahren@i2se.com> References: <1461269478-449-1-git-send-email-stefan.wahren@i2se.com> X-Provags-ID: V03:K0:xgJICE5nrBChDBzTt0ox9BXxTNxk3JD4OgHBMWIHbe2ssh5zd+p P/jb0dChx6mFJMaq/QV9pymn9HmwLb6KyXyCvYmsGvcbwhjMcR7owcy/6cDdyB13H5fFFb6 3PVvD/CXWh1ys05zqcmwkF2fAefsAqew9ytYnjdQ1/8P77jlKIQUpWeeMrr0rlQzkMCAux2 f0+irOKrFBexHX+7fu96w== X-UI-Out-Filterresults: notjunk:1; V01:K0:FYDrvdaOCjU=:GGYGjO3LepfF5Cxho1xhD9 w7MOjV0TOSdfG+4L+EcfMkBUre7ZE1xl1LP6laqmHdWMdEyZixZsS8ZR8vwaFf7Fnh3cYE9aS Lv1h9D/yaLSdEMe/NEfxaKn06ZtP2Lcon2gJv+DQJUspnypmfJ2dwUP7XjTFnIjjGNM402Vja mJmOlEaFGgjB21A3DdNtqaEuW2il2/89a/KEGsjkP3C4nRY7KpwLpBr85RYwx08Ug/32DWdh9 JSagX/TWzk8nPmf0fjtCOfIGiaNSZjvlaWomq33x4XQnpMzfj6gD9zIJvPRamQDh0UFq1p83U v8xMgEIw7VV6tL3HDwZyQxNPiUAExgKIlcK1MrwzkGA9+sJN6GAszpHWoojDEw3SUmU/uU8iT 9pG2+1eOzGwOICJukAvAJSluNyC2l0QKcUqVY4bLX82SjIG6yuVEOcHaItcuT+L/nFk+DcOlQ XE86DmMt21kfZkxiGNrJN2EDV6jorHHZGa3IjWLAXk2edslBeFWK1Jkk26PRFJQcwZiZpn411 Gm6KV6Ra1hGTPqonbxqycsiuOaLBP2x1yOowHoLL6Lg+9QfZZfyDJJ3Gn+B1IDtMD6MwcUOm2 8j9QYUSTaP3PiW74neVI/8UhaSK1YJ9Jt//HyT7Y9VoAgZUfccnskpIHLML0kaH0CWGcj/JEc Njb4NuNeptdRa2OeFc+gkxU1L5r0Omzazvd9Vzxp6fJUQjFzNQ/BftUCwhJAbAay9VnY= Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch implements suspend/resume support for mxs-lradc. It's possible to use the touchscreen as wakeup source. Signed-off-by: Stefan Wahren Reviewed-by: Marek Vasut --- drivers/iio/adc/mxs-lradc.c | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/iio/adc/mxs-lradc.c b/drivers/iio/adc/mxs-lradc.c index cfc558f..6bd387f 100644 --- a/drivers/iio/adc/mxs-lradc.c +++ b/drivers/iio/adc/mxs-lradc.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -1745,10 +1746,70 @@ static int mxs_lradc_remove(struct platform_device *pdev) return 0; } +static int __maybe_unused mxs_lradc_suspend(struct device *dev) +{ + struct iio_dev *iio = dev_get_drvdata(dev); + struct mxs_lradc *lradc = iio_priv(iio); + struct input_dev *input = lradc->ts_input; + int ret = 0; + + if (input) { + mutex_lock(&input->mutex); + + /* Enable touchscreen wakeup irq */ + if (input->users && device_may_wakeup(dev)) + ret = enable_irq_wake(lradc->irq[0]); + else + mxs_lradc_disable_ts(lradc); + + mutex_unlock(&input->mutex); + } + + if (ret) + return ret; + + mxs_lradc_hw_stop(lradc); + + clk_disable_unprepare(lradc->clk); + + return ret; +} + +static int __maybe_unused mxs_lradc_resume(struct device *dev) +{ + struct iio_dev *iio = dev_get_drvdata(dev); + struct mxs_lradc *lradc = iio_priv(iio); + struct input_dev *input = lradc->ts_input; + int ret; + + ret = clk_prepare_enable(lradc->clk); + if (ret) + return ret; + + mxs_lradc_hw_init(lradc); + + if (input) { + mutex_lock(&input->mutex); + + /* Disable touchscreen wakeup irq */ + if (input->users && device_may_wakeup(dev)) + ret = disable_irq_wake(lradc->irq[0]); + else + mxs_lradc_enable_touch_detection(lradc); + + mutex_unlock(&input->mutex); + } + + return ret; +} + +static SIMPLE_DEV_PM_OPS(mxs_lradc_pm_ops, mxs_lradc_suspend, mxs_lradc_resume); + static struct platform_driver mxs_lradc_driver = { .driver = { .name = DRIVER_NAME, .of_match_table = mxs_lradc_dt_ids, + .pm = &mxs_lradc_pm_ops, }, .probe = mxs_lradc_probe, .remove = mxs_lradc_remove,