From patchwork Fri Nov 14 08:50:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 5304111 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5AC92C11AC for ; Fri, 14 Nov 2014 08:52:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 906D820149 for ; Fri, 14 Nov 2014 08:52:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF57F2017D for ; Fri, 14 Nov 2014 08:52:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754643AbaKNIv6 (ORCPT ); Fri, 14 Nov 2014 03:51:58 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:57110 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754730AbaKNIuo (ORCPT ); Fri, 14 Nov 2014 03:50:44 -0500 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NF00078QU13CY60@mailout4.w1.samsung.com>; Fri, 14 Nov 2014 08:53:27 +0000 (GMT) X-AuditID: cbfec7f4-b7f6c6d00000120b-ff-5465c262d149 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 63.0C.04619.262C5645; Fri, 14 Nov 2014 08:50:42 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync1.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NF00074XTWBTB70@eusync1.samsung.com>; Fri, 14 Nov 2014 08:50:42 +0000 (GMT) From: Krzysztof Kozlowski To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Russell King , Dan Williams , Vinod Koul , Ulf Hansson , Alan Stern , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org Cc: Kevin Hilman , Laurent Pinchart , Kyungmin Park , Marek Szyprowski , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski Subject: [PATCH v12 5/6] dmaengine: pl330: Add PM sleep support Date: Fri, 14 Nov 2014 09:50:32 +0100 Message-id: <1415955033-29093-6-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1415955033-29093-1-git-send-email-k.kozlowski@samsung.com> References: <1415955033-29093-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHLMWRmVeSWpSXmKPExsVy+t/xy7pJh1JDDA4+5bLYOGM9q8X0qRcY LVZP/ctq8fqFocXTzY+ZLM42vWG36Jy4hN1i1pS9TBaXd81hs/jce4TR4vZlXou1R+6yW9w9 dZTN4szpS6wWE35fYLM4vjbc4mXffhYHQY+W5h42j9kdM1k9Fu95yeSxaVUnm8eda3vYPLZc bWfxmH33B6NH35ZVjB4rVn9n9/i8SS6AK4rLJiU1J7MstUjfLoEr4/v/FUwFc/kq2t8cY2lg PM3dxcjJISFgIvHn9E52CFtM4sK99WxdjFwcQgJLGSUWtb5mAkkICfQxSZzbVgRiswkYS2xe vgSsSESgnVmib91UNpAEs8AiJommqYogtrCAvcSL3l0sIDaLgKpE/5tjYBt4Bdwl1tz5ygqx TU7i5LHJYDangIfE5I2rWCCWuUt8vvyHeQIj7wJGhlWMoqmlyQXFSem5hnrFibnFpXnpesn5 uZsYIWH+ZQfj4mNWhxgFOBiVeHgNClJDhFgTy4orcw8xSnAwK4nwKu0GCvGmJFZWpRblxxeV 5qQWH2Jk4uCUamD0LNvhaG1lpCch/j0l8/XpFUK7Py2P+CHcyq30Zb/Jpe/x4pf38Wl2MfSf eJx7uHWFkJxPp8bduNc582tP8+6fwSt45lyPUX78GkXhtQdkvuzUW/kv3efRhESZxqdzg7aU 8/r6Tk05eKCwXVPmrpNGvKp9t9Ifjr3p7Z9fHfjZVa/JLHdP1UaJpTgj0VCLuag4EQBGF6/A UQIAAA== Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 Add system suspend/resume capabilities to the pl330 driver so the amba bus clock could be also unprepared to conserve energy. Signed-off-by: Krzysztof Kozlowski --- drivers/dma/pl330.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index c3bd3584f261..e499bb118f0a 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2627,6 +2627,46 @@ static int pl330_dma_device_slave_caps(struct dma_chan *dchan, return 0; } +/* + * Runtime PM callbacks are provided by amba/bus.c driver. + * + * It is assumed here that IRQ safe runtime PM is chosen in probe and amba + * bus driver will only disable/enable the clock in runtime PM callbacks. + */ +static int __maybe_unused pl330_suspend(struct device *dev) +{ + struct amba_device *pcdev = to_amba_device(dev); + + pm_runtime_disable(dev); + + if (!pm_runtime_status_suspended(dev)) { + /* amba did not disable the clock */ + amba_pclk_disable(pcdev); + } + amba_pclk_unprepare(pcdev); + + return 0; +} + +static int __maybe_unused pl330_resume(struct device *dev) +{ + struct amba_device *pcdev = to_amba_device(dev); + int ret; + + ret = amba_pclk_prepare(pcdev); + if (ret) + return ret; + + if (!pm_runtime_status_suspended(dev)) + ret = amba_pclk_enable(pcdev); + + pm_runtime_enable(dev); + + return ret; +} + +static SIMPLE_DEV_PM_OPS(pl330_pm, pl330_suspend, pl330_resume); + static int pl330_probe(struct amba_device *adev, const struct amba_id *id) { @@ -2853,6 +2893,7 @@ static struct amba_driver pl330_driver = { .drv = { .owner = THIS_MODULE, .name = "dma-pl330", + .pm = &pl330_pm, }, .id_table = pl330_ids, .probe = pl330_probe,