return CMD_RET_FAILURE;
}
- ret = board_usb_init(controller_index, USB_INIT_DEVICE);
+ ret = usb_gadget_initialize(controller_index);
if (ret) {
pr_err("USB init failed: %d\n", ret);
return CMD_RET_FAILURE;
exit:
g_dnl_unregister();
g_dnl_clear_detach();
- board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+ usb_gadget_release(controller_index);
return ret;
#else
dev_index = simple_strtoul(devnum, NULL, 0);
rockusb_dev_init(devtype, dev_index);
- ret = board_usb_init(controller_index, USB_INIT_DEVICE);
+ ret = usb_gadget_initialize(controller_index);
if (ret) {
printf("USB init failed: %d\n", ret);
return CMD_RET_FAILURE;
exit:
g_dnl_unregister();
g_dnl_clear_detach();
- board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+ usb_gadget_release(controller_index);
return ret;
}
goto done;
int controller_index = simple_strtoul(usb_controller, NULL, 0);
- ret = board_usb_init(controller_index, USB_INIT_DEVICE);
+ ret = usb_gadget_initialize(controller_index);
if (ret) {
pr_err("USB init failed: %d\n", ret);
ret = CMD_RET_FAILURE;
exit:
g_dnl_unregister();
- board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+ usb_gadget_release(controller_index);
done:
dfu_free_entities();
char *usb_controller = argv[1];
int controller_index = simple_strtoul(usb_controller, NULL, 0);
- board_usb_init(controller_index, USB_INIT_DEVICE);
+ usb_gadget_initialize(controller_index);
g_dnl_clear_detach();
g_dnl_register("usb_dnl_sdp");
exit:
g_dnl_unregister();
- board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+ usb_gadget_release(controller_index);
return ret;
}
controller_index = (unsigned int)(simple_strtoul(
usb_controller, NULL, 0));
- if (board_usb_init(controller_index, USB_INIT_DEVICE)) {
+ if (usb_gadget_initialize(controller_index)) {
pr_err("Couldn't init USB controller.\n");
rc = CMD_RET_FAILURE;
goto cleanup_ums_init;
cleanup_register:
g_dnl_unregister();
cleanup_board:
- board_usb_cleanup(controller_index, USB_INIT_DEVICE);
+ usb_gadget_release(controller_index);
cleanup_ums_init:
ums_fini();
bool dfu_reset = false;
int ret, i = 0;
- ret = board_usb_init(usbctrl_index, USB_INIT_DEVICE);
+ ret = usb_gadget_initialize(usbctrl_index);
if (ret) {
- pr_err("board usb init failed\n");
+ pr_err("usb_gadget_initialize failed\n");
return CMD_RET_FAILURE;
}
g_dnl_clear_detach();
}
exit:
g_dnl_unregister();
- board_usb_cleanup(usbctrl_index, USB_INIT_DEVICE);
+ usb_gadget_release(usbctrl_index);
if (dfu_reset)
do_reset(NULL, 0, 0, NULL);
struct usb_gadget *gadget;
struct usb_request *req; /* for control responses */
struct usb_request *stat_req; /* for cdc & rndis status */
-#if CONFIG_IS_ENABLED(DM_USB)
- struct udevice *usb_udev;
-#endif
u8 config;
struct usb_ep *in_ep, *out_ep, *status_ep;
}
/*-------------------------------------------------------------------------*/
-
-#if CONFIG_IS_ENABLED(DM_USB)
-int dm_usb_init(struct eth_dev *e_dev)
-{
- struct udevice *dev = NULL;
- int ret;
-
- ret = uclass_first_device(UCLASS_USB_DEV_GENERIC, &dev);
- if (!dev || ret) {
- pr_err("No USB device found\n");
- return -ENODEV;
- }
-
- e_dev->usb_udev = dev;
-
- return ret;
-}
-#endif
-
static int _usb_eth_init(struct ether_priv *priv)
{
struct eth_dev *dev = &priv->ethdev;
struct usb_gadget *gadget;
unsigned long ts;
+ int ret;
unsigned long timeout = USB_CONNECT_TIMEOUT;
-#if CONFIG_IS_ENABLED(DM_USB)
- if (dm_usb_init(dev)) {
- pr_err("USB ether not found\n");
- return -ENODEV;
- }
-#else
- board_usb_init(0, USB_INIT_DEVICE);
-#endif
+ ret = usb_gadget_initialize(0);
+ if (ret)
+ return ret;
/* Configure default mac-addresses for the USB ethernet device */
#ifdef CONFIG_USBNET_DEV_ADDR
}
usb_gadget_unregister_driver(&priv->eth_driver);
-#if !CONFIG_IS_ENABLED(DM_USB)
- board_usb_cleanup(0, USB_INIT_DEVICE);
-#endif
+ usb_gadget_release(0);
}
#ifndef CONFIG_DM_ETH
#define __LINUX_USB_GADGET_H
#include <errno.h>
+#include <usb.h>
#include <linux/compat.h>
#include <linux/list.h>
extern int usb_gadget_handle_interrupts(int index);
+static inline int usb_gadget_initialize(int index)
+{
+ return board_usb_init(index, USB_INIT_DEVICE);
+}
+
+static inline int usb_gadget_release(int index)
+{
+ return board_usb_cleanup(index, USB_INIT_DEVICE);
+}
#endif /* __LINUX_USB_GADGET_H */