From patchwork Tue Nov 3 10:47:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 7541491 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0199CBEEA4 for ; Tue, 3 Nov 2015 10:47:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 05476205E6 for ; Tue, 3 Nov 2015 10:47:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CFC4320611 for ; Tue, 3 Nov 2015 10:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752062AbbKCKrP (ORCPT ); Tue, 3 Nov 2015 05:47:15 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:40050 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751418AbbKCKrO (ORCPT ); Tue, 3 Nov 2015 05:47:14 -0500 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NX802DO2JAOHS60@mailout4.samsung.com> for linux-samsung-soc@vger.kernel.org; Tue, 03 Nov 2015 19:47:12 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.113]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 1A.CB.05272.0B098365; Tue, 3 Nov 2015 19:47:12 +0900 (KST) X-AuditID: cbfee68e-f791c6d000001498-20-563890b06489 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id F5.67.18629.0B098365; Tue, 3 Nov 2015 19:47:12 +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 <0NX800N1DJAN2C90@mmp1.samsung.com>; Tue, 03 Nov 2015 19:47:12 +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 v2 2/7] drm/exynos: add pm_runtime to DP Date: Tue, 03 Nov 2015 19:47:04 +0900 Message-id: <1446547629-12521-3-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1446547629-12521-1-git-send-email-inki.dae@samsung.com> References: <1446547629-12521-1-git-send-email-inki.dae@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrALMWRmVeSWpSXmKPExsWyRsSkUHfDBIswgz1LdSx6z51ksrjy9T2b xafVrewWk+5PYLGYcX4fkwOrx9/n11k8tn97wOpxv/s4k0ffllWMHp83yQWwRnHZpKTmZJal FunbJXBl/O3azFKwS7niwg2DBsb9sl2MnBwSAiYSd9fvZoWwxSQu3FvP1sXIxSEksIJR4uiW XjaYovcL57NAJJYySiy5dYURwvnOKHF4+S2wKjYBVYmJK+6D2SICyhJ/J65iBLGZBfoZJX6c VwCxhQUsJJY2LQGrYQGqf/X1D5jNK+AicWDFIxaIbXISJ49NBjuJU8BVYs3pFUBzOICWuUjc W28EsldCoJtd4tLWj6wQcwQkvk0+xAJSIyEgK7HpADPEGEmJgytusExgFF7AyLCKUTS1ILmg OCm9yEivODG3uDQvXS85P3cTIzCgT/971reD8eYB60OMAhyMSjy8C5aYhwmxJpYVV+YeYjQF 2jCRWUo0OR8YN3kl8YbGZkYWpiamxkbmlmZK4rwJUj+DhQTSE0tSs1NTC1KL4otKc1KLDzEy cXBKNTCG7biVaHcv9eKj0r6WLKklz82vB5/ZedtYJnnnrMm7jjjaCJqt2jM9mWnqdscIFxn7 74bVC660TDjXfkVOcMdZK4774a9fdj5w13sttexlC8t1n97fJY9Ez8r22dXJ1Uip/nt86tLq ao/cGftP7r9yVen67PS979fW+Tw9apNyqaXJbJbSHZ/DSizFGYmGWsxFxYkAueKKVmMCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLIsWRmVeSWpSXmKPExsVy+t9jAd0NEyzCDKbOUrXoPXeSyeLK1/ds Fp9Wt7JbTLo/gcVixvl9TA6sHn+fX2fx2P7tAavH/e7jTB59W1YxenzeJBfAGtXAaJORmpiS WqSQmpecn5KZl26r5B0c7xxvamZgqGtoaWGupJCXmJtqq+TiE6DrlpkDtF1JoSwxpxQoFJBY XKykb4dpQmiIm64FTGOErm9IEFyPkQEaSFjDmPG3azNLwS7ligs3DBoY98t2MXJySAiYSLxf OJ8FwhaTuHBvPVsXIxeHkMBSRoklt64wQjjfGSUOL7/FBlLFJqAqMXHFfTBbREBZ4u/EVYwg NrNAP6PEj/MKILawgIXE0qYlYDUsQPWvvv4Bs3kFXCQOrHgEtU1O4uSxyawgNqeAq8Sa0yuA 5nAALXORuLfeaAIj7wJGhlWMEqkFyQXFSem5Rnmp5XrFibnFpXnpesn5uZsYwVHzTHoH4+Fd 7ocYBTgYlXh4FywxDxNiTSwrrsw9xCjBwawkwju5xyJMiDclsbIqtSg/vqg0J7X4EKMp0F0T maVEk/OBEZ1XEm9obGJmZGlkbmhhZGyuJM6r72kUJiSQnliSmp2aWpBaBNPHxMEp1cCY8rBJ ROmd5Tcuyw9qT3U09nk8n9EzdfGD5w9W7tTMWF533nTn20aFqz/3Ti86Vxz0MYa1vOPdqicu bXo1UodEWX+5FlwPf3PZ8npj7a52mYmTDzXXmLsn/RDb3+b0x+2X+0uzvPWifgZKMkafp/S8 lxJb9MI5SNrhnmfEGpMtKdNOrbx2bMdTJZbijERDLeai4kQARWTfObACAAA= 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=-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 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. Changelog v2: - no change Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_dp_core.c | 58 ++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c index e4d32a1..b6e8b89 100644 --- a/drivers/gpu/drm/exynos/exynos_dp_core.c +++ b/drivers/gpu/drm/exynos/exynos_dp_core.c @@ -1058,8 +1058,7 @@ static void exynos_dp_bridge_enable(struct drm_bridge *bridge) struct exynos_dp_device *dp = bridge->driver_private; struct exynos_drm_crtc *crtc = dp_to_crtc(dp); - if (dp->dpms_mode == DRM_MODE_DPMS_ON) - return; + pm_runtime_get_sync(dp->dev); if (dp->panel) { if (drm_panel_prepare(dp->panel)) { @@ -1071,13 +1070,10 @@ 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); exynos_dp_commit(&dp->encoder); - - dp->dpms_mode = DRM_MODE_DPMS_ON; } static void exynos_dp_bridge_disable(struct drm_bridge *bridge) @@ -1085,9 +1081,6 @@ static void exynos_dp_bridge_disable(struct drm_bridge *bridge) struct exynos_dp_device *dp = bridge->driver_private; struct exynos_drm_crtc *crtc = dp_to_crtc(dp); - if (dp->dpms_mode != DRM_MODE_DPMS_ON) - return; - if (dp->panel) { if (drm_panel_disable(dp->panel)) { DRM_ERROR("failed to disable the panel\n"); @@ -1098,7 +1091,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,7 +1100,7 @@ static void exynos_dp_bridge_disable(struct drm_bridge *bridge) DRM_ERROR("failed to turnoff the panel\n"); } - dp->dpms_mode = DRM_MODE_DPMS_OFF; + pm_runtime_put_sync(dp->dev); } static void exynos_dp_bridge_nop(struct drm_bridge *bridge) @@ -1267,7 +1259,6 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data) int pipe, ret = 0; dp->dev = &pdev->dev; - dp->dpms_mode = DRM_MODE_DPMS_OFF; dp->video_info = exynos_dp_dt_parse_pdata(&pdev->dev); if (IS_ERR(dp->video_info)) @@ -1392,6 +1383,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 +1412,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 +1475,7 @@ struct platform_driver dp_driver = { .driver = { .name = "exynos-dp", .owner = THIS_MODULE, + .pm = &exynos_dp_pm_ops, .of_match_table = exynos_dp_match, }, };