From patchwork Mon Mar 9 23:22:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Stuebner X-Patchwork-Id: 5972481 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 14E3E9F380 for ; Mon, 9 Mar 2015 23:23:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1790E20411 for ; Mon, 9 Mar 2015 23:23:20 +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 175BF201ED for ; Mon, 9 Mar 2015 23:23:19 +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 1YV713-0002IP-JZ; Mon, 09 Mar 2015 23:23:17 +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 1YV710-00023T-Eq; Mon, 09 Mar 2015 23:23:15 +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 1YV70W-0007Te-AC; Tue, 10 Mar 2015 00:22:44 +0100 From: Heiko Stuebner To: Philipp Zabel Subject: [PATCH 2/3] drm/bridge: dw-hdmi: support optional supply regulators Date: Tue, 10 Mar 2015 00:22:49 +0100 Message-ID: <2297963.iMSNqyfSUx@phil> User-Agent: KMail/4.14.1 (Linux/3.19.0+; KDE/4.14.2; x86_64; ; ) In-Reply-To: <1429128.MSqYm0qZ9p@phil> References: <1429128.MSqYm0qZ9p@phil> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150309_162314_700286_28FF447A X-CRM114-Status: GOOD ( 13.81 ) X-Spam-Score: -0.0 (/) Cc: Fabio Estevam , devicetree@vger.kernel.org, Rob Herring , Pawel Moll , Ian Campbell , David Airlie , Kumar Gala , dianders@chromium.org, djkurtz@chromium.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, broonie@kernel.org, dri-devel@lists.freedesktop.org, Yakir Yang , Andy Yan , Mark Rutland , linux-arm-kernel@lists.infradead.org, Mark Yao 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 --- .../devicetree/bindings/drm/bridge/dw_hdmi.txt | 5 ++++ drivers/gpu/drm/bridge/dw_hdmi.c | 27 +++++++++++++++++++++- drivers/gpu/drm/imx/dw_hdmi-imx.c | 3 ++- drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 15 +++++++++++- include/drm/bridge/dw_hdmi.h | 3 ++- 5 files changed, 49 insertions(+), 4 deletions(-) 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" +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/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c index cd6a706..9f8999d 100644 --- a/drivers/gpu/drm/bridge/dw_hdmi.c +++ b/drivers/gpu/drm/bridge/dw_hdmi.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -114,6 +115,9 @@ struct dw_hdmi { struct hdmi_data_info hdmi_data; const struct dw_hdmi_plat_data *plat_data; + struct regulator_bulk_data *supplies; + int nsupplies; + int vic; u8 edid[HDMI_EDID_LEN]; @@ -879,6 +883,12 @@ static int dw_hdmi_phy_init(struct dw_hdmi *hdmi) int i, ret; bool cscon = false; + if (hdmi->nsupplies > 0) { + ret = regulator_bulk_enable(hdmi->nsupplies, hdmi->supplies); + if (ret) + return ret; + } + /*check csc whether needed activated in HDMI mode */ cscon = (is_color_space_conversion(hdmi) && !hdmi->hdmi_data.video_mode.mdvi); @@ -1105,6 +1115,9 @@ static void dw_hdmi_phy_disable(struct dw_hdmi *hdmi) dw_hdmi_phy_enable_tmds(hdmi, 0); dw_hdmi_phy_enable_power(hdmi, 0); + if (hdmi->nsupplies > 0) + regulator_bulk_disable(hdmi->nsupplies, hdmi->supplies); + hdmi->phy_enabled = false; } @@ -1549,7 +1562,8 @@ static int dw_hdmi_register(struct drm_device *drm, struct dw_hdmi *hdmi) int dw_hdmi_bind(struct device *dev, struct device *master, void *data, struct drm_encoder *encoder, struct resource *iores, int irq, - const struct dw_hdmi_plat_data *plat_data) + const struct dw_hdmi_plat_data *plat_data, + struct regulator_bulk_data *supplies, int nsupplies) { struct drm_device *drm = data; struct device_node *np = dev->of_node; @@ -1602,6 +1616,17 @@ int dw_hdmi_bind(struct device *dev, struct device *master, if (IS_ERR(hdmi->regs)) return PTR_ERR(hdmi->regs); + if (nsupplies > 0) { + ret = devm_regulator_bulk_get(hdmi->dev, nsupplies, supplies); + if (ret == -EPROBE_DEFER) + return ret; + if (ret) + nsupplies = 0; + } + + hdmi->supplies = supplies; + hdmi->nsupplies = nsupplies; + hdmi->isfr_clk = devm_clk_get(hdmi->dev, "isfr"); if (IS_ERR(hdmi->isfr_clk)) { ret = PTR_ERR(hdmi->isfr_clk); diff --git a/drivers/gpu/drm/imx/dw_hdmi-imx.c b/drivers/gpu/drm/imx/dw_hdmi-imx.c index 121d30c..153e259 100644 --- a/drivers/gpu/drm/imx/dw_hdmi-imx.c +++ b/drivers/gpu/drm/imx/dw_hdmi-imx.c @@ -214,7 +214,8 @@ static int dw_hdmi_imx_bind(struct device *dev, struct device *master, drm_encoder_init(drm, encoder, &dw_hdmi_imx_encoder_funcs, DRM_MODE_ENCODER_TMDS); - return dw_hdmi_bind(dev, master, data, encoder, iores, irq, plat_data); + return dw_hdmi_bind(dev, master, data, encoder, iores, irq, plat_data, + NULL, 0); } static void dw_hdmi_imx_unbind(struct device *dev, struct device *master, diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c index d236faa..c085e88 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 @@ -24,6 +25,8 @@ #define GRF_SOC_CON6 0x025c #define HDMI_SEL_VOP_LIT (1 << 4) +#define HDMI_NUM_REGULATORS 2 + struct rockchip_hdmi { struct device *dev; struct regmap *regmap; @@ -248,6 +251,7 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master, struct platform_device *pdev = to_platform_device(dev); const struct dw_hdmi_plat_data *plat_data; const struct of_device_id *match; + struct regulator_bulk_data *supplies; struct drm_device *drm = data; struct drm_encoder *encoder; struct rockchip_hdmi *hdmi; @@ -275,6 +279,14 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master, if (!iores) return -ENXIO; + supplies = devm_kcalloc(&pdev->dev, HDMI_NUM_REGULATORS, + sizeof(*supplies), GFP_KERNEL); + if (!supplies) + return -ENOMEM; + + supplies[0].supply = "avdd1v0"; + supplies[1].supply = "avdd1v8"; + platform_set_drvdata(pdev, hdmi); encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node); @@ -297,7 +309,8 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master, drm_encoder_init(drm, encoder, &dw_hdmi_rockchip_encoder_funcs, DRM_MODE_ENCODER_TMDS); - return dw_hdmi_bind(dev, master, data, encoder, iores, irq, plat_data); + return dw_hdmi_bind(dev, master, data, encoder, iores, irq, plat_data, + supplies, HDMI_NUM_REGULATORS); } static void dw_hdmi_rockchip_unbind(struct device *dev, struct device *master, diff --git a/include/drm/bridge/dw_hdmi.h b/include/drm/bridge/dw_hdmi.h index 5a4f490..7b0fac5 100644 --- a/include/drm/bridge/dw_hdmi.h +++ b/include/drm/bridge/dw_hdmi.h @@ -57,5 +57,6 @@ void dw_hdmi_unbind(struct device *dev, struct device *master, void *data); int dw_hdmi_bind(struct device *dev, struct device *master, void *data, struct drm_encoder *encoder, struct resource *iores, int irq, - const struct dw_hdmi_plat_data *plat_data); + const struct dw_hdmi_plat_data *plat_data, + struct regulator_bulk_data *supplies, int nsupplies); #endif /* __IMX_HDMI_H__ */