usb: ci_udc: Add function to remove usb device
When unregister gadget driver in ci_udc, the usb device is not
removed or stop. This causes next "usb start" fails to work.
Add a new interface "usb_remove_ehci_gadget" in usb-uclass to
remove the usb device for DM driver. Using "usb_lowlevel_stop" for
non-DM driver.
Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
index cdbdbcc..cdb8f6f 100644
--- a/drivers/usb/gadget/ci_udc.c
+++ b/drivers/usb/gadget/ci_udc.c
@@ -1053,6 +1053,13 @@
free(controller.items_mem);
free(controller.epts);
+#if CONFIG_IS_ENABLED(DM_USB)
+ usb_remove_ehci_gadget(&controller.ctrl);
+#else
+ usb_lowlevel_stop(0);
+ controller.ctrl = NULL;
+#endif
+
return 0;
}