phy: rockchip: inno-usb2: Clear charger state in host mode

Test on RK3576 Tablet Android 14 GKI, when plug in U disk,
it will trigger the usb2 phy to do charging detection logic
in the following process.

1. Type-C PD controller chip (e.g HUSB311) detect DFP mode;

2. Type-C tcpm call usb_role_switch_set_role() to notify
   the usb controller to set USB_ROLE_HOST;

3. The usb dwc3 controller driver do dwc3_set_mode() to
   initialize the controller and phy for host mode;

4. In the __dwc3_set_mode(), it do pm_runtime_get_sync()
   -> dwc3_runtime_resume() -> dwc3_resume_common() ->
   dwc3_core_init() -> phy_init(dwc->usb2_generic_phy);

5. In the usb2 phy driver, it do rockchip_usb2phy_init()
   -> schedule otg_sm_work -> rockchip_chg_detect_work()

6. Detect dcp cable is connected, and call extcon_set_state_sync()
   to send charger notification with true state.

Later, if plug out the U disk and plug in a USB charger,
it will fail to send charger notification because its
extcon state still in true state.

To fix this issue, we need to clear the charger state
in the otg_sm_work if it's already in host mode.

Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: I6a30429162290927cae3e5f3495f51db61bf15b6
This commit is contained in:
William Wu
2024-05-29 15:41:17 +08:00
committed by Tao Huang
parent 4b8f3fe475
commit 915826d691

View File

@@ -1253,6 +1253,10 @@ static void rockchip_usb2phy_otg_sm_work(struct work_struct *work)
rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN;
mutex_unlock(&rport->mutex);
rockchip_usb2phy_power_on(rport->phy);
if (extcon_get_state(rphy->edev, cable)) {
extcon_set_state_sync(rphy->edev, cable, false);
cable = EXTCON_NONE;
}
return;
} else if (rport->vbus_attached) {
dev_dbg(&rport->phy->dev, "vbus_attach\n");