Skip to content

Commit 2d79957

Browse files
jfischer-nofabiobaltieri
authored andcommitted
drivers: udc: add SOF Kconfig option and SOF event helper
Add helper to handle SOF interrupts/events and new Kconfig option to disable SOF interrupt. Signed-off-by: Johann Fischer <[email protected]>
1 parent 4cae466 commit 2d79957

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

drivers/usb/udc/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ config UDC_BUF_FORCE_NOCACHE
4242
Place the buffer pools in the nocache memory region if the driver
4343
cannot handle buffers in cached memory.
4444

45+
config UDC_ENABLE_SOF
46+
bool "SOF interrupt processing"
47+
help
48+
Enabled SoF interrupts can cause a very high CPU load on high-speed
49+
controllers because the interrupt rate would be 125 µs.
50+
4551
config UDC_WORKQUEUE
4652
bool "Use a dedicate work queue for UDC drivers"
4753
help

drivers/usb/udc/udc_common.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,29 @@ int udc_submit_event(const struct device *dev,
156156
int udc_submit_ep_event(const struct device *dev,
157157
struct net_buf *const buf,
158158
const int err);
159+
160+
/**
161+
* @brief Helper function to send UDC SOF event to a higher level.
162+
*
163+
* Type of this event is hardcoded to UDC_EVT_SOF.
164+
*
165+
* @param[in] dev Pointer to device struct of the driver instance
166+
*/
167+
#if defined(CONFIG_UDC_ENABLE_SOF)
168+
static inline void udc_submit_sof_event(const struct device *dev)
169+
{
170+
struct udc_data *data = dev->data;
171+
struct udc_event drv_evt = {
172+
.type = UDC_EVT_SOF,
173+
.dev = dev,
174+
};
175+
176+
(void)data->event_cb(dev, &drv_evt);
177+
}
178+
#else
179+
#define udc_submit_sof_event(dev) ARG_UNUSED(dev)
180+
#endif
181+
159182
/**
160183
* @brief Helper function to enable endpoint.
161184
*

0 commit comments

Comments
 (0)