From patchwork Thu Jun 13 09:53:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mayuresh Kulkarni X-Patchwork-Id: 2715471 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 515A09F3DD for ; Thu, 13 Jun 2013 10:32:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2DEAF20185 for ; Thu, 13 Jun 2013 10:32:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 02A6B2017A for ; Thu, 13 Jun 2013 10:32:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D9132E64B7 for ; Thu, 13 Jun 2013 03:32:28 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from hqemgate03.nvidia.com (hqemgate03.nvidia.com [216.228.121.140]) by gabe.freedesktop.org (Postfix) with ESMTP id DD8ADE5F38 for ; Thu, 13 Jun 2013 02:54:36 -0700 (PDT) Received: from hqnvupgp08.nvidia.com (Not Verified[216.228.121.13]) by hqemgate03.nvidia.com id ; Thu, 13 Jun 2013 03:01:33 -0700 Received: from hqemhub01.nvidia.com ([172.20.12.94]) by hqnvupgp08.nvidia.com (PGP Universal service); Thu, 13 Jun 2013 02:54:31 -0700 X-PGP-Universal: processed; by hqnvupgp08.nvidia.com on Thu, 13 Jun 2013 02:54:31 -0700 Received: from mkulkarni-linux.nvidia.com (172.20.144.16) by hqemhub01.nvidia.com (172.20.150.30) with Microsoft SMTP Server (TLS) id 8.3.298.1; Thu, 13 Jun 2013 02:54:30 -0700 From: Mayuresh Kulkarni To: , , , , , Subject: [PATCH v2 3/4] gpu: host1x: add runtime pm support for dc Date: Thu, 13 Jun 2013 15:23:37 +0530 Message-ID: <1371117218-2326-4-git-send-email-mkulkarni@nvidia.com> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1371117218-2326-1-git-send-email-mkulkarni@nvidia.com> References: <1371117218-2326-1-git-send-email-mkulkarni@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 13 Jun 2013 03:29:55 -0700 Cc: Mayuresh Kulkarni , linux-kernel@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 As of now, the dc clock is enabled in its .probe via runtime pm and disabled in .remove Signed-off-by: Mayuresh Kulkarni --- drivers/gpu/host1x/drm/dc.c | 60 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c index 5360e5a..8e669a9 100644 --- a/drivers/gpu/host1x/drm/dc.c +++ b/drivers/gpu/host1x/drm/dc.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "host1x_client.h" #include "dc.h" @@ -1128,9 +1129,7 @@ static int tegra_dc_probe(struct platform_device *pdev) return PTR_ERR(dc->clk); } - err = clk_prepare_enable(dc->clk); - if (err < 0) - return err; + platform_set_drvdata(pdev, dc); regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); dc->regs = devm_ioremap_resource(&pdev->dev, regs); @@ -1147,6 +1146,15 @@ static int tegra_dc_probe(struct platform_device *pdev) dc->client.ops = &dc_client_ops; dc->client.dev = &pdev->dev; +#ifdef CONFIG_PM_RUNTIME + pm_runtime_enable(&pdev->dev); + pm_runtime_get_sync(&pdev->dev); +#else + err = clk_prepare_enable(dc->clk); + if (err < 0) + return err; +#endif + err = tegra_dc_rgb_probe(dc); if (err < 0 && err != -ENODEV) { dev_err(&pdev->dev, "failed to probe RGB output: %d\n", err); @@ -1160,8 +1168,6 @@ static int tegra_dc_probe(struct platform_device *pdev) return err; } - platform_set_drvdata(pdev, dc); - return 0; } @@ -1178,11 +1184,52 @@ static int tegra_dc_remove(struct platform_device *pdev) return err; } +#ifdef CONFIG_PM_RUNTIME + pm_runtime_put(&pdev->dev); + pm_runtime_disable(&pdev->dev); +#endif + + return 0; +} + +#ifdef CONFIG_PM_RUNTIME +static int tegra_dc_runtime_suspend(struct device *dev) +{ + struct tegra_dc *dc; + + dc = dev_get_drvdata(dev); + if (!dc) + return -EINVAL; + clk_disable_unprepare(dc->clk); return 0; } +static int tegra_dc_runtime_resume(struct device *dev) +{ + int err = 0; + struct tegra_dc *dc; + + dc = dev_get_drvdata(dev); + if (!dc) + return -EINVAL; + + err = clk_prepare_enable(dc->clk); + if (err < 0) + dev_err(dev, "failed to enable clock\n"); + + return err; +} +#endif /* CONFIG_PM_RUNTIME */ + +#ifdef CONFIG_PM +static const struct dev_pm_ops tegra_dc_pm_ops = { + SET_RUNTIME_PM_OPS(tegra_dc_runtime_suspend, + tegra_dc_runtime_resume, NULL) +}; +#endif + static struct of_device_id tegra_dc_of_match[] = { { .compatible = "nvidia,tegra30-dc", }, { .compatible = "nvidia,tegra20-dc", }, @@ -1194,6 +1241,9 @@ struct platform_driver tegra_dc_driver = { .name = "tegra-dc", .owner = THIS_MODULE, .of_match_table = tegra_dc_of_match, +#ifdef CONFIG_PM + .pm = &tegra_dc_pm_ops, +#endif }, .probe = tegra_dc_probe, .remove = tegra_dc_remove,