From 9d591106dc22bae57a614a7b42ab9d52c6b921f8 Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Fri, 10 Sep 2021 16:16:21 +0200 Subject: usb: gadget: Add bcdDevice for the DWC2 USB Gadget Controller Add an entry in usb_gadget_controller_number() for the DWC2 gadget controller. It is used to bind the USB Ethernet driver. Signed-off-by: Patrice Chotard Reported-by: Herbert Poetzl Cc: Marek Vasut Cc: Herbert Poetzl --- drivers/usb/gadget/gadget_chips.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h index 0cdf47c2dd..06e6a48949 100644 --- a/drivers/usb/gadget/gadget_chips.h +++ b/drivers/usb/gadget/gadget_chips.h @@ -167,6 +167,12 @@ #define gadget_is_mtu3(g) 0 #endif +#ifdef CONFIG_USB_GADGET_DWC2_OTG +#define gadget_is_dwc2(g) (!strcmp("dwc2-udc", (g)->name)) +#else +#define gadget_is_dwc2(g) 0 +#endif + /** * usb_gadget_controller_number - support bcdDevice id convention * @gadget: the controller being driven @@ -232,5 +238,7 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget) return 0x25; else if (gadget_is_mtu3(gadget)) return 0x26; + else if (gadget_is_dwc2(gadget)) + return 0x27; return -ENOENT; } -- cgit v1.2.3 From 4c3dc6f69afa47923451fb6baf6c2a60947e45f8 Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Fri, 10 Sep 2021 16:16:22 +0200 Subject: usb: sandbox: Add gadget callbacks Add usb_gadget_handle_interrupts(), usb_gadget_register_driver() and usb_gadget_unregister_driver() to be able to test binding usb gadget. Signed-off-by: Patrice Chotard Cc: Marek Vasut Cc: Herbert Poetzl Reviewed-by: Simon Glass --- drivers/usb/host/usb-sandbox.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'drivers/usb') diff --git a/drivers/usb/host/usb-sandbox.c b/drivers/usb/host/usb-sandbox.c index d7cc92aa54..d1103dcb2e 100644 --- a/drivers/usb/host/usb-sandbox.c +++ b/drivers/usb/host/usb-sandbox.c @@ -9,6 +9,13 @@ #include #include #include +#include + +struct sandbox_udc { + struct usb_gadget gadget; +}; + +struct sandbox_udc *this_controller; struct sandbox_usb_ctrl { int rootdev; @@ -117,6 +124,27 @@ static int sandbox_submit_int(struct udevice *bus, struct usb_device *udev, return ret; } +int usb_gadget_handle_interrupts(int index) +{ + return 0; +} + +int usb_gadget_register_driver(struct usb_gadget_driver *driver) +{ + struct sandbox_udc *dev = this_controller; + + return driver->bind(&dev->gadget); +} + +int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) +{ + struct sandbox_udc *dev = this_controller; + + driver->unbind(&dev->gadget); + + return 0; +} + static int sandbox_alloc_device(struct udevice *dev, struct usb_device *udev) { struct sandbox_usb_ctrl *ctrl = dev_get_priv(dev); -- cgit v1.2.3