Commit 1a14e0c2 authored by Guido Günther's avatar Guido Günther Committed by Sam Ravnborg

drm/panel: jh057n00900: Add regulator support

Allow to specify regulators for vcc and iovcc. According to the data
sheet the panel wants vcc (2.8V) and iovcc (1.8V) and there's no startup
dependency between the two.
Signed-off-by: default avatarGuido Günther <agx@sigxcpu.org>
Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/f78611fb26329e50ec1533810fbb76562f2f4e48.1561542477.git.agx@sigxcpu.org
parent d4bd9a58
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/media-bus-format.h> #include <linux/media-bus-format.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/regulator/consumer.h>
#include <video/display_timing.h> #include <video/display_timing.h>
#include <video/mipi_display.h> #include <video/mipi_display.h>
...@@ -47,6 +48,8 @@ struct jh057n { ...@@ -47,6 +48,8 @@ struct jh057n {
struct drm_panel panel; struct drm_panel panel;
struct gpio_desc *reset_gpio; struct gpio_desc *reset_gpio;
struct backlight_device *backlight; struct backlight_device *backlight;
struct regulator *vcc;
struct regulator *iovcc;
bool prepared; bool prepared;
struct dentry *debugfs; struct dentry *debugfs;
...@@ -160,6 +163,8 @@ static int jh057n_unprepare(struct drm_panel *panel) ...@@ -160,6 +163,8 @@ static int jh057n_unprepare(struct drm_panel *panel)
return 0; return 0;
mipi_dsi_dcs_set_display_off(dsi); mipi_dsi_dcs_set_display_off(dsi);
regulator_disable(ctx->iovcc);
regulator_disable(ctx->vcc);
ctx->prepared = false; ctx->prepared = false;
return 0; return 0;
...@@ -174,6 +179,19 @@ static int jh057n_prepare(struct drm_panel *panel) ...@@ -174,6 +179,19 @@ static int jh057n_prepare(struct drm_panel *panel)
return 0; return 0;
DRM_DEV_DEBUG_DRIVER(ctx->dev, "Resetting the panel\n"); DRM_DEV_DEBUG_DRIVER(ctx->dev, "Resetting the panel\n");
ret = regulator_enable(ctx->vcc);
if (ret < 0) {
DRM_DEV_ERROR(ctx->dev,
"Failed to enable vcc supply: %d\n", ret);
return ret;
}
ret = regulator_enable(ctx->iovcc);
if (ret < 0) {
DRM_DEV_ERROR(ctx->dev,
"Failed to enable iovcc supply: %d\n", ret);
goto disable_vcc;
}
gpiod_set_value_cansleep(ctx->reset_gpio, 1); gpiod_set_value_cansleep(ctx->reset_gpio, 1);
usleep_range(20, 40); usleep_range(20, 40);
gpiod_set_value_cansleep(ctx->reset_gpio, 0); gpiod_set_value_cansleep(ctx->reset_gpio, 0);
...@@ -189,6 +207,10 @@ static int jh057n_prepare(struct drm_panel *panel) ...@@ -189,6 +207,10 @@ static int jh057n_prepare(struct drm_panel *panel)
ctx->prepared = true; ctx->prepared = true;
return 0; return 0;
disable_vcc:
regulator_disable(ctx->vcc);
return ret;
} }
static const struct drm_display_mode default_mode = { static const struct drm_display_mode default_mode = {
...@@ -301,6 +323,25 @@ static int jh057n_probe(struct mipi_dsi_device *dsi) ...@@ -301,6 +323,25 @@ static int jh057n_probe(struct mipi_dsi_device *dsi)
if (IS_ERR(ctx->backlight)) if (IS_ERR(ctx->backlight))
return PTR_ERR(ctx->backlight); return PTR_ERR(ctx->backlight);
ctx->vcc = devm_regulator_get(dev, "vcc");
if (IS_ERR(ctx->vcc)) {
ret = PTR_ERR(ctx->vcc);
if (ret != -EPROBE_DEFER)
DRM_DEV_ERROR(dev,
"Failed to request vcc regulator: %d\n",
ret);
return ret;
}
ctx->iovcc = devm_regulator_get(dev, "iovcc");
if (IS_ERR(ctx->iovcc)) {
ret = PTR_ERR(ctx->iovcc);
if (ret != -EPROBE_DEFER)
DRM_DEV_ERROR(dev,
"Failed to request iovcc regulator: %d\n",
ret);
return ret;
}
drm_panel_init(&ctx->panel); drm_panel_init(&ctx->panel);
ctx->panel.dev = dev; ctx->panel.dev = dev;
ctx->panel.funcs = &jh057n_drm_funcs; ctx->panel.funcs = &jh057n_drm_funcs;
......
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