Commit 2d799574 authored by Johann Fischer's avatar Johann Fischer Committed by Fabio Baltieri
Browse files

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: default avatarJohann Fischer <johann.fischer@nordicsemi.no>
parent 4cae4661
Loading
Loading
Loading
Loading
+6 −0
Changes for drivers/usb/udc/Kconfig: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -42,6 +42,12 @@ config UDC_BUF_FORCE_NOCACHE
	  Place the buffer pools in the nocache memory region if the driver
	  cannot handle buffers in cached memory.

config UDC_ENABLE_SOF
	bool "SOF interrupt processing"
	help
	  Enabled SoF interrupts can cause a very high CPU load on high-speed
	  controllers because the interrupt rate would be 125 µs.

config UDC_WORKQUEUE
	bool "Use a dedicate work queue for UDC drivers"
	help
+23 −0
Changes for drivers/usb/udc/udc_common.h: 23 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -156,6 +156,29 @@ int udc_submit_event(const struct device *dev,
int udc_submit_ep_event(const struct device *dev,
			struct net_buf *const buf,
			const int err);

/**
 * @brief Helper function to send UDC SOF event to a higher level.
 *
 * Type of this event is hardcoded to UDC_EVT_SOF.
 *
 * @param[in] dev    Pointer to device struct of the driver instance
 */
#if defined(CONFIG_UDC_ENABLE_SOF)
static inline void udc_submit_sof_event(const struct device *dev)
{
	struct udc_data *data = dev->data;
	struct udc_event drv_evt = {
		.type = UDC_EVT_SOF,
		.dev = dev,
	};

	(void)data->event_cb(dev, &drv_evt);
}
#else
#define udc_submit_sof_event(dev) ARG_UNUSED(dev)
#endif

/**
 * @brief Helper function to enable endpoint.
 *