Commit ca80c4eb authored by Sascha Hauer's avatar Sascha Hauer Committed by Heiko Stuebner

drm/rockchip: dw_hdmi: add regulator support

The RK3568 has HDMI_TX_AVDD0V9 and HDMI_TX_AVDD_1V8 supply inputs needed
for the HDMI port. add support for these to the driver for boards which
have them supplied by switchable regulators.
Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
Tested-by: default avatarMichael Riesch <michael.riesch@wolfvision.net>
Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20220422072841.2206452-10-s.hauer@pengutronix.de
parent 80266ccb
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/phy/phy.h> #include <linux/phy/phy.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <drm/bridge/dw_hdmi.h> #include <drm/bridge/dw_hdmi.h>
#include <drm/drm_edid.h> #include <drm/drm_edid.h>
...@@ -76,6 +77,8 @@ struct rockchip_hdmi { ...@@ -76,6 +77,8 @@ struct rockchip_hdmi {
struct clk *ref_clk; struct clk *ref_clk;
struct clk *grf_clk; struct clk *grf_clk;
struct dw_hdmi *hdmi; struct dw_hdmi *hdmi;
struct regulator *avdd_0v9;
struct regulator *avdd_1v8;
struct phy *phy; struct phy *phy;
}; };
...@@ -226,6 +229,14 @@ static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi) ...@@ -226,6 +229,14 @@ static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi)
return PTR_ERR(hdmi->grf_clk); return PTR_ERR(hdmi->grf_clk);
} }
hdmi->avdd_0v9 = devm_regulator_get(hdmi->dev, "avdd-0v9");
if (IS_ERR(hdmi->avdd_0v9))
return PTR_ERR(hdmi->avdd_0v9);
hdmi->avdd_1v8 = devm_regulator_get(hdmi->dev, "avdd-1v8");
if (IS_ERR(hdmi->avdd_1v8))
return PTR_ERR(hdmi->avdd_1v8);
return 0; return 0;
} }
...@@ -566,11 +577,23 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master, ...@@ -566,11 +577,23 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,
return ret; return ret;
} }
ret = regulator_enable(hdmi->avdd_0v9);
if (ret) {
DRM_DEV_ERROR(hdmi->dev, "failed to enable avdd0v9: %d\n", ret);
goto err_avdd_0v9;
}
ret = regulator_enable(hdmi->avdd_1v8);
if (ret) {
DRM_DEV_ERROR(hdmi->dev, "failed to enable avdd1v8: %d\n", ret);
goto err_avdd_1v8;
}
ret = clk_prepare_enable(hdmi->ref_clk); ret = clk_prepare_enable(hdmi->ref_clk);
if (ret) { if (ret) {
DRM_DEV_ERROR(hdmi->dev, "Failed to enable HDMI reference clock: %d\n", DRM_DEV_ERROR(hdmi->dev, "Failed to enable HDMI reference clock: %d\n",
ret); ret);
return ret; goto err_clk;
} }
if (hdmi->chip_data == &rk3568_chip_data) { if (hdmi->chip_data == &rk3568_chip_data) {
...@@ -594,10 +617,19 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master, ...@@ -594,10 +617,19 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,
*/ */
if (IS_ERR(hdmi->hdmi)) { if (IS_ERR(hdmi->hdmi)) {
ret = PTR_ERR(hdmi->hdmi); ret = PTR_ERR(hdmi->hdmi);
drm_encoder_cleanup(encoder); goto err_bind;
clk_disable_unprepare(hdmi->ref_clk);
} }
return 0;
err_bind:
drm_encoder_cleanup(encoder);
clk_disable_unprepare(hdmi->ref_clk);
err_clk:
regulator_disable(hdmi->avdd_1v8);
err_avdd_1v8:
regulator_disable(hdmi->avdd_0v9);
err_avdd_0v9:
return ret; return ret;
} }
...@@ -608,6 +640,9 @@ static void dw_hdmi_rockchip_unbind(struct device *dev, struct device *master, ...@@ -608,6 +640,9 @@ static void dw_hdmi_rockchip_unbind(struct device *dev, struct device *master,
dw_hdmi_unbind(hdmi->hdmi); dw_hdmi_unbind(hdmi->hdmi);
clk_disable_unprepare(hdmi->ref_clk); clk_disable_unprepare(hdmi->ref_clk);
regulator_disable(hdmi->avdd_1v8);
regulator_disable(hdmi->avdd_0v9);
} }
static const struct component_ops dw_hdmi_rockchip_ops = { static const struct component_ops dw_hdmi_rockchip_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment