From 0bb9818fe493bbb61dc7cd455af25ac1b6fc310d Mon Sep 17 00:00:00 2001 From: Zhang Yubing Date: Fri, 10 Dec 2021 19:47:42 +0800 Subject: [PATCH] phy: rockchip: usbdp: add PD-to-HPD IRQ support When DP output in Tyep-C interface, HPD and HPD IRQ info are send by PD message, and transfer to phy by mux set callback function. The usbdp phy need tell the DP controller not only the HPD info, but also HPD IRQ info. According to DP Standard 1.4a 3.3 section, the HPD IRQ pulse width should be in the range from 0.5 ms to 1 ms, setting the low level time between 750 us nad 800 us to satisfied the specification. Signed-off-by: Zhang Yubing Change-Id: Ie6d6d0537e6633e6e5f12119ceafc4109e32e74e --- drivers/phy/rockchip/phy-rockchip-usbdp.c | 26 +++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c index b21b4c6a573e..d5381c30680a 100644 --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c @@ -1089,15 +1089,27 @@ static int usbdp_typec_mux_set(struct typec_mux *mux, if (state->alt && state->alt->svid == USB_TYPEC_DP_SID) { struct typec_displayport_data *data = state->data; - bool hpd = !!(data && (data->status & DP_STATUS_HPD_STATE)); - if (hpd && udphy->mode != mode) { - udphy->mode = mode; - udphy->mode_change = true; + if (!data) { + if (cfg->hpd_event_trigger) + cfg->hpd_event_trigger(udphy, false); + } else if (data->status & DP_STATUS_IRQ_HPD) { + if (cfg->hpd_event_trigger) { + cfg->hpd_event_trigger(udphy, false); + usleep_range(750, 800); + cfg->hpd_event_trigger(udphy, true); + } + } else if (data->status & DP_STATUS_HPD_STATE) { + if (udphy->mode != mode) { + udphy->mode = mode; + udphy->mode_change = true; + } + if (cfg->hpd_event_trigger) + cfg->hpd_event_trigger(udphy, true); + } else { + if (cfg->hpd_event_trigger) + cfg->hpd_event_trigger(udphy, false); } - - if (cfg->hpd_event_trigger) - cfg->hpd_event_trigger(udphy, hpd); } mutex_unlock(&udphy->mutex);