From patchwork Fri Sep 4 20:15:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 7125861 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 6CE1E9F32B for ; Fri, 4 Sep 2015 20:16:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 756FF20895 for ; Fri, 4 Sep 2015 20:16:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7BF5A2089C for ; Fri, 4 Sep 2015 20:16:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760498AbbIDUQG (ORCPT ); Fri, 4 Sep 2015 16:16:06 -0400 Received: from mail-yk0-f195.google.com ([209.85.160.195]:36129 "EHLO mail-yk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760474AbbIDUQG (ORCPT ); Fri, 4 Sep 2015 16:16:06 -0400 Received: by ykcf206 with SMTP id f206so2756921ykc.3 for ; Fri, 04 Sep 2015 13:16:05 -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=Dqmm3MBIkST7hqnRonuibEwi4XIe7hgKXXTqNUCEHKo=; b=kzn9OYKF64LW6mmDqfnUuTwqCiS8OkefuUrJZPeEu9OGgK067YGxEUje8USPTMhmHU fWSInd4U2yxXXj42ZNiYm3frx4g1WuWHrLqJxysMMF/xmd9ru2LhtisQFizJK6h6N6RL F3jiWKR/P898eQ+GirdwA/AwxyHH7VtKKelM0U4g/xXVB/4TOdlXGgN4gZSK9Y4QegA4 R4wuAwC7B8a1RCfP3cdfR6/5hY2M1HbZk3U3F6dpi5UAmMvUYZGWEZA/MgLNGioHTCTX 3VIcVBmzIHYJ1S53x9FY0Y5J3AoRsc22wUhfHkeQsynTREYOMeGKQv4DWhhVRsn9m8z9 rY4g== X-Received: by 10.170.128.2 with SMTP id u2mr6274812ykb.72.1441397765612; Fri, 04 Sep 2015 13:16:05 -0700 (PDT) Received: from jade.localdomain ([187.64.235.140]) by smtp.gmail.com with ESMTPSA id w186sm3228710ywf.18.2015.09.04.13.16.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Sep 2015 13:16:05 -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 03/10] drm/exynos: add pm_runtime to HDMI Date: Fri, 4 Sep 2015 17:15:45 -0300 Message-Id: <1441397752-6672-4-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_hdmi.c | 56 +++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 932f7fa..5fcbdda 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -92,7 +92,6 @@ struct hdmi_context { struct drm_device *drm_dev; struct drm_connector connector; bool hpd; - bool powered; bool dvi_mode; void __iomem *regs; @@ -1726,11 +1725,6 @@ static void hdmi_enable(struct drm_encoder *encoder) struct hdmi_context *hdata = encoder_to_hdmi(encoder); struct hdmi_resources *res = &hdata->res; - if (hdata->powered) - return; - - hdata->powered = true; - pm_runtime_get_sync(hdata->dev); if (regulator_bulk_enable(res->regul_count, res->regul_bulk)) @@ -1740,9 +1734,6 @@ static void hdmi_enable(struct drm_encoder *encoder) regmap_update_bits(hdata->pmureg, PMU_HDMI_PHY_CONTROL, PMU_HDMI_PHY_ENABLE_BIT, 1); - clk_prepare_enable(res->hdmi); - clk_prepare_enable(res->sclk_hdmi); - hdmiphy_poweron(hdata); hdmi_conf_apply(hdata); } @@ -1754,9 +1745,6 @@ static void hdmi_disable(struct drm_encoder *encoder) struct drm_crtc *crtc = encoder->crtc; const struct drm_crtc_helper_funcs *funcs = NULL; - if (!hdata->powered) - return; - /* * The SFRs of VP and Mixer are updated by Vertical Sync of * Timing generator which is a part of HDMI so the sequence @@ -1778,9 +1766,6 @@ static void hdmi_disable(struct drm_encoder *encoder) cancel_delayed_work(&hdata->hotplug_work); - clk_disable_unprepare(res->sclk_hdmi); - clk_disable_unprepare(res->hdmi); - /* reset pmu hdmiphy control bit to disable hdmiphy */ regmap_update_bits(hdata->pmureg, PMU_HDMI_PHY_CONTROL, PMU_HDMI_PHY_ENABLE_BIT, 0); @@ -1788,8 +1773,6 @@ static void hdmi_disable(struct drm_encoder *encoder) regulator_bulk_disable(res->regul_count, res->regul_bulk); pm_runtime_put_sync(hdata->dev); - - hdata->powered = false; } static struct drm_encoder_helper_funcs exynos_hdmi_encoder_helper_funcs = { @@ -2146,12 +2129,51 @@ static int hdmi_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int exynos_hdmi_suspend(struct device *dev) +{ + struct hdmi_context *hdata = dev_get_drvdata(dev); + struct hdmi_resources *res = &hdata->res; + + clk_disable_unprepare(res->sclk_hdmi); + clk_disable_unprepare(res->hdmi); + + return 0; +} + +static int exynos_hdmi_resume(struct device *dev) +{ + struct hdmi_context *hdata = dev_get_drvdata(dev); + struct hdmi_resources *res = &hdata->res; + int ret; + + ret = clk_prepare_enable(res->hdmi); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the hdmi clk [%d]\n", ret); + return ret; + } + ret = clk_prepare_enable(res->sclk_hdmi); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the sclk_mixer clk [%d]\n", + ret); + return ret; + } + + return 0; +} +#endif + +static const struct dev_pm_ops exynos_hdmi_pm_ops = { + SET_RUNTIME_PM_OPS(exynos_hdmi_suspend, exynos_hdmi_resume, NULL) +}; + struct platform_driver hdmi_driver = { .probe = hdmi_probe, .remove = hdmi_remove, .driver = { .name = "exynos-hdmi", .owner = THIS_MODULE, + .pm = &exynos_hdmi_pm_ops, .of_match_table = hdmi_match_types, }, };