fb4258ca79e089f5c1252ed5ea3366cc00cddc4e
[openwrt/staging/noltari.git] /
1 From 3542a39c5655242ba89bb4f51e9237cbb7e8cf09 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Fri, 19 Nov 2021 16:16:40 +0000
4 Subject: [PATCH] drm/vc4: Ensure vc4_hdmi doesn't use 2711 HPD
5 registers on Pi0-3
6
7 The existing logic was flawed in that it could try reading the
8 2711 specific registers for HPD on a CM1/3 where the HPD GPIO
9 hadn't been defined in DT.
10
11 Ensure we don't do the 2711 register read on invalid hardware,
12 and then
13
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
15 ---
16 drivers/gpu/drm/vc4/vc4_hdmi.c | 24 ++++++++++++++++--------
17 drivers/gpu/drm/vc4/vc4_hdmi.h | 3 +++
18 2 files changed, 19 insertions(+), 8 deletions(-)
19
20 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
21 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
22 @@ -206,14 +206,8 @@ vc4_hdmi_connector_detect(struct drm_con
23 if (gpiod_get_value_cansleep(vc4_hdmi->hpd_gpio))
24 connected = true;
25 } else {
26 - unsigned long flags;
27 - u32 hotplug;
28 -
29 - spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
30 - hotplug = HDMI_READ(HDMI_HOTPLUG);
31 - spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
32 -
33 - if (hotplug & VC4_HDMI_HOTPLUG_CONNECTED)
34 + if (vc4_hdmi->variant->hp_detect &&
35 + vc4_hdmi->variant->hp_detect(vc4_hdmi))
36 connected = true;
37 }
38
39 @@ -1355,6 +1349,18 @@ static u32 vc5_hdmi_channel_map(struct v
40 return channel_map;
41 }
42
43 +static bool vc5_hdmi_hp_detect(struct vc4_hdmi *vc4_hdmi)
44 +{
45 + unsigned long flags;
46 + u32 hotplug;
47 +
48 + spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
49 + hotplug = HDMI_READ(HDMI_HOTPLUG);
50 + spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
51 +
52 + return !!(hotplug & VC4_HDMI_HOTPLUG_CONNECTED);
53 +}
54 +
55 /* HDMI audio codec callbacks */
56 static void vc4_hdmi_audio_set_mai_clock(struct vc4_hdmi *vc4_hdmi,
57 unsigned int samplerate)
58 @@ -2779,6 +2785,7 @@ static const struct vc4_hdmi_variant bcm
59 .phy_rng_disable = vc5_hdmi_phy_rng_disable,
60 .channel_map = vc5_hdmi_channel_map,
61 .supports_hdr = true,
62 + .hp_detect = vc5_hdmi_hp_detect,
63 };
64
65 static const struct vc4_hdmi_variant bcm2711_hdmi1_variant = {
66 @@ -2807,6 +2814,7 @@ static const struct vc4_hdmi_variant bcm
67 .phy_rng_disable = vc5_hdmi_phy_rng_disable,
68 .channel_map = vc5_hdmi_channel_map,
69 .supports_hdr = true,
70 + .hp_detect = vc5_hdmi_hp_detect,
71 };
72
73 static const struct of_device_id vc4_hdmi_dt_match[] = {
74 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h
75 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h
76 @@ -102,6 +102,9 @@ struct vc4_hdmi_variant {
77
78 /* Enables HDR metadata */
79 bool supports_hdr;
80 +
81 + /* Callback for hardware specific hotplug detect */
82 + bool (*hp_detect)(struct vc4_hdmi *vc4_hdmi);
83 };
84
85 /* HDMI audio information */