Skip to content

Commit 6eb6b6f

Browse files
lumagsuperna9999
authored andcommitted
drm/bridge: display-connector: handle hdmi-pwr supply
On some devices the +5V Power pin of the HDMI connector and/or the ESD protection logic is powered on by a separate regulator. Instead of declaring this regulator as always-on, make hdmi-connector support the additional hdmi-pwr supply. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://patchwork.freedesktop.org/patch/msgid/20230531000259.3758235-4-dmitry.baryshkov@linaro.org
1 parent 99304fd commit 6eb6b6f

1 file changed

Lines changed: 29 additions & 26 deletions

File tree

drivers/gpu/drm/bridge/display-connector.c

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,18 @@ static irqreturn_t display_connector_hpd_irq(int irq, void *arg)
191191
return IRQ_HANDLED;
192192
}
193193

194+
static int display_connector_get_supply(struct platform_device *pdev,
195+
struct display_connector *conn,
196+
const char *name)
197+
{
198+
conn->supply = devm_regulator_get_optional(&pdev->dev, name);
199+
200+
if (conn->supply == ERR_PTR(-ENODEV))
201+
conn->supply = NULL;
202+
203+
return PTR_ERR_OR_ZERO(conn->supply);
204+
}
205+
194206
static int display_connector_probe(struct platform_device *pdev)
195207
{
196208
struct display_connector *conn;
@@ -316,43 +328,34 @@ static int display_connector_probe(struct platform_device *pdev)
316328
if (type == DRM_MODE_CONNECTOR_DisplayPort) {
317329
int ret;
318330

319-
conn->supply = devm_regulator_get_optional(&pdev->dev, "dp-pwr");
320-
321-
if (IS_ERR(conn->supply)) {
322-
ret = PTR_ERR(conn->supply);
323-
324-
switch (ret) {
325-
case -ENODEV:
326-
conn->supply = NULL;
327-
break;
328-
329-
case -EPROBE_DEFER:
330-
return -EPROBE_DEFER;
331-
332-
default:
333-
dev_err(&pdev->dev, "failed to get DP PWR regulator: %d\n", ret);
334-
return ret;
335-
}
336-
}
337-
338-
if (conn->supply) {
339-
ret = regulator_enable(conn->supply);
340-
if (ret) {
341-
dev_err(&pdev->dev, "failed to enable DP PWR regulator: %d\n", ret);
342-
return ret;
343-
}
344-
}
331+
ret = display_connector_get_supply(pdev, conn, "dp-pwr");
332+
if (ret < 0)
333+
return dev_err_probe(&pdev->dev, ret, "failed to get DP PWR regulator\n");
345334
}
346335

347336
/* enable DDC */
348337
if (type == DRM_MODE_CONNECTOR_HDMIA) {
338+
int ret;
339+
349340
conn->ddc_en = devm_gpiod_get_optional(&pdev->dev, "ddc-en",
350341
GPIOD_OUT_HIGH);
351342

352343
if (IS_ERR(conn->ddc_en)) {
353344
dev_err(&pdev->dev, "Couldn't get ddc-en gpio\n");
354345
return PTR_ERR(conn->ddc_en);
355346
}
347+
348+
ret = display_connector_get_supply(pdev, conn, "hdmi-pwr");
349+
if (ret < 0)
350+
return dev_err_probe(&pdev->dev, ret, "failed to get HDMI +5V Power regulator\n");
351+
}
352+
353+
if (conn->supply) {
354+
ret = regulator_enable(conn->supply);
355+
if (ret) {
356+
dev_err(&pdev->dev, "failed to enable PWR regulator: %d\n", ret);
357+
return ret;
358+
}
356359
}
357360

358361
conn->bridge.funcs = &display_connector_bridge_funcs;

0 commit comments

Comments
 (0)