GPIO HPD does not rely on DP controller internal native HPD interrupts.
Skip native HPD register manipulations to avoid irrelevant operations.

In analogix_dp_config_interrupt(), mute all native HPD interrupts when
dp->hpd_gpiod is set. Move the dp->hpd_gpiod guard from inside
analogix_dp_clear_hotplug_interrupts() to its caller in the threaded
IRQ handler, so that the function operates purely on the given irq_type
bitmask without implicit mode-dependent behavior. This makes it
reusable for future callers that may need to clear specific interrupt
status bits regardless of the HPD detection mode.

Signed-off-by: Damon Ding <[email protected]>

---

Changes in v2:
- Adapt to the newly added IRQF_ONESHOT related commit and expand the
  commit msg.
---
 .../drm/bridge/analogix/analogix_dp_core.c    |  2 +-
 .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 30 +++++++++++--------
 2 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c 
b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index d207cc864bdc..f05db455b430 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -720,7 +720,7 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void 
*arg)
        bool hpd_detected;
 
        irq_type = analogix_dp_get_irq_type(dp);
-       if (irq_type)
+       if (!dp->hpd_gpiod && irq_type)
                analogix_dp_clear_hotplug_interrupts(dp, irq_type);
 
        if (!dp->hpd_gpiod && analogix_dp_is_rockchip(dp->plat_data->dev_type))
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c 
b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
index fa8e2f104d6c..4b210e685747 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
@@ -182,18 +182,22 @@ void analogix_dp_config_interrupt(struct 
analogix_dp_device *dp)
        writel(0, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_2);
        writel(0, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_3);
 
-       /*
-        * Either HOTPLUG_CHG interrupt or PLUG + HPD_LOST interrupt
-        * pair can be used to implement hotplug detection.
-        *
-        * On Rockchip platforms, configuring HPD deglitch to 2ms and
-        * using HOTPLUG_CHG interrupt for hotplug detection is proven
-        * as a better solution via engineering verification.
-        */
-       if (analogix_dp_is_rockchip(dp->plat_data->dev_type))
-               analogix_dp_unmute_hpd_interrupt(dp, DP_IRQ_TYPE_HP_CHANGE);
-       else
-               analogix_dp_unmute_hpd_interrupt(dp, HPD_IRQ);
+       if (dp->hpd_gpiod) {
+               analogix_dp_mute_hpd_interrupt(dp, HPD_IRQ);
+       } else {
+               /*
+                * Either HOTPLUG_CHG interrupt or PLUG + HPD_LOST interrupt
+                * pair can be used to implement hotplug detection.
+                *
+                * On Rockchip platforms, configuring HPD deglitch to 2ms and
+                * using HOTPLUG_CHG interrupt for hotplug detection is proven
+                * as a better solution via engineering verification.
+                */
+               if (analogix_dp_is_rockchip(dp->plat_data->dev_type))
+                       analogix_dp_unmute_hpd_interrupt(dp, 
DP_IRQ_TYPE_HP_CHANGE);
+               else
+                       analogix_dp_unmute_hpd_interrupt(dp, HPD_IRQ);
+       }
 }
 
 void analogix_dp_mute_hpd_interrupt(struct analogix_dp_device *dp, u32 
irq_type)
@@ -413,7 +417,7 @@ void analogix_dp_clear_hotplug_interrupts(struct 
analogix_dp_device *dp, u32 irq
 {
        u32 reg = 0;
 
-       if (dp->hpd_gpiod || !irq_type)
+       if (!irq_type)
                return;
 
        if (irq_type & COMMON_INT_4_HPD_IRQ) {
-- 
2.34.1

Reply via email to