From patchwork Thu Jun 22 05:44:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhiyong.tao" X-Patchwork-Id: 9803493 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 6E4DD600C5 for ; Thu, 22 Jun 2017 05:45:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 598DC285C5 for ; Thu, 22 Jun 2017 05:45:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B4C7285CA; Thu, 22 Jun 2017 05:45:48 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,UNPARSEABLE_RELAY autolearn=unavailable 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 07F19285C5 for ; Thu, 22 Jun 2017 05:45:48 +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=liE9hQWG4QmQwVXDTLlGNAUFdvsE8WXU9KCwgyw0Acg=; b=aVHN0RSlCf3QTN yZAxu/guPvL/JvjhEQVuMVj2JlI93TdHwct+iH4flY96FXDRAkgHVAokJYxBxrtsRAy7DRJYuLMJ/ uGOB9ifkLjnPnxSTp9tNTqffj5MbWtPgBrflLDHQtDo5CFPi3e+7H/I4qHTfGT1bjAWg+tKu4yWLx 7fcBzBBP3HZvgmUVExl0IBT8jlkkxmEvewrFXVIZJYTX0PO3jKrjySVBO8bNWnymKFue3dlBi/GO7 idJHuylXd5Q9kqsTPXzzUxi5zlfxDZVSRXSRTitf7ocqtSjBGJEBdwGH2kQB9kMokkPId4bKy/2CP PLzsix4l1qWXMJUoFTlQ==; 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 1dNuw7-0004T7-Bz; Thu, 22 Jun 2017 05:45:47 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dNuw0-0004Ho-MM; Thu, 22 Jun 2017 05:45:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZNfVF38j3nv5FDZFw0/lPaVwonDQS8xjGCvNuiaKvrA=; b=V35o2qTnUiCIEH7BG9HgcJQBi flTBNXoVifcoo1r7Lz4FOue+1Z6sLKE+8oR26lh+3SR7sZpblBLg6riJ9WHleiEf82/4TwFp19UTd fqh0UyN/oKEmAjAd3lH6y6IKeRsY1ZDGGf8ZM+foLiUz29IaCannTqj6iedknPxk26DHncCw4/tkp sSDVU6rctm+mp1pqIOpSV5NuwhggnTFO+Bv3u6gk9JJJGK3CJM1XJXrmbBtO2uYtyfHq2WTXTJhjO F1H7Jr/cDo+N/pP6REr4pOsXYF+unSefIKFA4fbWQuK9WOnEdyIpTelGm/HqBIC/+bDC06FYnqh6n aDljfUfIg==; Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dNuvx-0006Ju-ED; Thu, 22 Jun 2017 05:45:38 +0000 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 224068703; Thu, 22 Jun 2017 13:44:59 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Thu, 22 Jun 2017 13:44:57 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Thu, 22 Jun 2017 13:44:56 +0800 From: Zhiyong Tao To: , , , , Subject: [PATCH 2/3] iio: adc: mt7622: add support for suspend/resume. Date: Thu, 22 Jun 2017 13:44:33 +0800 Message-ID: <1498110274-18678-3-git-send-email-zhiyong.tao@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1498110274-18678-1-git-send-email-zhiyong.tao@mediatek.com> References: <1498110274-18678-1-git-send-email-zhiyong.tao@mediatek.com> MIME-Version: 1.0 X-MTK: N X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, srv_heupstream@mediatek.com, linux-iio@vger.kernel.org, Zhiyong Tao , s.hauer@pengutronix.de, sean.wang@mediatek.com, liguo.zhang@mediatek.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com, yingjoe.chen@mediatek.com, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch supports auxadc suspend/resume flow. Disable auxadc clk and power in suspend function. Enable axuadc clk and power in resume function. Signed-off-by: Zhiyong Tao --- drivers/iio/adc/mt6577_auxadc.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c index 2d104c8..2dd7c74 100644 --- a/drivers/iio/adc/mt6577_auxadc.c +++ b/drivers/iio/adc/mt6577_auxadc.c @@ -184,6 +184,37 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev, .read_raw = &mt6577_auxadc_read_raw, }; +static int mt6577_auxadc_resume(struct device *dev) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev); + int ret; + + ret = clk_prepare_enable(adc_dev->adc_clk); + if (ret) { + pr_err("failed to enable auxadc clock\n"); + return ret; + } + + mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC, + MT6577_AUXADC_PDN_EN, 0); + mdelay(MT6577_AUXADC_POWER_READY_MS); + + return 0; +} + +static int mt6577_auxadc_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev); + + mt6577_auxadc_mod_reg(adc_dev->reg_base + MT6577_AUXADC_MISC, + 0, MT6577_AUXADC_PDN_EN); + clk_disable_unprepare(adc_dev->adc_clk); + + return 0; +} + static int mt6577_auxadc_probe(struct platform_device *pdev) { struct mt6577_auxadc_device *adc_dev; @@ -269,6 +300,11 @@ static int mt6577_auxadc_remove(struct platform_device *pdev) return 0; } +static const struct dev_pm_ops mt6577_auxadc_pm_ops = { + .suspend = mt6577_auxadc_suspend, + .resume = mt6577_auxadc_resume, +}; + static const struct of_device_id mt6577_auxadc_of_match[] = { { .compatible = "mediatek,mt2701-auxadc", }, { .compatible = "mediatek,mt8173-auxadc", }, @@ -280,6 +316,7 @@ static int mt6577_auxadc_remove(struct platform_device *pdev) .driver = { .name = "mt6577-auxadc", .of_match_table = mt6577_auxadc_of_match, + .pm = &mt6577_auxadc_pm_ops, }, .probe = mt6577_auxadc_probe, .remove = mt6577_auxadc_remove,