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
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.
11 Ensure we don't do the 2711 register read on invalid hardware,
14 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
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(-)
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))
26 - unsigned long flags;
29 - spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
30 - hotplug = HDMI_READ(HDMI_HOTPLUG);
31 - spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
33 - if (hotplug & VC4_HDMI_HOTPLUG_CONNECTED)
34 + if (vc4_hdmi->variant->hp_detect &&
35 + vc4_hdmi->variant->hp_detect(vc4_hdmi))
39 @@ -1355,6 +1349,18 @@ static u32 vc5_hdmi_channel_map(struct v
43 +static bool vc5_hdmi_hp_detect(struct vc4_hdmi *vc4_hdmi)
45 + unsigned long flags;
48 + spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
49 + hotplug = HDMI_READ(HDMI_HOTPLUG);
50 + spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
52 + return !!(hotplug & VC4_HDMI_HOTPLUG_CONNECTED);
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,
62 + .hp_detect = vc5_hdmi_hp_detect,
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,
70 + .hp_detect = vc5_hdmi_hp_detect,
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 {
78 /* Enables HDR metadata */
81 + /* Callback for hardware specific hotplug detect */
82 + bool (*hp_detect)(struct vc4_hdmi *vc4_hdmi);
85 /* HDMI audio information */