From patchwork Wed Aug 15 12:07:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Icenowy Zheng X-Patchwork-Id: 10567009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E94195A4 for ; Thu, 16 Aug 2018 06:55:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5D0F2AB8A for ; Thu, 16 Aug 2018 06:55:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA57A2AB92; Thu, 16 Aug 2018 06:55:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 79AB22AB8A for ; Thu, 16 Aug 2018 06:55:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7453C6E440; Thu, 16 Aug 2018 06:54:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from burlywood.maple.relay.mailchannels.net (burlywood.maple.relay.mailchannels.net [23.83.214.26]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F1A26E36B for ; Wed, 15 Aug 2018 12:08:57 +0000 (UTC) X-Sender-Id: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 8378D4226B; Wed, 15 Aug 2018 12:08:55 +0000 (UTC) Received: from hermes.aosc.io (unknown [100.96.30.57]) (Authenticated sender: lmn-TZDUIOWCRQMW) by relay.mailchannels.net (Postfix) with ESMTPA id B782642449; Wed, 15 Aug 2018 12:08:54 +0000 (UTC) X-Sender-Id: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io Received: from hermes.aosc.io (hermes.aosc.io [199.195.250.187]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.1); Wed, 15 Aug 2018 12:08:55 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: lmn-tzduiowcrqmw|x-authsender|icenowy@aosc.io X-MailChannels-Auth-Id: lmn-TZDUIOWCRQMW X-Dime-Rock: 0a8046d51c6526a3_1534334935381_2432829898 X-MC-Loop-Signature: 1534334935381:3011819492 X-MC-Ingress-Time: 1534334935380 Received: from localhost (localhost [127.0.0.1]) (Authenticated sender: icenowy@aosc.io) by hermes.aosc.io (Postfix) with ESMTPSA id 87292BE73E; Wed, 15 Aug 2018 12:08:42 +0000 (UTC) From: Icenowy Zheng To: Maxime Ripard , David Airlie , Chen-Yu Tsai Subject: [PATCH] drm: sun4i: exclusively set HDMI-related clocks for dw-hdmi Date: Wed, 15 Aug 2018 20:07:45 +0800 Message-Id: <20180815120745.36593-1-icenowy@aosc.io> X-Mailman-Approved-At: Thu, 16 Aug 2018 06:54:35 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-sunxi@googlegroups.com, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, Icenowy Zheng MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The glue in sun4i-drm of dw-hdmi currently doesn't set the clocks of dw-hdmi exclusively, which will lead the display fails to initialize in some situations. Add the exclusivity to sun8i-dw-hdmi and sun8i-hdmi-phy. Cc: stable@vger.kernel.org # v4.17+ Signed-off-by: Icenowy Zheng --- drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 11 ++++++++++- drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 7 +++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c index 31875b636434..a10220518548 100644 --- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c @@ -137,10 +137,16 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, goto err_assert_ctrl_reset; } + ret = clk_rate_exclusive_get(hdmi->clk_tmds); + if (ret) { + dev_err(dev, "Could not get exclusivity over the tmds clock\n"); + goto err_disable_clk_tmds; + } + phy_node = of_parse_phandle(dev->of_node, "phys", 0); if (!phy_node) { dev_err(dev, "Can't found PHY phandle\n"); - goto err_disable_clk_tmds; + goto err_put_clk_tmds_exclusivity; } ret = sun8i_hdmi_phy_probe(hdmi, phy_node); @@ -179,6 +185,8 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, cleanup_encoder: drm_encoder_cleanup(encoder); sun8i_hdmi_phy_remove(hdmi); +err_put_clk_tmds_exclusivity: + clk_rate_exclusive_put(hdmi->clk_tmds); err_disable_clk_tmds: clk_disable_unprepare(hdmi->clk_tmds); err_assert_ctrl_reset: @@ -194,6 +202,7 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master, dw_hdmi_unbind(hdmi->hdmi); sun8i_hdmi_phy_remove(hdmi); + clk_rate_exclusive_put(hdmi->clk_tmds); clk_disable_unprepare(hdmi->clk_tmds); reset_control_assert(hdmi->rst_ctrl); } diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c index 82502b351aec..1e0b1d9bc0fb 100644 --- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c @@ -511,13 +511,14 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node) } clk_prepare_enable(phy->clk_phy); + clk_rate_exclusive_get(phy->clk_phy); } phy->rst_phy = of_reset_control_get_shared(node, "phy"); if (IS_ERR(phy->rst_phy)) { dev_err(dev, "Could not get phy reset control\n"); ret = PTR_ERR(phy->rst_phy); - goto err_disable_clk_phy; + goto err_put_clk_phy_exclusivity; } ret = reset_control_deassert(phy->rst_phy); @@ -548,7 +549,8 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node) reset_control_assert(phy->rst_phy); err_put_rst_phy: reset_control_put(phy->rst_phy); -err_disable_clk_phy: +err_put_clk_phy_exclusivity: + clk_rate_exclusive_put(phy->clk_phy); clk_disable_unprepare(phy->clk_phy); err_put_clk_pll1: clk_put(phy->clk_pll1); @@ -568,6 +570,7 @@ void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi) clk_disable_unprepare(phy->clk_mod); clk_disable_unprepare(phy->clk_bus); + clk_rate_exclusive_put(phy->clk_phy); clk_disable_unprepare(phy->clk_phy); reset_control_assert(phy->rst_phy);