From 81317ce8f23b26bf6400c6712ae516555cd45e5e Mon Sep 17 00:00:00 2001 From: Johann Fischer Date: Tue, 6 Feb 2024 11:49:18 +0100 Subject: [PATCH] drivers: udc_dwc2: enable SOF interrupts and SOF events Enable SOF interrupts and SOF events. Signed-off-by: Johann Fischer --- drivers/usb/common/usb_dwc2_hw.h | 2 ++ drivers/usb/udc/udc_dwc2.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/usb/common/usb_dwc2_hw.h b/drivers/usb/common/usb_dwc2_hw.h index edcab56b50f7..f216a423968d 100644 --- a/drivers/usb/common/usb_dwc2_hw.h +++ b/drivers/usb/common/usb_dwc2_hw.h @@ -202,6 +202,8 @@ USB_DWC2_SET_FIELD_DEFINE(grstctl_txfnum, GRSTCTL_TXFNUM) #define USB_DWC2_GINTSTS_USBSUSP BIT(USB_DWC2_GINTSTS_USBSUSP_POS) #define USB_DWC2_GINTSTS_RXFLVL_POS 4UL #define USB_DWC2_GINTSTS_RXFLVL BIT(USB_DWC2_GINTSTS_RXFLVL_POS) +#define USB_DWC2_GINTSTS_SOF_POS 3UL +#define USB_DWC2_GINTSTS_SOF BIT(USB_DWC2_GINTSTS_SOF_POS) #define USB_DWC2_GINTSTS_OTGINT_POS 2UL #define USB_DWC2_GINTSTS_OTGINT BIT(USB_DWC2_GINTSTS_OTGINT_POS) diff --git a/drivers/usb/udc/udc_dwc2.c b/drivers/usb/udc/udc_dwc2.c index c38e03157b62..0c1463e97980 100644 --- a/drivers/usb/udc/udc_dwc2.c +++ b/drivers/usb/udc/udc_dwc2.c @@ -854,6 +854,12 @@ static void udc_dwc2_isr_handler(const struct device *dev) LOG_DBG("GINTSTS 0x%x", int_status); + if (int_status & USB_DWC2_GINTSTS_SOF) { + /* Clear USB SOF interrupt. */ + sys_write32(USB_DWC2_GINTSTS_SOF, gintsts_reg); + udc_submit_event(dev, UDC_EVT_SOF, 0); + } + if (int_status & USB_DWC2_GINTSTS_USBRST) { /* Clear and handle USB Reset interrupt. */ sys_write32(USB_DWC2_GINTSTS_USBRST, gintsts_reg); @@ -1541,7 +1547,8 @@ static int udc_dwc2_init(const struct device *dev) /* Unmask interrupts */ sys_write32(USB_DWC2_GINTSTS_OEPINT | USB_DWC2_GINTSTS_IEPINT | USB_DWC2_GINTSTS_ENUMDONE | USB_DWC2_GINTSTS_USBRST | - USB_DWC2_GINTSTS_WKUPINT | USB_DWC2_GINTSTS_USBSUSP, + USB_DWC2_GINTSTS_WKUPINT | USB_DWC2_GINTSTS_USBSUSP | + USB_DWC2_GINTSTS_SOF, (mem_addr_t)&base->gintmsk);