usb: dwc3: core: stop the core when it's removed
authorAngus Ainslie <angus@akkea.ca>
Wed, 2 Feb 2022 23:08:55 +0000 (15:08 -0800)
committerMarek Vasut <marex@denx.de>
Wed, 16 Feb 2022 15:52:56 +0000 (16:52 +0100)
If u-boot doesn't stop the core when it's finished with it then
linux can't find it.

Signed-off-by: Angus Ainslie <angus@akkea.ca>
drivers/usb/dwc3/core.c

index ce1c0e8..b592a48 100644 (file)
@@ -706,6 +706,14 @@ static void dwc3_gadget_run(struct dwc3 *dwc)
        mdelay(100);
 }
 
+static void dwc3_core_stop(struct dwc3 *dwc)
+{
+       u32 reg;
+
+       reg = dwc3_readl(dwc->regs, DWC3_DCTL);
+       dwc3_writel(dwc->regs, DWC3_DCTL, reg & ~(DWC3_DCTL_RUN_STOP));
+}
+
 static void dwc3_core_exit_mode(struct dwc3 *dwc)
 {
        switch (dwc->dr_mode) {
@@ -1128,6 +1136,7 @@ void dwc3_remove(struct dwc3 *dwc)
        dwc3_core_exit_mode(dwc);
        dwc3_event_buffers_cleanup(dwc);
        dwc3_free_event_buffers(dwc);
+       dwc3_core_stop(dwc);
        dwc3_core_exit(dwc);
        kfree(dwc->mem);
 }