From patchwork Tue Nov 3 10:47:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 7541511 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 EE02D9FC6A 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 146A9205E6 for ; Tue, 3 Nov 2015 10:47:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 062A7205FA for ; Tue, 3 Nov 2015 10:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752184AbbKCKrQ (ORCPT ); Tue, 3 Nov 2015 05:47:16 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:48628 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751834AbbKCKrO (ORCPT ); Tue, 3 Nov 2015 05:47:14 -0500 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NX802ZA4JAPEL60@mailout1.samsung.com> for linux-samsung-soc@vger.kernel.org; Tue, 03 Nov 2015 19:47:13 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.116]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id 60.10.05342.1B098365; Tue, 3 Nov 2015 19:47:13 +0900 (KST) X-AuditID: cbfee690-f794e6d0000014de-8e-563890b1d041 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 65.3D.23663.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 3/7] drm/exynos: add pm_runtime to HDMI Date: Tue, 03 Nov 2015 19:47:05 +0900 Message-id: <1446547629-12521-4-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+NgFrrALMWRmVeSWpSXmKPExsWyRsSkRHfjBIswgx1buS16z51ksrjy9T2b xafVrewWk+5PYLGYcX4fkwOrx9/n11k8tn97wOpxv/s4k0ffllWMHp83yQWwRnHZpKTmZJal FunbJXBlzDk5lbHgmXxF0+FJzA2MfVJdjBwcEgImEusXcncxcgKZYhIX7q1n62Lk4hASWMEo cXrFMhaIhInEiZ+/WCASSxklluy7AuV8Z5Q4vPwWG0gVm4CqxMQV98FsEQFlib8TVzGC2MwC /YwSP84rgNjCAlYSG3q/MIHYLED1uydPB9vAK+Ai8fLpKVaIbXISJ49NBrM5BVwl1pxewQhy qRBQzb31RiB7JQT62SVOLbnLCDFHQOLb5EMsEN/ISmw6wAwxRlLi4IobLBMYhRcwMqxiFE0t SC4oTkovMtErTswtLs1L10vOz93ECAzo0/+eTdjBeO+A9SFGAQ5GJR7eH8vMw4RYE8uKK3MP MZoCbZjILCWanA+Mm7ySeENjMyMLUxNTYyNzSzMlcd7XUj+DhQTSE0tSs1NTC1KL4otKc1KL DzEycXBKNTDqfPZa4bo0Q/6hzgWhyRn2HewPNkrr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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: - Mofidy CONFIG_PM_SLEEP -> CONFIG_PM Signed-off-by: Gustavo Padovan Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_hdmi.c | 56 ++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 57b6755..d0362af 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -102,7 +102,6 @@ struct hdmi_context { struct device *dev; struct drm_device *drm_dev; struct drm_connector connector; - bool powered; bool dvi_mode; struct delayed_work hotplug_work; struct drm_display_mode current_mode; @@ -113,7 +112,7 @@ struct hdmi_context { void __iomem *regs_hdmiphy; struct i2c_client *hdmiphy_port; struct i2c_adapter *ddc_adpt; - struct gpio_desc *hpd_gpio; + struct gpio_desc *hpd_gpio; int irq; struct regmap *pmureg; struct clk *hdmi; @@ -1585,11 +1584,6 @@ static void hdmi_enable(struct drm_encoder *encoder) { struct hdmi_context *hdata = encoder_to_hdmi(encoder); - if (hdata->powered) - return; - - hdata->powered = true; - pm_runtime_get_sync(hdata->dev); if (regulator_bulk_enable(ARRAY_SIZE(supply), hdata->regul_bulk)) @@ -1599,9 +1593,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(hdata->hdmi); - clk_prepare_enable(hdata->sclk_hdmi); - hdmi_conf_apply(hdata); } @@ -1611,9 +1602,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 @@ -1633,9 +1621,6 @@ static void hdmi_disable(struct drm_encoder *encoder) cancel_delayed_work(&hdata->hotplug_work); - clk_disable_unprepare(hdata->sclk_hdmi); - clk_disable_unprepare(hdata->hdmi); - /* reset pmu hdmiphy control bit to disable hdmiphy */ regmap_update_bits(hdata->pmureg, PMU_HDMI_PHY_CONTROL, PMU_HDMI_PHY_ENABLE_BIT, 0); @@ -1643,8 +1628,6 @@ static void hdmi_disable(struct drm_encoder *encoder) regulator_bulk_disable(ARRAY_SIZE(supply), hdata->regul_bulk); pm_runtime_put_sync(hdata->dev); - - hdata->powered = false; } static struct drm_encoder_helper_funcs exynos_hdmi_encoder_helper_funcs = { @@ -1978,12 +1961,49 @@ static int hdmi_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM +static int exynos_hdmi_suspend(struct device *dev) +{ + struct hdmi_context *hdata = dev_get_drvdata(dev); + + clk_disable_unprepare(hdata->sclk_hdmi); + clk_disable_unprepare(hdata->hdmi); + + return 0; +} + +static int exynos_hdmi_resume(struct device *dev) +{ + struct hdmi_context *hdata = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(hdata->hdmi); + if (ret < 0) { + DRM_ERROR("Failed to prepare_enable the hdmi clk [%d]\n", ret); + return ret; + } + ret = clk_prepare_enable(hdata->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, }, };