From f7ced1f32062c6c787b8100915936e6ce29ad2fe Mon Sep 17 00:00:00 2001 From: Meng Dongyang Date: Tue, 20 Mar 2018 16:33:30 +0800 Subject: [PATCH] usb: dwc2: set op_state to peripheral when resume The operation mode of controller will change to peripheral when resume if PD is power off during suspend, current code disconnect hcd and set lx state to L3 in this case to make sure the controller will be reinit in device mode, but that's not enough, the op_state is still host which is change when init or ID change interrupt occur. If the ID change happened after suspend the driver would miss the interrupt, so when the application call the pullup function to stop gadget and start again to change to another function, the disconnect gadget operation can't be done and the gadget restart directly. This will result in NULL point when gadget work. This patch set op_state to OTG_STATE_B_PERIPHERAL when resume in this case. Change-Id: Ifbafb7fae43d634cfa879c9a066d1e114db4196e Signed-off-by: Meng Dongyang Signed-off-by: Frank Wang --- drivers/usb/dwc2/platform.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index b31430428da0..bb38f24aa3f2 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -743,6 +743,7 @@ static int __maybe_unused dwc2_resume(struct device *dev) if (dwc2->op_state == OTG_STATE_A_HOST && dwc2_is_device_mode(dwc2)) { spin_lock_irqsave(&dwc2->lock, flags); dwc2_hcd_disconnect(dwc2, true); + dwc2->op_state = OTG_STATE_B_PERIPHERAL; dwc2->lx_state = DWC2_L3; if (!dwc2->driver) dwc2_hsotg_core_init_disconnected(dwc2, false);