From patchwork Thu Mar 12 20:45:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 449648 Return-Path: X-Original-To: incoming-dt@patchwork.ozlabs.org Delivered-To: patchwork-incoming-dt@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B17BE1400DE for ; Fri, 13 Mar 2015 07:45:28 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752582AbbCLUp1 (ORCPT ); Thu, 12 Mar 2015 16:45:27 -0400 Received: from gloria.sntech.de ([95.129.55.99]:53709 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752460AbbCLUp0 (ORCPT ); Thu, 12 Mar 2015 16:45:26 -0400 Received: from ip545477c2.speed.planet.nl ([84.84.119.194] helo=phil.localnet) by gloria.sntech.de with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YW9yk-0005lV-DB; Thu, 12 Mar 2015 21:45:14 +0100 From: Heiko Stuebner To: Philipp Zabel , David Airlie , Mark Yao Cc: djkurtz@chromium.org, Yakir Yang , dianders@chromium.org, Andy Yan , linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , linux-arm-kernel@lists.infradead.org, Russell King - ARM Linux Subject: [PATCH v3 1/2] drm/bridge: dw-hdmi: support optional supply regulators Date: Thu, 12 Mar 2015 21:45:19 +0100 Message-ID: <4184159.j0iXe39dFB@phil> User-Agent: KMail/4.14.1 (Linux/3.19.0+; KDE/4.14.2; x86_64; ; ) MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org At least the Rockchip variant of the dw_hdmi can have controllable power supplies providing 1.0 and 1.8V. Therefore add the possibility for the generic bridge driver to enable supplies provided by the hw-specific drivers. Signed-off-by: Heiko Stuebner Acked-by: Philipp Zabel --- changes since v2: - rename supplies to the names found in the hdmi IP databook changes since v1: - follow suggestion from Russell King to keep regulator handling local to the rockchip implementation for the time being and only generalize when a real second implementation needs regulator handling .../devicetree/bindings/drm/bridge/dw_hdmi.txt | 5 ++++ drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 32 +++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt index a905c14..bb74640 100644 --- a/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt +++ b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt @@ -22,6 +22,11 @@ Optional properties - ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing - clocks, clock-names: phandle to the HDMI CEC clock, name should be "cec" +Optional supplies: +rockchip,rk3288-dw-hdmi handles two optional power supplies: +- vp-supply: 1.0V power supply +- vph-supply: 1.8V power supply + Example: hdmi: hdmi@0120000 { compatible = "fsl,imx6q-hdmi"; diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c index d236faa..647a240 100644 --- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -28,6 +29,9 @@ struct rockchip_hdmi { struct device *dev; struct regmap *regmap; struct drm_encoder encoder; + struct regulator_bulk_data supplies[2]; + int nsupplies; + bool supplies_enabled; }; #define to_rockchip_hdmi(x) container_of(x, struct rockchip_hdmi, x) @@ -179,6 +183,12 @@ static struct drm_encoder_funcs dw_hdmi_rockchip_encoder_funcs = { static void dw_hdmi_rockchip_encoder_disable(struct drm_encoder *encoder) { + struct rockchip_hdmi *hdmi = to_rockchip_hdmi(encoder); + + if (hdmi->nsupplies > 0 && hdmi->supplies_enabled) { + regulator_bulk_disable(hdmi->nsupplies, hdmi->supplies); + hdmi->supplies_enabled = false; + } } static bool @@ -199,7 +209,16 @@ static void dw_hdmi_rockchip_encoder_commit(struct drm_encoder *encoder) { struct rockchip_hdmi *hdmi = to_rockchip_hdmi(encoder); u32 val; - int mux; + int mux, ret; + + if (hdmi->nsupplies > 0 && !hdmi->supplies_enabled) { + ret = regulator_bulk_enable(hdmi->nsupplies, hdmi->supplies); + if (ret) { + dev_err(hdmi->dev, "could not enable hdmi analog supplies\n"); + return; + } + hdmi->supplies_enabled = true; + } mux = rockchip_drm_encoder_get_mux_id(hdmi->dev->of_node, encoder); if (mux) @@ -275,6 +294,17 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master, if (!iores) return -ENXIO; + hdmi->supplies[0].supply = "vp"; + hdmi->supplies[1].supply = "vph"; + hdmi->nsupplies = 2; + + ret = devm_regulator_bulk_get(hdmi->dev, + hdmi->nsupplies, hdmi->supplies); + if (ret == -EPROBE_DEFER) + return ret; + if (ret) + hdmi->nsupplies = 0; + platform_set_drvdata(pdev, hdmi); encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node);