From patchwork Thu Nov 26 11:53:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 7706081 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 2874B9F443 for ; Thu, 26 Nov 2015 11:54:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 34D40207D7 for ; Thu, 26 Nov 2015 11:54:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3A584207C9 for ; Thu, 26 Nov 2015 11:54:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751016AbbKZLx7 (ORCPT ); Thu, 26 Nov 2015 06:53:59 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:46021 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750839AbbKZLx6 (ORCPT ); Thu, 26 Nov 2015 06:53:58 -0500 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NYF029KI7PXAGB0@mailout2.samsung.com> for linux-samsung-soc@vger.kernel.org; Thu, 26 Nov 2015 20:53:57 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.114]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id BF.04.29987.4D2F6565; Thu, 26 Nov 2015 20:53:56 +0900 (KST) X-AuditID: cbfee68d-f79286d000007523-37-5656f2d4b1c9 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 5F.EF.24993.4D2F6565; Thu, 26 Nov 2015 20:53:56 +0900 (KST) Received: from localhost.localdomain ([10.252.83.67]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NYF00KJ47PV2MC1@mmp1.samsung.com>; Thu, 26 Nov 2015 20:53:56 +0900 (KST) From: Inki Dae To: dri-devel@lists.freedesktop.org Cc: airlied@linux.ie, linux-samsung-soc@vger.kernel.org, Gustavo Padovan , Inki Dae Subject: [PATCH v3] drm/exynos: add pm_runtime to DP Date: Thu, 26 Nov 2015 20:53:51 +0900 Message-id: <1448538834-26378-2-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1448538834-26378-1-git-send-email-inki.dae@samsung.com> References: <1448538834-26378-1-git-send-email-inki.dae@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrALMWRmVeSWpSXmKPExsWyRsSkSPfKp7Awg5WvrS16z51ksrjy9T2b xafVrewWk+5PYLGYcX4fkwOrx9/n11k8tn97wOpxv/s4k0ffllWMHp83yQWwRnHZpKTmZJal FunbJXBlzNqyh7ngqUzFqle/GBsYP4h3MXJwSAiYSNz5ltnFyAlkiklcuLeerYuRi0NIYAWj xL297WwQCROJx+tWQCWWMkrcaZzPDJIQEvjOKHFkqSuIzSagKjFxxX2wBhEBZYm/E1cxgtjM Av2MEj/OK4DYwkCDbnz5ABZnAar/vnwL2BxeAReJrR9bWSCWyUmcPDaZFcTmFHCVWLX8HgvE LheJ3sYbYEdICLSzS8xa+p8FYpCAxLfJh1ggvpGV2HSAGWKOpMTBFTdYJjAKL2BkWMUomlqQ XFCclF5kqFecmFtcmpeul5yfu4kRGNCn/z3r3cF4+4D1IUYBDkYlHt4C27AwIdbEsuLK3EOM pkAbJjJLiSbnA+MmryTe0NjMyMLUxNTYyNzSTEmcV1HqZ7CQQHpiSWp2ampBalF8UWlOavEh RiYOTqkGxoPdfbtMMthKV64/7Sr0W88548Jrw92F/R33M82NTtw747aionrqqyctXfZnO1fL B+95mH7lSYNQiZHSzHOrVv/b1GYiFHPxcH9w5NEgvwYuvU0p7tnv044v6zrrv1DymrOLQvv3 g18sOezzohYtYM5IuGPjzCO4VmvO5Kc37NM42z+9vF53SYmlOCPRUIu5qDgRAJYh+t9jAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRmVeSWpSXmKPExsVy+t9jAd0rn8LCDGYeNLXoPXeSyeLK1/ds Fp9Wt7JbTLo/gcVixvl9TA6sHn+fX2fx2P7tAavH/e7jTB59W1YxenzeJBfAGtXAaJORmpiS WqSQmpecn5KZl26r5B0c7xxvamZgqGtoaWGupJCXmJtqq+TiE6DrlpkDtF1JoSwxpxQoFJBY XKykb4dpQmiIm64FTGOErm9IEFyPkQEaSFjDmDFryx7mgqcyFate/WJsYPwg3sXIySEhYCLx eN0KNghbTOLCvfVANheHkMBSRok7jfOZQRJCAt8ZJY4sdQWx2QRUJSauuA/WICKgLPF34ipG EJtZoJ9R4sd5BRBbGGjojS8fwOIsQPXfl28Bm8Mr4CKx9WMrC8QyOYmTxyazgticAq4Sq5bf Y4HY5SLR23iDbQIj7wJGhlWMEqkFyQXFSem5hnmp5XrFibnFpXnpesn5uZsYwXHzTGoH48Fd 7ocYBTgYlXh4C2zDwoRYE8uKK3MPMUpwMCuJ8H55CBTiTUmsrEotyo8vKs1JLT7EaAp02ERm KdHkfGBM55XEGxqbmBlZGpkbWhgZmyuJ817Y7xcmJJCeWJKanZpakFoE08fEwSnVwKhtbeK9 XKEzjb00l0nmduB5n+WKHT5Mq/zXban6coGrQvPuu5DMGVv47HVmxk1w4proKXZ32imJu0Ed d5Lmxov5c/OcT/bo5T06bV7QjsDoGVbfnYs/Ka1Iu/GsqNHjyn5NsxV5Otr1XQzKDuXH93VY 3r9yb3rr7auzxVYstIzd7sFovbt+qhJLcUaioRZzUXEiADu3K7OxAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@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 From: Gustavo Padovan Let pm_runtime handle the enabling/disabling of the device with proper refcnt instead of rely on specific flags to track the enabled state. Chnagelog v3: - revive dpms_mode to keep current dpms mode. Changelog v2: - no change Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_dp_core.c | 51 +++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c index e4d32a1..94f02a0 100644 --- a/drivers/gpu/drm/exynos/exynos_dp_core.c +++ b/drivers/gpu/drm/exynos/exynos_dp_core.c @@ -1061,6 +1061,8 @@ static void exynos_dp_bridge_enable(struct drm_bridge *bridge) if (dp->dpms_mode == DRM_MODE_DPMS_ON) return; + pm_runtime_get_sync(dp->dev); + if (dp->panel) { if (drm_panel_prepare(dp->panel)) { DRM_ERROR("failed to setup the panel\n"); @@ -1071,7 +1073,6 @@ static void exynos_dp_bridge_enable(struct drm_bridge *bridge) if (crtc->ops->clock_enable) crtc->ops->clock_enable(dp_to_crtc(dp), true); - clk_prepare_enable(dp->clock); phy_power_on(dp->phy); exynos_dp_init_dp(dp); enable_irq(dp->irq); @@ -1098,7 +1099,6 @@ static void exynos_dp_bridge_disable(struct drm_bridge *bridge) disable_irq(dp->irq); flush_work(&dp->hotplug_work); phy_power_off(dp->phy); - clk_disable_unprepare(dp->clock); if (crtc->ops->clock_enable) crtc->ops->clock_enable(dp_to_crtc(dp), false); @@ -1108,6 +1108,8 @@ static void exynos_dp_bridge_disable(struct drm_bridge *bridge) DRM_ERROR("failed to turnoff the panel\n"); } + pm_runtime_put_sync(dp->dev); + dp->dpms_mode = DRM_MODE_DPMS_OFF; } @@ -1392,6 +1394,7 @@ static int exynos_dp_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *panel_node, *bridge_node, *endpoint; struct exynos_dp_device *dp; + int ret; dp = devm_kzalloc(&pdev->dev, sizeof(struct exynos_dp_device), GFP_KERNEL); @@ -1420,16 +1423,57 @@ static int exynos_dp_probe(struct platform_device *pdev) return -EPROBE_DEFER; } - return component_add(&pdev->dev, &exynos_dp_ops); + pm_runtime_enable(dev); + + ret = component_add(&pdev->dev, &exynos_dp_ops); + if (ret) + goto err_disable_pm_runtime; + + return ret; + +err_disable_pm_runtime: + pm_runtime_disable(dev); + + return ret; } static int exynos_dp_remove(struct platform_device *pdev) { + pm_runtime_disable(&pdev->dev); component_del(&pdev->dev, &exynos_dp_ops); return 0; } +#ifdef CONFIG_PM +static int exynos_dp_suspend(struct device *dev) +{ + struct exynos_dp_device *dp = dev_get_drvdata(dev); + + clk_disable_unprepare(dp->clock); + + return 0; +} + +static int exynos_dp_resume(struct device *dev) +{ + struct exynos_dp_device *dp = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(dp->clock); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the clock clk [%d]\n", ret); + return ret; + } + + return 0; +} +#endif + +static const struct dev_pm_ops exynos_dp_pm_ops = { + SET_RUNTIME_PM_OPS(exynos_dp_suspend, exynos_dp_resume, NULL) +}; + static const struct of_device_id exynos_dp_match[] = { { .compatible = "samsung,exynos5-dp" }, {}, @@ -1442,6 +1486,7 @@ struct platform_driver dp_driver = { .driver = { .name = "exynos-dp", .owner = THIS_MODULE, + .pm = &exynos_dp_pm_ops, .of_match_table = exynos_dp_match, }, };