Skip to content

Commit 633ba1e

Browse files
jernejskmripard
authored andcommitted
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: Jernej Skrabec <jernej.skrabec@siol.net> [Icenowy: change supply name to "hvcc"] Signed-off-by: Icenowy Zheng <icenowy@aosc.io> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180904044053.15425-11-icenowy@aosc.io
1 parent 50414b9 commit 633ba1e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,22 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
125125
return PTR_ERR(hdmi->clk_tmds);
126126
}
127127

128+
hdmi->regulator = devm_regulator_get(dev, "hvcc");
129+
if (IS_ERR(hdmi->regulator)) {
130+
dev_err(dev, "Couldn't get regulator\n");
131+
return PTR_ERR(hdmi->regulator);
132+
}
133+
134+
ret = regulator_enable(hdmi->regulator);
135+
if (ret) {
136+
dev_err(dev, "Failed to enable regulator\n");
137+
return ret;
138+
}
139+
128140
ret = reset_control_deassert(hdmi->rst_ctrl);
129141
if (ret) {
130142
dev_err(dev, "Could not deassert ctrl reset control\n");
131-
return ret;
143+
goto err_disable_regulator;
132144
}
133145

134146
ret = clk_prepare_enable(hdmi->clk_tmds);
@@ -183,6 +195,8 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
183195
clk_disable_unprepare(hdmi->clk_tmds);
184196
err_assert_ctrl_reset:
185197
reset_control_assert(hdmi->rst_ctrl);
198+
err_disable_regulator:
199+
regulator_disable(hdmi->regulator);
186200

187201
return ret;
188202
}
@@ -196,6 +210,7 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master,
196210
sun8i_hdmi_phy_remove(hdmi);
197211
clk_disable_unprepare(hdmi->clk_tmds);
198212
reset_control_assert(hdmi->rst_ctrl);
213+
regulator_disable(hdmi->regulator);
199214
}
200215

201216
static const struct component_ops sun8i_dw_hdmi_ops = {

drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <drm/drm_encoder.h>
1111
#include <linux/clk.h>
1212
#include <linux/regmap.h>
13+
#include <linux/regulator/consumer.h>
1314
#include <linux/reset.h>
1415

1516
#define SUN8I_HDMI_PHY_DBG_CTRL_REG 0x0000
@@ -176,6 +177,7 @@ struct sun8i_dw_hdmi {
176177
struct drm_encoder encoder;
177178
struct sun8i_hdmi_phy *phy;
178179
struct dw_hdmi_plat_data plat_data;
180+
struct regulator *regulator;
179181
struct reset_control *rst_ctrl;
180182
};
181183

0 commit comments

Comments
 (0)