From patchwork Tue Mar 10 21:45:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 5980861 Return-Path: X-Original-To: patchwork-linux-rockchip@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 1930B9F380 for ; Tue, 10 Mar 2015 21:46:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 38EC62021A for ; Tue, 10 Mar 2015 21:46:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D82E12013D for ; Tue, 10 Mar 2015 21:46:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YVRyd-0008JJ-0h; Tue, 10 Mar 2015 21:46:11 +0000 Received: from gloria.sntech.de ([95.129.55.99]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YVRyT-0007t6-Ii; Tue, 10 Mar 2015 21:46:03 +0000 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 1YVRxs-00040y-Kj; Tue, 10 Mar 2015 22:45:24 +0100 From: Heiko Stuebner To: Philipp Zabel , David Airlie , Mark Yao Subject: [PATCH v2 1/2] drm/bridge: dw-hdmi: support optional supply regulators Date: Tue, 10 Mar 2015 22:45:29 +0100 Message-ID: <2265807.RXHBN9kUi4@phil> User-Agent: KMail/4.14.1 (Linux/3.19.0+; KDE/4.14.2; x86_64; ; ) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150310_144601_852069_C28E1D24 X-CRM114-Status: GOOD ( 14.07 ) X-Spam-Score: -0.0 (/) Cc: Mark Rutland , devicetree@vger.kernel.org, Russell King - ARM Linux , Pawel Moll , Ian Campbell , Kumar Gala , dianders@chromium.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Rob Herring , djkurtz@chromium.org, Yakir Yang , Andy Yan , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 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 --- 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: +- avdd1v0-supply: 1.0V power supply +- avdd1v8-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 = "avdd1v0"; + hdmi->supplies[1].supply = "avdd1v8"; + 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);