summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2024-04-03 15:44:43 +0800
committersakumisu <[email protected]>2024-04-03 15:44:43 +0800
commit6ef086a085c122e4c7be671e32d5bab9bc474458 (patch)
tree28add039d98566cf4965695f0ae0f93a3af9ee9e
parent5494b0e99adb7c50d0212d51dd66b47848834f3f (diff)
add check for dwc2 fifo with ep mps
-rw-r--r--port/dwc2/usb_dc_dwc2.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/port/dwc2/usb_dc_dwc2.c b/port/dwc2/usb_dc_dwc2.c
index 4de89de1..e789924a 100644
--- a/port/dwc2/usb_dc_dwc2.c
+++ b/port/dwc2/usb_dc_dwc2.c
@@ -82,15 +82,15 @@
#endif
#ifndef CONFIG_USB_DWC2_TX6_FIFO_SIZE
-#define CONFIG_USB_DWC2_TX6_FIFO_SIZE (64 / 4)
+#define CONFIG_USB_DWC2_TX6_FIFO_SIZE (0 / 4)
#endif
#ifndef CONFIG_USB_DWC2_TX7_FIFO_SIZE
-#define CONFIG_USB_DWC2_TX7_FIFO_SIZE (64 / 4)
+#define CONFIG_USB_DWC2_TX7_FIFO_SIZE (0 / 4)
#endif
#ifndef CONFIG_USB_DWC2_TX8_FIFO_SIZE
-#define CONFIG_USB_DWC2_TX8_FIFO_SIZE (64 / 4)
+#define CONFIG_USB_DWC2_TX8_FIFO_SIZE (0 / 4)
#endif
#define USBD_BASE (g_usbdev_bus[0].reg_base)
@@ -710,6 +710,17 @@ int usbd_ep_open(uint8_t busid, const struct usb_endpoint_descriptor *ep)
USB_OTG_DOEPCTL_USBAEP;
}
} else {
+ uint16_t fifo_size;
+ if (ep_idx == 0) {
+ fifo_size = (USB_OTG_GLB->DIEPTXF0_HNPTXFSIZ >> 16);
+ } else {
+ fifo_size = (USB_OTG_GLB->DIEPTXF[ep_idx - 1U] >> 16);
+ }
+ if ((fifo_size * 4) < USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize)) {
+ USB_LOG_ERR("Ep addr %02x fifo overflow\r\n", ep->bEndpointAddress);
+ return -2;
+ }
+
g_dwc2_udc.in_ep[ep_idx].ep_mps = USB_GET_MAXPACKETSIZE(ep->wMaxPacketSize);
g_dwc2_udc.in_ep[ep_idx].ep_type = USB_GET_ENDPOINT_TYPE(ep->bmAttributes);