Commit 07633840 authored by Peter Rosin's avatar Peter Rosin Committed by Andrzej Hajda

drm/bridge: lvds-encoder: add powerdown-gpios support

Optionally power down the LVDS-encoder when it is not in use.
Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
Reviewed-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
Signed-off-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190111151843.11114-6-peda@axentia.se
parent b2304b2e
...@@ -11,11 +11,13 @@ ...@@ -11,11 +11,13 @@
#include <drm/drm_bridge.h> #include <drm/drm_bridge.h>
#include <drm/drm_panel.h> #include <drm/drm_panel.h>
#include <linux/gpio/consumer.h>
#include <linux/of_graph.h> #include <linux/of_graph.h>
struct lvds_encoder { struct lvds_encoder {
struct drm_bridge bridge; struct drm_bridge bridge;
struct drm_bridge *panel_bridge; struct drm_bridge *panel_bridge;
struct gpio_desc *powerdown_gpio;
}; };
static int lvds_encoder_attach(struct drm_bridge *bridge) static int lvds_encoder_attach(struct drm_bridge *bridge)
...@@ -28,8 +30,30 @@ static int lvds_encoder_attach(struct drm_bridge *bridge) ...@@ -28,8 +30,30 @@ static int lvds_encoder_attach(struct drm_bridge *bridge)
bridge); bridge);
} }
static void lvds_encoder_enable(struct drm_bridge *bridge)
{
struct lvds_encoder *lvds_encoder = container_of(bridge,
struct lvds_encoder,
bridge);
if (lvds_encoder->powerdown_gpio)
gpiod_set_value_cansleep(lvds_encoder->powerdown_gpio, 0);
}
static void lvds_encoder_disable(struct drm_bridge *bridge)
{
struct lvds_encoder *lvds_encoder = container_of(bridge,
struct lvds_encoder,
bridge);
if (lvds_encoder->powerdown_gpio)
gpiod_set_value_cansleep(lvds_encoder->powerdown_gpio, 1);
}
static struct drm_bridge_funcs funcs = { static struct drm_bridge_funcs funcs = {
.attach = lvds_encoder_attach, .attach = lvds_encoder_attach,
.enable = lvds_encoder_enable,
.disable = lvds_encoder_disable,
}; };
static int lvds_encoder_probe(struct platform_device *pdev) static int lvds_encoder_probe(struct platform_device *pdev)
...@@ -45,6 +69,16 @@ static int lvds_encoder_probe(struct platform_device *pdev) ...@@ -45,6 +69,16 @@ static int lvds_encoder_probe(struct platform_device *pdev)
if (!lvds_encoder) if (!lvds_encoder)
return -ENOMEM; return -ENOMEM;
lvds_encoder->powerdown_gpio = devm_gpiod_get_optional(dev, "powerdown",
GPIOD_OUT_HIGH);
if (IS_ERR(lvds_encoder->powerdown_gpio)) {
int err = PTR_ERR(lvds_encoder->powerdown_gpio);
if (err != -EPROBE_DEFER)
dev_err(dev, "powerdown GPIO failure: %d\n", err);
return err;
}
/* Locate the panel DT node. */ /* Locate the panel DT node. */
port = of_graph_get_port_by_id(dev->of_node, 1); port = of_graph_get_port_by_id(dev->of_node, 1);
if (!port) { if (!port) {
......
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