Commit 61714cd3 authored by Sebastian Reichel's avatar Sebastian Reichel Committed by Tomi Valkeinen

drm/omap: panel-dsi-cm: use bulk regulator API

Use bulk regulator API to simplify the code. This also switches
from _optional variant to normal variant, which will provide a
dummy regulator (i.e. if some always-enabled regulator is not
described in DT).
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201215104657.802264-23-tomi.valkeinen@ti.com
parent 68ca91d7
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#define DCS_GET_ID2 0xdb #define DCS_GET_ID2 0xdb
#define DCS_GET_ID3 0xdc #define DCS_GET_ID3 0xdc
#define DCS_REGULATOR_SUPPLY_NUM 2
struct panel_drv_data { struct panel_drv_data {
struct mipi_dsi_device *dsi; struct mipi_dsi_device *dsi;
...@@ -54,8 +56,7 @@ struct panel_drv_data { ...@@ -54,8 +56,7 @@ struct panel_drv_data {
struct gpio_desc *reset_gpio; struct gpio_desc *reset_gpio;
struct gpio_desc *ext_te_gpio; struct gpio_desc *ext_te_gpio;
struct regulator *vpnl; struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM];
struct regulator *vddi;
bool use_dsi_backlight; bool use_dsi_backlight;
...@@ -556,28 +557,16 @@ static int dsicm_power_on(struct panel_drv_data *ddata) ...@@ -556,28 +557,16 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
.lp_clk_max = 10000000, .lp_clk_max = 10000000,
}; };
if (ddata->vpnl) { r = regulator_bulk_enable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
r = regulator_enable(ddata->vpnl);
if (r) { if (r) {
dev_err(&ddata->dsi->dev, dev_err(&ddata->dsi->dev, "failed to enable supplies: %d\n", r);
"failed to enable VPNL: %d\n", r);
return r; return r;
} }
}
if (ddata->vddi) {
r = regulator_enable(ddata->vddi);
if (r) {
dev_err(&ddata->dsi->dev,
"failed to enable VDDI: %d\n", r);
goto err_vpnl;
}
}
r = src->ops->dsi.set_config(src, &dsi_config); r = src->ops->dsi.set_config(src, &dsi_config);
if (r) { if (r) {
dev_err(&ddata->dsi->dev, "failed to configure DSI\n"); dev_err(&ddata->dsi->dev, "failed to configure DSI\n");
goto err_vddi; goto err_regulators;
} }
src->ops->enable(src); src->ops->enable(src);
...@@ -636,12 +625,10 @@ static int dsicm_power_on(struct panel_drv_data *ddata) ...@@ -636,12 +625,10 @@ static int dsicm_power_on(struct panel_drv_data *ddata)
dsicm_hw_reset(ddata); dsicm_hw_reset(ddata);
src->ops->dsi.disable(src, true, false); src->ops->dsi.disable(src, true, false);
err_vddi: err_regulators:
if (ddata->vddi) r = regulator_bulk_disable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
regulator_disable(ddata->vddi); if (r)
err_vpnl: dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r);
if (ddata->vpnl)
regulator_disable(ddata->vpnl);
return r; return r;
} }
...@@ -665,10 +652,9 @@ static void dsicm_power_off(struct panel_drv_data *ddata) ...@@ -665,10 +652,9 @@ static void dsicm_power_off(struct panel_drv_data *ddata)
src->ops->dsi.disable(src, true, false); src->ops->dsi.disable(src, true, false);
if (ddata->vddi) r = regulator_bulk_disable(ARRAY_SIZE(ddata->supplies), ddata->supplies);
regulator_disable(ddata->vddi); if (r)
if (ddata->vpnl) dev_err(&ddata->dsi->dev, "failed to disable supplies: %d\n", r);
regulator_disable(ddata->vpnl);
ddata->enabled = false; ddata->enabled = false;
} }
...@@ -972,21 +958,12 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi) ...@@ -972,21 +958,12 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
ddata->height_mm = 0; ddata->height_mm = 0;
of_property_read_u32(node, "height-mm", &ddata->height_mm); of_property_read_u32(node, "height-mm", &ddata->height_mm);
ddata->vpnl = devm_regulator_get_optional(&dsi->dev, "vpnl"); ddata->supplies[0].supply = "vpnl";
if (IS_ERR(ddata->vpnl)) { ddata->supplies[1].supply = "vddi";
err = PTR_ERR(ddata->vpnl); err = devm_regulator_bulk_get(&dsi->dev, ARRAY_SIZE(ddata->supplies),
if (err == -EPROBE_DEFER) ddata->supplies);
if (err)
return err; return err;
ddata->vpnl = NULL;
}
ddata->vddi = devm_regulator_get_optional(&dsi->dev, "vddi");
if (IS_ERR(ddata->vddi)) {
err = PTR_ERR(ddata->vddi);
if (err == -EPROBE_DEFER)
return err;
ddata->vddi = NULL;
}
backlight = devm_of_find_backlight(&dsi->dev); backlight = devm_of_find_backlight(&dsi->dev);
if (IS_ERR(backlight)) if (IS_ERR(backlight))
......
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