summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-02-26 14:24:33 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2020-02-26 14:31:33 +0300
commit2df6428e290a61367b1a54db56fe49000dc4c49d (patch)
treecded9f0b46e24a4b6649bbae6823625acb3a0618 /drivers
parent272378ec0eb972100496c3be44be03b86caa9ca3 (diff)
downloadlinux-2df6428e290a61367b1a54db56fe49000dc4c49d.tar.xz
drm/bridge: simple-bridge: Add support for enable GPIO
If an enable GPIO is declared in the firmware, assert it when enabling the bridge and deassert it when disabling it. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com> Reviewed-by: Stefan Agner <stefan@agner.ch> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Maxime Ripard <mripard@kernel.org> Acked-by: Sam Ravnborg <sam@ravnborg.org> Tested-by: Sebastian Reichel <sebastian.reichel@collabora.com> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200226112514.12455-14-laurent.pinchart@ideasonboard.com
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/bridge/simple-bridge.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/gpu/drm/bridge/simple-bridge.c b/drivers/gpu/drm/bridge/simple-bridge.c
index 20866c1230de..70e6092bdf6c 100644
--- a/drivers/gpu/drm/bridge/simple-bridge.c
+++ b/drivers/gpu/drm/bridge/simple-bridge.c
@@ -6,6 +6,7 @@
* Maxime Ripard <maxime.ripard@free-electrons.com>
*/
+#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of_graph.h>
@@ -30,6 +31,7 @@ struct simple_bridge {
struct i2c_adapter *ddc;
struct regulator *vdd;
+ struct gpio_desc *enable;
};
static inline struct simple_bridge *
@@ -143,19 +145,23 @@ static int simple_bridge_attach(struct drm_bridge *bridge,
static void simple_bridge_enable(struct drm_bridge *bridge)
{
struct simple_bridge *sbridge = drm_bridge_to_simple_bridge(bridge);
- int ret = 0;
+ int ret;
- if (sbridge->vdd)
+ if (sbridge->vdd) {
ret = regulator_enable(sbridge->vdd);
+ if (ret)
+ DRM_ERROR("Failed to enable vdd regulator: %d\n", ret);
+ }
- if (ret)
- DRM_ERROR("Failed to enable vdd regulator: %d\n", ret);
+ gpiod_set_value_cansleep(sbridge->enable, 1);
}
static void simple_bridge_disable(struct drm_bridge *bridge)
{
struct simple_bridge *sbridge = drm_bridge_to_simple_bridge(bridge);
+ gpiod_set_value_cansleep(sbridge->enable, 0);
+
if (sbridge->vdd)
regulator_disable(sbridge->vdd);
}
@@ -208,6 +214,14 @@ static int simple_bridge_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "No vdd regulator found: %d\n", ret);
}
+ sbridge->enable = devm_gpiod_get_optional(&pdev->dev, "enable",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(sbridge->enable)) {
+ if (PTR_ERR(sbridge->enable) != -EPROBE_DEFER)
+ dev_err(&pdev->dev, "Unable to retrieve enable GPIO\n");
+ return PTR_ERR(sbridge->enable);
+ }
+
sbridge->ddc = simple_bridge_retrieve_ddc(&pdev->dev);
if (IS_ERR(sbridge->ddc)) {
if (PTR_ERR(sbridge->ddc) == -ENODEV) {