aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJernej Skrabec <jernej.skrabec@siol.net>2018-09-04 00:40:52 -0400
committerMaxime Ripard <maxime.ripard@bootlin.com>2018-09-05 03:20:28 -0400
commit633ba1e086e1abbeef1ffd899911de8cf3987d9f (patch)
treedf2c74c9f296e748109a0df731543551c18174ec
parent50414b954ba647693db655fb753811dc895e8cbe (diff)
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
-rw-r--r--drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c17
-rw-r--r--drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h2
2 files changed, 18 insertions, 1 deletions
diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
index 31875b636434..ed2983770e9c 100644
--- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
+++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
@@ -125,10 +125,22 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
125 return PTR_ERR(hdmi->clk_tmds); 125 return PTR_ERR(hdmi->clk_tmds);
126 } 126 }
127 127
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
128 ret = reset_control_deassert(hdmi->rst_ctrl); 140 ret = reset_control_deassert(hdmi->rst_ctrl);
129 if (ret) { 141 if (ret) {
130 dev_err(dev, "Could not deassert ctrl reset control\n"); 142 dev_err(dev, "Could not deassert ctrl reset control\n");
131 return ret; 143 goto err_disable_regulator;
132 } 144 }
133 145
134 ret = clk_prepare_enable(hdmi->clk_tmds); 146 ret = clk_prepare_enable(hdmi->clk_tmds);
@@ -183,6 +195,8 @@ err_disable_clk_tmds:
183 clk_disable_unprepare(hdmi->clk_tmds); 195 clk_disable_unprepare(hdmi->clk_tmds);
184err_assert_ctrl_reset: 196err_assert_ctrl_reset:
185 reset_control_assert(hdmi->rst_ctrl); 197 reset_control_assert(hdmi->rst_ctrl);
198err_disable_regulator:
199 regulator_disable(hdmi->regulator);
186 200
187 return ret; 201 return ret;
188} 202}
@@ -196,6 +210,7 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master,
196 sun8i_hdmi_phy_remove(hdmi); 210 sun8i_hdmi_phy_remove(hdmi);
197 clk_disable_unprepare(hdmi->clk_tmds); 211 clk_disable_unprepare(hdmi->clk_tmds);
198 reset_control_assert(hdmi->rst_ctrl); 212 reset_control_assert(hdmi->rst_ctrl);
213 regulator_disable(hdmi->regulator);
199} 214}
200 215
201static const struct component_ops sun8i_dw_hdmi_ops = { 216static const struct component_ops sun8i_dw_hdmi_ops = {
diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
index aadbe0a10b0c..7fdc1ecd2892 100644
--- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
+++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
@@ -10,6 +10,7 @@
10#include <drm/drm_encoder.h> 10#include <drm/drm_encoder.h>
11#include <linux/clk.h> 11#include <linux/clk.h>
12#include <linux/regmap.h> 12#include <linux/regmap.h>
13#include <linux/regulator/consumer.h>
13#include <linux/reset.h> 14#include <linux/reset.h>
14 15
15#define SUN8I_HDMI_PHY_DBG_CTRL_REG 0x0000 16#define SUN8I_HDMI_PHY_DBG_CTRL_REG 0x0000
@@ -176,6 +177,7 @@ struct sun8i_dw_hdmi {
176 struct drm_encoder encoder; 177 struct drm_encoder encoder;
177 struct sun8i_hdmi_phy *phy; 178 struct sun8i_hdmi_phy *phy;
178 struct dw_hdmi_plat_data plat_data; 179 struct dw_hdmi_plat_data plat_data;
180 struct regulator *regulator;
179 struct reset_control *rst_ctrl; 181 struct reset_control *rst_ctrl;
180}; 182};
181 183