Analogix DP controllers support two sets of interrupts for hotplug detection: HOTPLUG_CHG, and the pair PLUG / HPD_LOST. The current driver logic relies on PLUG/HPD_LOST and does not consume HOTPLUG_CHG, nor does it check for INT_HPD for IRQ_HPD events.
The existing analogix_dp_get_irq_type() returns on the first matched interrupt flag. This causes the hardirq handler to unconditionally mute all HPD interrupts, including HOTPLUG_CHG and INT_HPD, creating a limitation for future extensions. To prepare fine-grained interrupt handling, convert the return type from enum dp_irq_type to a u32 bitmask. Accumulate all pending interrupt flags instead of returning early, and add detection for DP_IRQ_TYPE_IRQ_HPD. Remove DP_IRQ_TYPE_UNKNOWN sentinel; use zero to indicate no pending interrupts, which simplifies code and facilitates future extension for additional interrupt types. Signed-off-by: Damon Ding <[email protected]> --- .../gpu/drm/bridge/analogix/analogix_dp_core.c | 8 ++++---- .../gpu/drm/bridge/analogix/analogix_dp_core.h | 4 ++-- .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 18 ++++++++++-------- 3 files changed, 16 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 6df6963740d2..079f2f01f33b 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -701,10 +701,10 @@ static irqreturn_t analogix_dp_hardirq(int irq, void *arg) { struct analogix_dp_device *dp = arg; irqreturn_t ret = IRQ_NONE; - enum dp_irq_type irq_type; + u32 irq_type; irq_type = analogix_dp_get_irq_type(dp); - if (irq_type != DP_IRQ_TYPE_UNKNOWN) { + if (irq_type) { analogix_dp_mute_hpd_interrupt(dp); ret = IRQ_WAKE_THREAD; } @@ -715,7 +715,7 @@ static irqreturn_t analogix_dp_hardirq(int irq, void *arg) static irqreturn_t analogix_dp_irq_thread(int irq, void *arg) { struct analogix_dp_device *dp = arg; - enum dp_irq_type irq_type; + u32 irq_type; irq_type = analogix_dp_get_irq_type(dp); if (irq_type & DP_IRQ_TYPE_HP_CABLE_IN || @@ -725,7 +725,7 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void *arg) drm_helper_hpd_irq_event(dp->drm_dev); } - if (irq_type != DP_IRQ_TYPE_UNKNOWN) { + if (irq_type) { analogix_dp_clear_hotplug_interrupts(dp); analogix_dp_unmute_hpd_interrupt(dp); } diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h index 4560597604ad..3f40d95757c5 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h @@ -120,7 +120,7 @@ enum dp_irq_type { DP_IRQ_TYPE_HP_CABLE_IN = BIT(0), DP_IRQ_TYPE_HP_CABLE_OUT = BIT(1), DP_IRQ_TYPE_HP_CHANGE = BIT(2), - DP_IRQ_TYPE_UNKNOWN = BIT(3), + DP_IRQ_TYPE_IRQ_HPD = BIT(3), }; struct video_info { @@ -195,7 +195,7 @@ void analogix_dp_set_analog_power_down(struct analogix_dp_device *dp, int analogix_dp_init_analog_func(struct analogix_dp_device *dp); void analogix_dp_init_hpd(struct analogix_dp_device *dp); void analogix_dp_force_hpd(struct analogix_dp_device *dp); -enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp); +u32 analogix_dp_get_irq_type(struct analogix_dp_device *dp); void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp); void analogix_dp_reset_aux(struct analogix_dp_device *dp); void analogix_dp_init_aux(struct analogix_dp_device *dp); diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c index c1344a3f013a..49c1961e4326 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c @@ -412,8 +412,9 @@ void analogix_dp_force_hpd(struct analogix_dp_device *dp) writel(reg, dp->reg_base + ANALOGIX_DP_SYS_CTL_3); } -enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp) +u32 analogix_dp_get_irq_type(struct analogix_dp_device *dp) { + u32 irq_type = 0; u32 reg; if (dp->hpd_gpiod) { @@ -425,17 +426,18 @@ enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp) } else { /* Parse hotplug interrupt status register */ reg = readl(dp->reg_base + ANALOGIX_DP_COMMON_INT_STA_4); - if (reg & PLUG) - return DP_IRQ_TYPE_HP_CABLE_IN; - + irq_type |= DP_IRQ_TYPE_HP_CABLE_IN; if (reg & HPD_LOST) - return DP_IRQ_TYPE_HP_CABLE_OUT; - + irq_type |= DP_IRQ_TYPE_HP_CABLE_OUT; if (reg & HOTPLUG_CHG) - return DP_IRQ_TYPE_HP_CHANGE; + irq_type |= DP_IRQ_TYPE_HP_CHANGE; + + reg = readl(dp->reg_base + ANALOGIX_DP_INT_STA); + if (reg & INT_HPD) + irq_type |= DP_IRQ_TYPE_IRQ_HPD; - return DP_IRQ_TYPE_UNKNOWN; + return irq_type; } } -- 2.34.1
