diff options
author | Stefan Agner <stefan.agner@toradex.com> | 2018-02-16 16:07:24 +0100 |
---|---|---|
committer | Marcel Ziswiler <marcel.ziswiler@toradex.com> | 2020-02-09 22:45:45 +0100 |
commit | c19224642168745b140c229a463038354ed9fc09 (patch) | |
tree | 56f2855708fa066295171d55f5ee32a5f5bbdc18 /drivers | |
parent | 03e68a4ec8760bbb6b2407711d9bbbd16d2a374c (diff) |
drm/imx/hdp: add HDMI CTRL GPIO support
Add support to control HDMI levels using a GPIO. The driver simply
sets the GPIO high for HDMI and low for DisplayPort.
Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
(cherry picked from commit d8868d38dc929cc5c4591f583489cdc57e93e9f2)
(cherry picked from commit b7d9e3c98e2d1681e2366f9011c599003e2179d3)
(cherry picked from commit 59004b52a9dcd08a1c1e3436851b2179f4ac7727)
(cherry picked from commit 060dd7a275260c26e0341dce9be59ec5c49722a4)
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/imx/hdp/imx-hdp.c | 29 | ||||
-rw-r--r-- | drivers/gpu/drm/imx/hdp/imx-hdp.h | 2 |
2 files changed, 28 insertions, 3 deletions
diff --git a/drivers/gpu/drm/imx/hdp/imx-hdp.c b/drivers/gpu/drm/imx/hdp/imx-hdp.c index 0e13ca85a571..93de72ff1990 100644 --- a/drivers/gpu/drm/imx/hdp/imx-hdp.c +++ b/drivers/gpu/drm/imx/hdp/imx-hdp.c @@ -21,6 +21,7 @@ #include <linux/of.h> #include <linux/irq.h> #include <linux/of_device.h> +#include <linux/of_gpio.h> #include "imx-hdp.h" #include "imx-hdmi.h" @@ -1327,6 +1328,7 @@ static struct hdp_ops imx8qm_hdmi_ops = { }; static struct hdp_devtype imx8qm_dp_devtype = { + .is_hdmi_level = false, .audio_type = CDN_DPTX, .ops = &imx8qm_dp_ops, .rw = &imx8qm_rw, @@ -1334,6 +1336,7 @@ static struct hdp_devtype imx8qm_dp_devtype = { }; static struct hdp_devtype imx8qm_hdmi_devtype = { + .is_hdmi_level = true, .audio_type = CDN_HDMITX_TYPHOON, .ops = &imx8qm_hdmi_ops, .rw = &imx8qm_rw, @@ -1360,6 +1363,7 @@ static struct hdp_ops imx8mq_ops = { }; static struct hdp_devtype imx8mq_hdmi_devtype = { + .is_hdmi_level = true, .audio_type = CDN_HDMITX_KIRAN, .ops = &imx8mq_ops, .rw = &imx8mq_rw, @@ -1648,6 +1652,18 @@ static int imx_hdp_imx_bind(struct device *dev, struct device *master, INIT_DELAYED_WORK(&hdp->hotplug_work, hotplug_work_func); + hdp->hdmi_ctrl_gpio = of_get_named_gpio(dev->of_node, "hdmi-ctrl-gpios", 0); + if (gpio_is_valid(hdp->hdmi_ctrl_gpio)) { + ret = gpio_request(hdp->hdmi_ctrl_gpio, "HDMI_CTRL"); + if (ret < 0) { + dev_err(dev, "request HDMI CTRL GPIO failed: %d\n", ret); + goto err_cleanup_encoder; + } + + /* Set signals depending on HDP device type */ + gpio_direction_output(hdp->hdmi_ctrl_gpio, devtype->is_hdmi_level); + } + /* Check cable states before enable irq */ imx_hdp_call(hdp, get_hpd_state, &hdp->state, &hpd); @@ -1661,7 +1677,7 @@ static int imx_hdp_imx_bind(struct device *dev, struct device *master, if (ret) { dev_err(&pdev->dev, "can't claim irq %d\n", hdp->irq[HPD_IRQ_IN]); - goto err_irq; + goto err_free_hdmi_gpio; } /* Cable Disconnedted, enable Plug in IRQ */ if (hpd == 0) @@ -1676,7 +1692,7 @@ static int imx_hdp_imx_bind(struct device *dev, struct device *master, if (ret) { dev_err(&pdev->dev, "can't claim irq %d\n", hdp->irq[HPD_IRQ_OUT]); - goto err_irq; + goto err_free_hdmi_gpio; } /* Cable Connected, enable Plug out IRQ */ if (hpd == 1) @@ -1692,7 +1708,11 @@ static int imx_hdp_imx_bind(struct device *dev, struct device *master, imx_hdp_register_audio_driver(dev); return 0; -err_irq: + +err_free_hdmi_gpio: + if (gpio_is_valid(hdp->hdmi_ctrl_gpio)) + gpio_free(hdp->hdmi_ctrl_gpio); +err_cleanup_encoder: drm_encoder_cleanup(encoder); return ret; } @@ -1707,6 +1727,9 @@ static void imx_hdp_imx_unbind(struct device *dev, struct device *master, imx_cec_unregister(&hdp->cec); #endif imx_hdp_call(hdp, pixel_clock_disable, &hdp->clks); + + if (gpio_is_valid(hdp->hdmi_ctrl_gpio)) + gpio_free(hdp->hdmi_ctrl_gpio); } static const struct component_ops imx_hdp_imx_ops = { diff --git a/drivers/gpu/drm/imx/hdp/imx-hdp.h b/drivers/gpu/drm/imx/hdp/imx-hdp.h index 52678a0bc0e3..62fc771adce6 100644 --- a/drivers/gpu/drm/imx/hdp/imx-hdp.h +++ b/drivers/gpu/drm/imx/hdp/imx-hdp.h @@ -128,6 +128,7 @@ struct hdp_ops { }; struct hdp_devtype { + u8 is_hdmi_level; u8 audio_type; struct hdp_ops *ops; struct hdp_rw_func *rw; @@ -214,6 +215,7 @@ struct imx_hdp { struct edid *edid; char cable_state; + int hdmi_ctrl_gpio; struct hdp_mem mem; struct imx_hdcp hdcp; |