Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/panel: otm8009a: Add support for the optional power-supply

Add support for the optional power-supply.

Note: A "dummy regulator" is returned by devm_regulator_get()
if the optional regulator is not present in the device tree,
simplifying the source code when enabling/disabling the regulator.

Signed-off-by: Philippe Cornu <philippe.cornu@st.com>
Reviewed-by: Yannick Fertré <yannick.fertre@st.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180205094532.23547-3-philippe.cornu@st.com

authored by

Philippe CORNU and committed by
Thierry Reding
ded8d7fe 683ad261

+17
+17
drivers/gpu/drm/panel/panel-orisetech-otm8009a.c
··· 11 11 #include <drm/drm_panel.h> 12 12 #include <linux/backlight.h> 13 13 #include <linux/gpio/consumer.h> 14 + #include <linux/regulator/consumer.h> 14 15 #include <video/mipi_display.h> 15 16 16 17 #define DRV_NAME "orisetech_otm8009a" ··· 63 62 struct drm_panel panel; 64 63 struct backlight_device *bl_dev; 65 64 struct gpio_desc *reset_gpio; 65 + struct regulator *supply; 66 66 bool prepared; 67 67 bool enabled; 68 68 }; ··· 281 279 msleep(20); 282 280 } 283 281 282 + regulator_disable(ctx->supply); 283 + 284 284 ctx->prepared = false; 285 285 286 286 return 0; ··· 295 291 296 292 if (ctx->prepared) 297 293 return 0; 294 + 295 + ret = regulator_enable(ctx->supply); 296 + if (ret < 0) { 297 + DRM_ERROR("failed to enable supply: %d\n", ret); 298 + return ret; 299 + } 298 300 299 301 if (ctx->reset_gpio) { 300 302 gpiod_set_value_cansleep(ctx->reset_gpio, 0); ··· 422 412 if (IS_ERR(ctx->reset_gpio)) { 423 413 dev_err(dev, "cannot get reset-gpio\n"); 424 414 return PTR_ERR(ctx->reset_gpio); 415 + } 416 + 417 + ctx->supply = devm_regulator_get(dev, "power"); 418 + if (IS_ERR(ctx->supply)) { 419 + ret = PTR_ERR(ctx->supply); 420 + dev_err(dev, "failed to request regulator: %d\n", ret); 421 + return ret; 425 422 } 426 423 427 424 mipi_dsi_set_drvdata(dsi, ctx);