From patchwork Fri Sep 4 20:15:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 7125841 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 A991F9F32B for ; Fri, 4 Sep 2015 20:16:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AACCC2073C for ; Fri, 4 Sep 2015 20:16:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7613420739 for ; Fri, 4 Sep 2015 20:16:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760500AbbIDUQE (ORCPT ); Fri, 4 Sep 2015 16:16:04 -0400 Received: from mail-yk0-f194.google.com ([209.85.160.194]:36124 "EHLO mail-yk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760335AbbIDUQE (ORCPT ); Fri, 4 Sep 2015 16:16:04 -0400 Received: by ykcf206 with SMTP id f206so2756849ykc.3 for ; Fri, 04 Sep 2015 13:16:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UsSWJYhKVZdWXMlXeZY3wIUqx4f8vAY1E6zf4DAicvw=; b=YkCNv40EtacZ2JjB+EXstQcQR+JMYApak9h2S4RAUD6wMVH6iDJk+bGXG7aa5XIBAk dS55L9lVJ5Ir06To6PWCYw3M3MATPbDRHMkhIJpl6yfZPzdjIbmLY2ELyA0wL7oXp+lG suxJ0HcX7/O/S9h3LA3pktTkkFSsNvPXpCAzW9lAECIaCmX5N7OWmxtf5xUsRASxuKXs m7tFzxY68OQxQUMj+pHwZhn0K3Ftchqav0Dt7VAAJW0Th08dRutHbCumfE8y+4Lgi5+H CG/DJ4uFGaD3o7jiQn8Kwns5SFQBrE6YMMlxZ1bJfAIqkvGYbmqFXiDGrmWhtoDMfTAg CEeQ== X-Received: by 10.129.76.13 with SMTP id z13mr6627323ywa.2.1441397763474; Fri, 04 Sep 2015 13:16:03 -0700 (PDT) Received: from jade.localdomain ([187.64.235.140]) by smtp.gmail.com with ESMTPSA id w186sm3228710ywf.18.2015.09.04.13.16.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Sep 2015 13:16:02 -0700 (PDT) From: Gustavo Padovan To: linux-samsung-soc@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, inki.dae@samsung.com, jy0922.shim@samsung.com, tjakobi@math.uni-bielefeld.de, Gustavo Padovan Subject: [PATCH 02/10] drm/exynos: add pm_runtime to DP Date: Fri, 4 Sep 2015 17:15:44 -0300 Message-Id: <1441397752-6672-3-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1441397752-6672-1-git-send-email-gustavo@padovan.org> References: <1441397752-6672-1-git-send-email-gustavo@padovan.org> 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, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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. Signed-off-by: Gustavo Padovan --- drivers/gpu/drm/exynos/exynos_dp_core.c | 40 +++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c index c73aff1..6794982 100644 --- a/drivers/gpu/drm/exynos/exynos_dp_core.c +++ b/drivers/gpu/drm/exynos/exynos_dp_core.c @@ -1070,8 +1070,7 @@ static void exynos_dp_enable(struct drm_encoder *encoder) struct exynos_dp_device *dp = encoder_to_dp(encoder); 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)) { @@ -1083,13 +1082,10 @@ static void exynos_dp_enable(struct drm_encoder *encoder) 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_disable(struct drm_encoder *encoder) @@ -1097,9 +1093,6 @@ static void exynos_dp_disable(struct drm_encoder *encoder) struct exynos_dp_device *dp = encoder_to_dp(encoder); 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"); @@ -1110,7 +1103,6 @@ static void exynos_dp_disable(struct drm_encoder *encoder) 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); @@ -1120,7 +1112,7 @@ static void exynos_dp_disable(struct drm_encoder *encoder) DRM_ERROR("failed to turnoff the panel\n"); } - dp->dpms_mode = DRM_MODE_DPMS_OFF; + pm_runtime_put_sync(dp->dev); } static struct drm_encoder_helper_funcs exynos_dp_encoder_helper_funcs = { @@ -1216,7 +1208,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)) @@ -1341,6 +1332,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); @@ -1369,11 +1361,23 @@ 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; @@ -1384,21 +1388,29 @@ static int exynos_dp_suspend(struct device *dev) { struct exynos_dp_device *dp = dev_get_drvdata(dev); - exynos_dp_disable(&dp->encoder); + 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; + } - exynos_dp_enable(&dp->encoder); return 0; } #endif static const struct dev_pm_ops exynos_dp_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(exynos_dp_suspend, exynos_dp_resume) + SET_RUNTIME_PM_OPS(exynos_dp_suspend, exynos_dp_resume, NULL) }; static const struct of_device_id exynos_dp_match[] = {