* [PATCH 2/2] drm/vc4: Respect GPIO_ACTIVE_LOW on HDMI HPD if set in the devicetree.
2016-03-01 1:52 [PATCH 0/2] drm/vc4: Fixes for Raspberry Pi 3 Eric Anholt
2016-03-01 1:53 ` [PATCH 1/2] drm/vc4: Let gpiolib know that we're OK with sleeping for HPD Eric Anholt
@ 2016-03-01 1:53 ` Eric Anholt
2016-03-01 18:21 ` [PATCH 0/2] drm/vc4: Fixes for Raspberry Pi 3 Daniel Stone
2 siblings, 0 replies; 4+ messages in thread
From: Eric Anholt @ 2016-03-01 1:53 UTC (permalink / raw)
To: dri-devel; +Cc: linux-kernel, David Airlie, Eric Anholt
The original Raspberry Pi had the GPIO active high, but the later
models are active low. The DT GPIO bindings allow specifying the
active flag, except that it doesn't get propagated to the gpiodesc, so
you have to handle it yourself.
Signed-off-by: Eric Anholt <eric@anholt.net>
---
drivers/gpu/drm/vc4/vc4_hdmi.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index 709ed57..dc60485 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -47,6 +47,7 @@ struct vc4_hdmi {
void __iomem *hdmicore_regs;
void __iomem *hd_regs;
int hpd_gpio;
+ bool hpd_active_low;
struct clk *pixel_clock;
struct clk *hsm_clock;
@@ -165,7 +166,8 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, bool force)
struct vc4_dev *vc4 = to_vc4_dev(dev);
if (vc4->hdmi->hpd_gpio) {
- if (gpio_get_value_cansleep(vc4->hdmi->hpd_gpio))
+ if (gpio_get_value_cansleep(vc4->hdmi->hpd_gpio) ^
+ vc4->hdmi->hpd_active_low)
return connector_status_connected;
else
return connector_status_disconnected;
@@ -506,11 +508,17 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
* we'll use the HDMI core's register.
*/
if (of_find_property(dev->of_node, "hpd-gpios", &value)) {
- hdmi->hpd_gpio = of_get_named_gpio(dev->of_node, "hpd-gpios", 0);
+ enum of_gpio_flags hpd_gpio_flags;
+
+ hdmi->hpd_gpio = of_get_named_gpio_flags(dev->of_node,
+ "hpd-gpios", 0,
+ &hpd_gpio_flags);
if (hdmi->hpd_gpio < 0) {
ret = hdmi->hpd_gpio;
goto err_unprepare_hsm;
}
+
+ hdmi->hpd_active_low = hpd_gpio_flags & OF_GPIO_ACTIVE_LOW;
}
vc4->hdmi = hdmi;
--
2.7.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 0/2] drm/vc4: Fixes for Raspberry Pi 3
2016-03-01 1:52 [PATCH 0/2] drm/vc4: Fixes for Raspberry Pi 3 Eric Anholt
2016-03-01 1:53 ` [PATCH 1/2] drm/vc4: Let gpiolib know that we're OK with sleeping for HPD Eric Anholt
2016-03-01 1:53 ` [PATCH 2/2] drm/vc4: Respect GPIO_ACTIVE_LOW on HDMI HPD if set in the devicetree Eric Anholt
@ 2016-03-01 18:21 ` Daniel Stone
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Stone @ 2016-03-01 18:21 UTC (permalink / raw)
To: Eric Anholt; +Cc: dri-devel, Linux Kernel Mailing List, David Airlie
Hi,
On 1 March 2016 at 01:52, Eric Anholt <eric@anholt.net> wrote:
> These are for fixing the vc4 driver on the Pi 3. Note that patch 2
> will also be necessary for fixing HPD on the Pi2, which we've been
> carrying downstream patches to work around until now.
Indeed. Having cherry-picked 80032d2e61 and added ACTIVE_LOW to the
bcm2836-rpi-2-b DT, I now get HPD reported correctly.
I think it might still need work: on RPi2 again, DDC fails on boot
(the same BCM2835_I2C_S_ERR bit being set, i.e. 'i2c transfer failed:
100'), and does work after a hotplug cycle. But the machine then
immediately hard-hangs - no serial console - after cat
/sys/class/drm/card0-HDMI-A-1/edid.
On the grounds that the VC4 node isn't yet in upstream DT though, and
this _does_ indeed fix HPD:
Tested-by: Daniel Stone <daniels@collabora.com>
Cheers,
Daniel
^ permalink raw reply [flat|nested] 4+ messages in thread