diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/ci_udc.c | 7 | ||||
-rw-r--r-- | drivers/usb/host/usb-uclass.c | 18 |
2 files changed, 25 insertions, 0 deletions
diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c index cdbdbcc5ca..cdb8f6fb3d 100644 --- a/drivers/usb/gadget/ci_udc.c +++ b/drivers/usb/gadget/ci_udc.c @@ -1053,6 +1053,13 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) 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; } diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index e5dda79b94..8773824e05 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -411,6 +411,24 @@ int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp) return 0; } +int usb_remove_ehci_gadget(struct ehci_ctrl **ctlrp) +{ + struct udevice *dev; + int ret; + + /* Find the old device and remove it */ + ret = uclass_find_device_by_seq(UCLASS_USB, 0, true, &dev); + if (ret) + return ret; + ret = device_remove(dev, DM_REMOVE_NORMAL); + if (ret) + return ret; + + *ctlrp = NULL; + + return 0; +} + /* returns 0 if no match, 1 if match */ static int usb_match_device(const struct usb_device_descriptor *desc, const struct usb_device_id *id) |