phy: rockchip: inno-usb2: fix charger detection error

We found a charger detection error on RK3566 Tablet.

1. Plug in a Type-C to Type-A cable and connect to PC USB Host
   or USB charger, then the charger detection is normal.

2. Plug out the cable, then the charger disconnection detection
   is normal.

3. Plug in a Type-C to Type-A receptacle and plug out again. Then
   the charger is detected unexpectedly.

To fix this issue, reinitialize the cable state of USB charger to
EXTCON_NONE when USB charger is disconnected.

Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: Ic56e4ee865af129c222f4c90c3d6e753f4e785bd
This commit is contained in:
William Wu
2021-02-24 17:27:02 +08:00
committed by Tao Huang
parent 966f18657f
commit c03b975591

View File

@@ -1125,11 +1125,14 @@ static void rockchip_usb2phy_otg_sm_work(struct work_struct *work)
return;
}
if (extcon_get_state(rphy->edev, cable) != rport->vbus_attached)
if (extcon_get_state(rphy->edev, cable) != rport->vbus_attached) {
extcon_set_state_sync(rphy->edev,
cable, rport->vbus_attached);
else if (rport->state == OTG_STATE_A_HOST &&
extcon_get_state(rphy->edev, cable))
if (!rport->vbus_attached)
cable = EXTCON_NONE;
} else if (rport->state == OTG_STATE_A_HOST &&
extcon_get_state(rphy->edev, cable)) {
/*
* If plug in OTG host cable when the rport state is
* OTG_STATE_B_PERIPHERAL, the vbus voltage will stay
@@ -1137,6 +1140,8 @@ static void rockchip_usb2phy_otg_sm_work(struct work_struct *work)
* changed. We need to set cable state here.
*/
extcon_set_state_sync(rphy->edev, cable, false);
cable = EXTCON_NONE;
}
if (rphy->edev_self &&
(extcon_get_state(rphy->edev, EXTCON_USB) !=