From a05993824cb5ae48e2f0159575860c9b00c5c4e7 Mon Sep 17 00:00:00 2001 From: Mayank Rana Date: Wed, 27 May 2020 16:18:04 -0700 Subject: [PATCH] dwc3-msm: Move override usb speed functionality outside edev check Currently usb speed override functionality doesn't work as expected when usb role switch based notification is used. Hence move usb speed override functionality out side edev check within dwc3_resume_work() API. Also update maximum_speed as max hw supported speed out side edev check. Change-Id: I69b066721490277b77333d2caf820b6c87703501 Signed-off-by: Mayank Rana --- drivers/usb/dwc3/dwc3-msm.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c index 03cc12943df9..8d47a6526289 100644 --- a/drivers/usb/dwc3/dwc3-msm.c +++ b/drivers/usb/dwc3/dwc3-msm.c @@ -3238,26 +3238,15 @@ static void dwc3_resume_work(struct work_struct *w) goto skip_update; } + dwc->maximum_speed = dwc->max_hw_supp_speed; /* Check speed and Type-C polarity values in order to configure PHY */ if (edev && extcon_get_state(edev, extcon_id)) { - dwc->maximum_speed = dwc->max_hw_supp_speed; - ret = extcon_get_property(edev, extcon_id, EXTCON_PROP_USB_SS, &val); if (!ret && val.intval == 0) dwc->maximum_speed = USB_SPEED_HIGH; - if (mdwc->override_usb_speed && - mdwc->override_usb_speed <= dwc->maximum_speed) { - dwc->maximum_speed = mdwc->override_usb_speed; - dwc->gadget.max_speed = dwc->maximum_speed; - dbg_event(0xFF, "override_speed", - mdwc->override_usb_speed); - } - - dbg_event(0xFF, "speed", dwc->maximum_speed); - ret = extcon_get_property(edev, extcon_id, EXTCON_PROP_USB_TYPEC_POLARITY, &val); if (ret) @@ -3270,6 +3259,17 @@ static void dwc3_resume_work(struct work_struct *w) } skip_update: + dbg_log_string("max_speed:%d hw_supp_speed:%d override_speed:%d", + dwc->maximum_speed, dwc->max_hw_supp_speed, + mdwc->override_usb_speed); + if (mdwc->override_usb_speed && + mdwc->override_usb_speed <= dwc->maximum_speed) { + dwc->maximum_speed = mdwc->override_usb_speed; + dwc->gadget.max_speed = dwc->maximum_speed; + } + + dbg_event(0xFF, "speed", dwc->maximum_speed); + /* * Skip scheduling sm work if no work is pending. When boot-up * with USB cable connected, usb state m/c is skipped to avoid