Commit c73d137e authored by Ye Li's avatar Ye Li

MLK-18290-4 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: 's avatarYe Li <ye.li@nxp.com>
parent d4f12cd9
......@@ -1044,6 +1044,13 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
free(controller.items_mem);
free(controller.epts);
#ifdef CONFIG_DM_USB
usb_remove_ehci_gadget(&controller.ctrl);
#else
usb_lowlevel_stop(0);
controller.ctrl = NULL;
#endif
return 0;
}
......
......@@ -372,6 +372,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);
if (ret)
return ret;
*ctlrp = NULL;
return 0;
}
/* returns 0 if no match, 1 if match */
int usb_match_device(const struct usb_device_descriptor *desc,
const struct usb_device_id *id)
......
......@@ -841,6 +841,15 @@ struct ehci_ctrl;
*/
int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp);
/**
* usb_remove_ehci_gadget() - Remove a gadget USB device
*
* TODO(sjg@chromium.org): Tidy this up when USB gadgets can use driver model
*
* This provides a way to tell a controller to remove a USB device
*/
int usb_remove_ehci_gadget(struct ehci_ctrl **ctlrp);
/**
* usb_stor_reset() - Prepare to scan USB storage devices
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment