From a1663d7e8a7a8b2f392f860ce7ad4263d09e2139 Mon Sep 17 00:00:00 2001 From: Zhang Yubing Date: Sat, 27 Nov 2021 16:28:57 +0800 Subject: [PATCH] phy: rockchip: usbdp: Fix aux channel polarity setting It's too late to set the aux channel polarity. Some sink device will not send attention cmd to indicate hpd plug event. Setting the aux channel polarity earlier. When detecting the connected status is disconnected, Setting the gpio status to low. Fixes: 8081c70a82a6: ("phy: rockchip: usbdp-phy: add pointer check, avoid NULL pointer") Signed-off-by: Zhang Yubing Change-Id: Ie653a043f9d3cecf489846d7edbd6eca73f5ee28 --- drivers/phy/rockchip/phy-rockchip-usbdp.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c index 4fe8df31e9b6..dc965129c492 100644 --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c @@ -437,6 +437,8 @@ static int upphy_set_typec_default_mapping(struct rockchip_udphy *udphy) udphy->lane_mux_sel[3] = PHY_LANE_MUX_USB; udphy->dp_aux_dout_sel = PHY_AUX_DP_DATA_POL_INVERT; udphy->dp_aux_din_sel = PHY_AUX_DP_DATA_POL_INVERT; + gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 1); + gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 0); } else { udphy->dp_lane_sel[0] = 2; udphy->dp_lane_sel[1] = 3; @@ -448,6 +450,8 @@ static int upphy_set_typec_default_mapping(struct rockchip_udphy *udphy) udphy->lane_mux_sel[3] = PHY_LANE_MUX_DP; udphy->dp_aux_dout_sel = PHY_AUX_DP_DATA_POL_NORMAL; udphy->dp_aux_din_sel = PHY_AUX_DP_DATA_POL_NORMAL; + gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 0); + gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 1); } udphy->mode = UDPHY_MODE_DP_USB; @@ -463,6 +467,8 @@ static int udphy_orien_sw_set(struct typec_switch *sw, mutex_lock(&udphy->mutex); if (orien == TYPEC_ORIENTATION_NONE) { + gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 0); + gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 0); /* unattached */ udphy_usb_bvalid_enable(udphy, false); goto unlock_ret; @@ -908,16 +914,6 @@ static int usbdp_typec_mux_set(struct typec_mux *mux, struct typec_displayport_data *data = state->data; bool hpd = !!(data && (data->status & DP_STATUS_HPD_STATE)); - if (hpd && udphy->sbu1_dc_gpio && udphy->sbu1_dc_gpio) { - if (udphy->flip) { - gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 1); - gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 0); - } else { - gpiod_set_value_cansleep(udphy->sbu1_dc_gpio, 0); - gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 1); - } - } - if (hpd && udphy->mode != mode) { udphy->mode = mode; udphy->mode_change = true; @@ -925,7 +921,6 @@ static int usbdp_typec_mux_set(struct typec_mux *mux, if (cfg->hpd_event_trigger) cfg->hpd_event_trigger(udphy, hpd); - } return 0;