From 09bbffb2989d2edb3e4083ebd60c714c87adb008 Mon Sep 17 00:00:00 2001 From: Zhang Yubing Date: Wed, 28 Feb 2024 11:04:36 +0800 Subject: [PATCH] drm/rockchip: dw-dp: get the real hpd state In DPTX Controller, when hpd signal is low, the hpd state will change to unplug immediately. if the low level signal is less than 2ms, the hpd state will change to plug state and trigger a hpd irq interrupt. In some case, driver will detect hpd state to get the plug/unplug info when a hpd irq is coming. A hpd irq may be regard as a unplug state. To avoid this issue, it better to wait the hpd state change to the nest state. Change-Id: I68c5bdc72128a2bc3ea990cfcb54e2ade755abc7 Signed-off-by: Zhang Yubing --- drivers/gpu/drm/rockchip/dw-dp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/rockchip/dw-dp.c b/drivers/gpu/drm/rockchip/dw-dp.c index 313792213bb5..7dcffa6e0305 100644 --- a/drivers/gpu/drm/rockchip/dw-dp.c +++ b/drivers/gpu/drm/rockchip/dw-dp.c @@ -1112,11 +1112,18 @@ static bool dw_dp_bandwidth_ok(struct dw_dp *dp, static bool dw_dp_detect(struct dw_dp *dp) { u32 value; + int ret; if (dp->hpd_gpio) return gpiod_get_value_cansleep(dp->hpd_gpio); - regmap_read(dp->regmap, DPTX_HPD_STATUS, &value); + ret = regmap_read_poll_timeout(dp->regmap, DPTX_HPD_STATUS, value, + FIELD_GET(HPD_STATE, value) != SOURCE_STATE_UNPLUG, + 100, 3000); + if (ret) { + dev_err(dp->dev, "get hpd status timeout\n"); + return false; + } return FIELD_GET(HPD_STATE, value) == SOURCE_STATE_PLUG; }