Skip to content

Commit 4f519fe

Browse files
wuliangfengrkhuangtao
authored andcommitted
phy: rockchip-inno-usb2: delay suspending phy if plug out device
The otg_sm_work will suspend the usb2 phy immediately if it detects disconnection from host. However, the usb2 controller(e.g. DWC2) may need to reinit registers and reset usb core after usb disconnect, and it needs to keep the usb2 phy stay in power on state to get utmi clk for these usb controller operation. We don't have a good synchronization mechanism to operate usb2 phy between usb2 phy driver and usb2 controller driver, so we delay 4s to suspend phy if detect otg device disconnect from host, this can make sure that usb2 controller completes reinitialization before suspend usb2 phy. Change-Id: I79288b8c7b141bb16e6d96d80cfee75f7558d2c0 Signed-off-by: William Wu <william.wu@rock-chips.com>
1 parent 0d01d22 commit 4f519fe

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/phy/phy-rockchip-inno-usb2.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -886,19 +886,17 @@ static void rockchip_usb2phy_otg_sm_work(struct work_struct *work)
886886
} else {
887887
rphy->chg_state = USB_CHG_STATE_UNDEFINED;
888888
rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN;
889+
mutex_unlock(&rport->mutex);
890+
rockchip_usb2phy_power_off(rport->phy);
891+
mutex_lock(&rport->mutex);
889892
}
890893
break;
891894
case OTG_STATE_B_PERIPHERAL:
892895
if (!rport->vbus_attached) {
893896
dev_dbg(&rport->phy->dev, "usb disconnect\n");
894-
rphy->chg_state = USB_CHG_STATE_UNDEFINED;
895-
rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN;
896897
rport->state = OTG_STATE_B_IDLE;
897898
rport->perip_connected = false;
898-
delay = 0;
899-
mutex_unlock(&rport->mutex);
900-
rockchip_usb2phy_power_off(rport->phy);
901-
mutex_lock(&rport->mutex);
899+
delay = OTG_SCHEDULE_DELAY * 2;
902900
wake_unlock(&rport->wakelock);
903901
}
904902
sch_work = true;
@@ -1246,6 +1244,7 @@ static irqreturn_t rockchip_usb2phy_bvalid_irq(int irq, void *data)
12461244

12471245
mutex_unlock(&rport->mutex);
12481246

1247+
cancel_delayed_work_sync(&rport->otg_sm_work);
12491248
rockchip_usb2phy_otg_sm_work(&rport->otg_sm_work.work);
12501249

12511250
return IRQ_HANDLED;
@@ -1324,6 +1323,7 @@ static int rockchip_otg_event(struct notifier_block *nb,
13241323
struct rockchip_usb2phy_port *rport =
13251324
container_of(nb, struct rockchip_usb2phy_port, event_nb);
13261325

1326+
cancel_delayed_work_sync(&rport->otg_sm_work);
13271327
schedule_delayed_work(&rport->otg_sm_work, OTG_SCHEDULE_DELAY);
13281328

13291329
return NOTIFY_DONE;

0 commit comments

Comments
 (0)