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