From patchwork Fri Jun 5 17:06:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 6556501 Return-Path: X-Original-To: patchwork-dri-devel@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 B41059F3D1 for ; Fri, 5 Jun 2015 17:06:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D60F720511 for ; Fri, 5 Jun 2015 17:06:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DE8192064F for ; Fri, 5 Jun 2015 17:06:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E1E6721B1; Fri, 5 Jun 2015 10:06:43 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from gloria.sntech.de (gloria.sntech.de [95.129.55.99]) by gabe.freedesktop.org (Postfix) with ESMTP id D215F721B1 for ; Fri, 5 Jun 2015 10:06:42 -0700 (PDT) Received: from ip92344111.dynamic.kabel-deutschland.de ([146.52.65.17] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Z0v4p-00031C-Fs; Fri, 05 Jun 2015 19:06:39 +0200 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Thierry Reding , Mark Yao Subject: [PATCH v4 2/3] drm/rockchip: implement dw_hdmi supplies for the Rockchip implementation Date: Fri, 05 Jun 2015 19:06:38 +0200 Message-ID: <17068264.uLYIadrGJJ@diego> User-Agent: KMail/4.14.1 (Linux/3.16.0-4-amd64; KDE/4.14.2; x86_64; ; ) In-Reply-To: <1707049.JEvfTcofKv@diego> References: <1707049.JEvfTcofKv@diego> MIME-Version: 1.0 Cc: Mark Rutland , devicetree@vger.kernel.org, Russell King - ARM Linux , Pawel Moll , Ian Campbell , dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, Rob Herring , linux-arm-kernel@lists.infradead.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 The Rockchip implementation of the IP exposes the supplies outside and expects them to be supplied by a pmic. So implement regulator handling for them. Signed-off-by: Heiko Stuebner Acked-by: Philipp Zabel --- changes since v3: - split generic dt-bindings and rockchip implementation - add Ack from 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 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 32 ++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c index 80d6fc8..9c003fa 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);