From 86933ad6ac1b7c6c23b5c88a803711362ec73bdb Mon Sep 17 00:00:00 2001 From: Mayank Rana Date: Wed, 9 Mar 2022 12:07:12 -0800 Subject: [PATCH] soc: qcom: eud: Do USB spoof disconnect and connect with enable/disable EUD There is known hardware issue where USB fails to enumerate into high speed mode behind EUD HUB. Recommendation is to toggle USB VBUS session override to enumerate USB device for this case when moving between EUD bypass to/from EUD debug mode. Hence perform USB spoof disconnect and connect when enabling /disabling EUD to get USB functional. There are several scenarios to consider of when the events from EUD should be handled: - EUD enabled in bootloader - SW WA not required as connection has not yet been established with the host when enabling EUD. - EUD enabled by module param - Events pertaining to the SW WA should be handled if the link is not in SSUSB. - EUD spoof detach/attach command - Events generated by EUD should be handled irrespective of the link speed. Introduce usage of the EXTCON_JIG connector to differentiate between receiving a spoof connect/disconnect command and enablement through the module param. - EXTCON_JIG = true --> EXTCON_USB events handled in SS/HS speeds - EXTCON_JIG = false --> EXTCON_USB events handled on in HS speeds This allows for the SS link to stay active in the case where the SW WA is required for enabling EUD using the module parameter. Change-Id: I9235c38cdcbbe987e1943cfb19109f7de7766cf5 Signed-off-by: Mayank Rana --- drivers/usb/dwc3/dwc3-msm-core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-msm-core.c b/drivers/usb/dwc3/dwc3-msm-core.c index 8d70fec99959..d4d225019b95 100644 --- a/drivers/usb/dwc3/dwc3-msm-core.c +++ b/drivers/usb/dwc3/dwc3-msm-core.c @@ -4719,9 +4719,25 @@ static int dwc3_msm_vbus_notifier(struct notifier_block *nb, /* detect USB spoof disconnect/connect notification with EUD device */ eud_str = strnstr(edev_name, "eud", strlen(edev_name)); if (eud_str) { + int spoof; + + spoof = extcon_get_state(edev, EXTCON_JIG); + if (mdwc->eud_active == event) return NOTIFY_DONE; + mdwc->eud_active = event; + + /* + * In case EUD is enabled by the module param, if DWC3 is + * operating in SS, ignore any connect/disconnect changes. This + * allows for the link to be uninterrupted, as EUD affects the + * HS path. Only listen for if there are spoof + * connect/disconnect commands. + */ + if (dwc && dwc->gadget->speed >= USB_SPEED_SUPER && !spoof) + return NOTIFY_DONE; + mdwc->check_eud_state = true; } else { if (mdwc->vbus_active == event)