0292-drm-vc4-Respect-GPIO_ACTIVE_LOW-on-HDMI-HPD-if-set-i.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. From 874ea6861ec0a21d463a03ed32288c9eedb06a7f Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Mon, 29 Feb 2016 17:53:01 -0800
  4. Subject: [PATCH] drm/vc4: Respect GPIO_ACTIVE_LOW on HDMI HPD if set in the
  5. devicetree.
  6. The original Raspberry Pi had the GPIO active high, but the later
  7. models are active low. The DT GPIO bindings allow specifying the
  8. active flag, except that it doesn't get propagated to the gpiodesc, so
  9. you have to handle it yourself.
  10. Signed-off-by: Eric Anholt <eric@anholt.net>
  11. Tested-by: Daniel Stone <daniels@collabora.com>
  12. (cherry picked from commit 0b06e0a7945130e6a187f7959529cba7725f573a)
  13. ---
  14. drivers/gpu/drm/vc4/vc4_hdmi.c | 12 ++++++++++--
  15. 1 file changed, 10 insertions(+), 2 deletions(-)
  16. --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
  17. +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
  18. @@ -47,6 +47,7 @@ struct vc4_hdmi {
  19. void __iomem *hdmicore_regs;
  20. void __iomem *hd_regs;
  21. int hpd_gpio;
  22. + bool hpd_active_low;
  23. struct clk *pixel_clock;
  24. struct clk *hsm_clock;
  25. @@ -168,7 +169,8 @@ vc4_hdmi_connector_detect(struct drm_con
  26. return connector_status_connected;
  27. if (vc4->hdmi->hpd_gpio) {
  28. - if (gpio_get_value_cansleep(vc4->hdmi->hpd_gpio))
  29. + if (gpio_get_value_cansleep(vc4->hdmi->hpd_gpio) ^
  30. + vc4->hdmi->hpd_active_low)
  31. return connector_status_connected;
  32. else
  33. return connector_status_disconnected;
  34. @@ -519,11 +521,17 @@ static int vc4_hdmi_bind(struct device *
  35. * we'll use the HDMI core's register.
  36. */
  37. if (of_find_property(dev->of_node, "hpd-gpios", &value)) {
  38. - hdmi->hpd_gpio = of_get_named_gpio(dev->of_node, "hpd-gpios", 0);
  39. + enum of_gpio_flags hpd_gpio_flags;
  40. +
  41. + hdmi->hpd_gpio = of_get_named_gpio_flags(dev->of_node,
  42. + "hpd-gpios", 0,
  43. + &hpd_gpio_flags);
  44. if (hdmi->hpd_gpio < 0) {
  45. ret = hdmi->hpd_gpio;
  46. goto err_unprepare_hsm;
  47. }
  48. +
  49. + hdmi->hpd_active_low = hpd_gpio_flags & OF_GPIO_ACTIVE_LOW;
  50. }
  51. vc4->hdmi = hdmi;