]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
drm/vc4: Respect GPIO_ACTIVE_LOW on HDMI HPD if set in the devicetree.
authorEric Anholt <eric@anholt.net>
Tue, 1 Mar 2016 01:53:01 +0000 (17:53 -0800)
committerEric Anholt <eric@anholt.net>
Mon, 14 Mar 2016 00:06:57 +0000 (17:06 -0700)
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>
Tested-by: Daniel Stone <daniels@collabora.com>
drivers/gpu/drm/vc4/vc4_hdmi.c

index 6bcf51d16a1d7eb18a9826140c743c296863a598..d8b864925fd38757cdc12e72d5ea102f32d2af09 100644 (file)
@@ -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;
@@ -166,7 +167,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;
@@ -517,11 +519,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;