Commit 633ba1e0 authored by Jernej Skrabec's avatar Jernej Skrabec Committed by Maxime Ripard

drm/sun4i: Add support for HDMI voltage regulator

Some boards have HDMI VCC pin connected to voltage regulator which may
not be turned on by default.

Add support for such boards by adding voltage regulator handling code to
HDMI driver.
Signed-off-by: default avatarJernej Skrabec <jernej.skrabec@siol.net>
[Icenowy: change supply name to "hvcc"]
Signed-off-by: default avatarIcenowy Zheng <icenowy@aosc.io>
Signed-off-by: default avatarMaxime Ripard <maxime.ripard@bootlin.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180904044053.15425-11-icenowy@aosc.io
parent 50414b95
...@@ -125,10 +125,22 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, ...@@ -125,10 +125,22 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
return PTR_ERR(hdmi->clk_tmds); return PTR_ERR(hdmi->clk_tmds);
} }
hdmi->regulator = devm_regulator_get(dev, "hvcc");
if (IS_ERR(hdmi->regulator)) {
dev_err(dev, "Couldn't get regulator\n");
return PTR_ERR(hdmi->regulator);
}
ret = regulator_enable(hdmi->regulator);
if (ret) {
dev_err(dev, "Failed to enable regulator\n");
return ret;
}
ret = reset_control_deassert(hdmi->rst_ctrl); ret = reset_control_deassert(hdmi->rst_ctrl);
if (ret) { if (ret) {
dev_err(dev, "Could not deassert ctrl reset control\n"); dev_err(dev, "Could not deassert ctrl reset control\n");
return ret; goto err_disable_regulator;
} }
ret = clk_prepare_enable(hdmi->clk_tmds); ret = clk_prepare_enable(hdmi->clk_tmds);
...@@ -183,6 +195,8 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, ...@@ -183,6 +195,8 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
clk_disable_unprepare(hdmi->clk_tmds); clk_disable_unprepare(hdmi->clk_tmds);
err_assert_ctrl_reset: err_assert_ctrl_reset:
reset_control_assert(hdmi->rst_ctrl); reset_control_assert(hdmi->rst_ctrl);
err_disable_regulator:
regulator_disable(hdmi->regulator);
return ret; return ret;
} }
...@@ -196,6 +210,7 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master, ...@@ -196,6 +210,7 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master,
sun8i_hdmi_phy_remove(hdmi); sun8i_hdmi_phy_remove(hdmi);
clk_disable_unprepare(hdmi->clk_tmds); clk_disable_unprepare(hdmi->clk_tmds);
reset_control_assert(hdmi->rst_ctrl); reset_control_assert(hdmi->rst_ctrl);
regulator_disable(hdmi->regulator);
} }
static const struct component_ops sun8i_dw_hdmi_ops = { static const struct component_ops sun8i_dw_hdmi_ops = {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <drm/drm_encoder.h> #include <drm/drm_encoder.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/reset.h> #include <linux/reset.h>
#define SUN8I_HDMI_PHY_DBG_CTRL_REG 0x0000 #define SUN8I_HDMI_PHY_DBG_CTRL_REG 0x0000
...@@ -176,6 +177,7 @@ struct sun8i_dw_hdmi { ...@@ -176,6 +177,7 @@ struct sun8i_dw_hdmi {
struct drm_encoder encoder; struct drm_encoder encoder;
struct sun8i_hdmi_phy *phy; struct sun8i_hdmi_phy *phy;
struct dw_hdmi_plat_data plat_data; struct dw_hdmi_plat_data plat_data;
struct regulator *regulator;
struct reset_control *rst_ctrl; struct reset_control *rst_ctrl;
}; };
......
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