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: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 5972461 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 5CB219F2A9 for ; Mon, 9 Mar 2015 23:22:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4B98720431 for ; Mon, 9 Mar 2015 23:22:52 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id CB0072012D for ; Mon, 9 Mar 2015 23:22:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 038146E635; Mon, 9 Mar 2015 16:22:49 -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 AFA2B6E635 for ; Mon, 9 Mar 2015 16:22:47 -0700 (PDT) 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 Cc: Fabio Estevam , devicetree@vger.kernel.org, Rob Herring , Pawel Moll , Ian Campbell , Kumar Gala , dianders@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 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 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__ */