Commit 7b287ec1 authored by Johann Fischer's avatar Johann Fischer Committed by Fabio Baltieri
Browse files

drivers: udc: disable SOF interrupt by default

If the new Kconfig option is disabled, no SOF events are passed to the
higher layer.

Signed-off-by: default avatarJohann Fischer <johann.fischer@nordicsemi.no>
parent 2d799574
Loading
Loading
Loading
Loading
+3 −2
Changes for drivers/usb/udc/udc_ambiq.c: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -156,7 +156,8 @@ static void udc_ambiq_evt_callback(const struct device *dev, am_hal_usb_dev_even
	case AM_HAL_USB_DEV_EVT_BUS_RESET:
		/* enable usb bus interrupts */
		am_hal_usb_intr_usb_enable(priv->usb_handle,
					   USB_CFG2_SOFE_Msk | USB_CFG2_ResumeE_Msk |
					   IF_ENABLED(CONFIG_UDC_ENABLE_SOF, (USB_CFG2_SOFE_Msk |))
					   USB_CFG2_ResumeE_Msk |
					   USB_CFG2_SuspendE_Msk | USB_CFG2_ResetE_Msk);
		/* init the endpoint */
		am_hal_usb_ep_init(priv->usb_handle, 0, 0, EP0_MPS);
@@ -174,7 +175,7 @@ static void udc_ambiq_evt_callback(const struct device *dev, am_hal_usb_dev_even
		udc_submit_event(dev, UDC_EVT_RESUME, 0);
		break;
	case AM_HAL_USB_DEV_EVT_SOF:
		udc_submit_event(dev, UDC_EVT_SOF, 0);
		udc_submit_sof_event(dev);
		break;
	case AM_HAL_USB_DEV_EVT_SUSPEND:
		/* Handle USB Suspend event, then set device state to suspended */
+12 −8
Changes for drivers/usb/udc/udc_dwc2.c: 12 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -2162,11 +2162,12 @@ static int udc_dwc2_init_controller(const struct device *dev)
	}

	/* Unmask interrupts */
	sys_write32(USB_DWC2_GINTSTS_OEPINT | USB_DWC2_GINTSTS_IEPINT |
	sys_write32(IF_ENABLED(CONFIG_UDC_ENABLE_SOF, (USB_DWC2_GINTSTS_SOF |
						       USB_DWC2_GINTSTS_INCOMPISOOUT |
						       USB_DWC2_GINTSTS_INCOMPISOIN |))
		    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_INCOMPISOOUT | USB_DWC2_GINTSTS_INCOMPISOIN |
		    USB_DWC2_GINTSTS_SOF,
		    USB_DWC2_GINTSTS_WKUPINT | USB_DWC2_GINTSTS_USBSUSP,
		    (mem_addr_t)&base->gintmsk);

	return 0;
@@ -2890,7 +2891,8 @@ static void udc_dwc2_isr_handler(const struct device *dev)

		LOG_DBG("GINTSTS 0x%x", int_status);

		if (int_status & USB_DWC2_GINTSTS_SOF) {
		if (IS_ENABLED(CONFIG_UDC_ENABLE_SOF) &&
		    int_status & USB_DWC2_GINTSTS_SOF) {
			uint32_t dsts;

			/* Clear USB SOF interrupt. */
@@ -2898,7 +2900,7 @@ static void udc_dwc2_isr_handler(const struct device *dev)

			dsts = sys_read32((mem_addr_t)&base->dsts);
			priv->sof_num = usb_dwc2_get_dsts_soffn(dsts);
			udc_submit_event(dev, UDC_EVT_SOF, 0);
			udc_submit_sof_event(dev);
		}

		if (int_status & USB_DWC2_GINTSTS_USBRST) {
@@ -2941,11 +2943,13 @@ static void udc_dwc2_isr_handler(const struct device *dev)
			dwc2_handle_oepint(dev);
		}

		if (int_status & USB_DWC2_GINTSTS_INCOMPISOIN) {
		if (IS_ENABLED(CONFIG_UDC_ENABLE_SOF) &&
		    int_status & USB_DWC2_GINTSTS_INCOMPISOIN) {
			dwc2_handle_incompisoin(dev);
		}

		if (int_status & USB_DWC2_GINTSTS_INCOMPISOOUT) {
		if (IS_ENABLED(CONFIG_UDC_ENABLE_SOF) &&
		    int_status & USB_DWC2_GINTSTS_INCOMPISOOUT) {
			dwc2_handle_incompisoout(dev);
		}

+3 −6
Changes for drivers/usb/udc/udc_it82xx2.c: 3 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -17,9 +17,6 @@ LOG_MODULE_REGISTER(udc_it82xx2, CONFIG_UDC_DRIVER_LOG_LEVEL);

#define DT_DRV_COMPAT ite_it82xx2_usb

/* TODO: Replace this definition by Kconfig option */
#define USB_DEVICE_CONFIG_SOF_NOTIFICATIONS (0U)

#define IT8XXX2_IS_EXTEND_ENDPOINT(n) (USB_EP_GET_IDX(n) >= 4)

#define IT82xx2_STATE_OUT_SHARED_FIFO_BUSY 0
@@ -1357,11 +1354,11 @@ static void it82xx2_usb_dc_isr(const void *arg)

	/* sof received */
	if (status & DC_SOF_RECEIVED) {
		if (!USB_DEVICE_CONFIG_SOF_NOTIFICATIONS) {
		if (!IS_ENABLED(CONFIG_UDC_ENABLE_SOF)) {
			it82xx2_enable_sof_int(dev, false);
		} else {
			usb_regs->dc_interrupt_status = DC_SOF_RECEIVED;
			udc_submit_event(dev, UDC_EVT_SOF, 0);
			udc_submit_sof_event(dev);
		}
		it82xx2_enable_resume_int(dev, false);
		emit_resume_event(dev);
@@ -1411,7 +1408,7 @@ static void suspended_handler(struct k_work *item)

	it82xx2_enable_resume_int(dev, true);

	if (!USB_DEVICE_CONFIG_SOF_NOTIFICATIONS) {
	if (!IS_ENABLED(CONFIG_UDC_ENABLE_SOF)) {
		it82xx2_enable_sof_int(dev, true);
	}

+2 −2
Changes for drivers/usb/udc/udc_kinetis.c: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -653,7 +653,7 @@ static void usbfsotg_isr_handler(const struct device *dev)
	}

	if (istatus == USB_ISTAT_SOFTOK_MASK) {
		udc_submit_event(dev, UDC_EVT_SOF, 0);
		udc_submit_sof_event(dev);
	}

	if (istatus == USB_ISTAT_ERROR_MASK) {
@@ -1016,7 +1016,7 @@ static int usbfsotg_init(const struct device *dev)
	base->INTEN = (USB_INTEN_SLEEPEN_MASK  |
		       USB_INTEN_STALLEN_MASK |
		       USB_INTEN_TOKDNEEN_MASK |
		       USB_INTEN_SOFTOKEN_MASK |
		       IF_ENABLED(CONFIG_UDC_ENABLE_SOF, (USB_INTEN_SOFTOKEN_MASK |))
		       USB_INTEN_ERROREN_MASK |
		       USB_INTEN_USBRSTEN_MASK);

+1 −1
Changes for drivers/usb/udc/udc_max32.c: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -533,7 +533,7 @@ static int udc_max32_event_callback(maxusb_event_t event, void *cbdata)
	case MAXUSB_EVENT_DPACT:
		LOG_DBG("DPACT event occurred");
		udc_set_suspended(dev, false);
		udc_submit_event(dev, UDC_EVT_SOF, 0);
		udc_submit_sof_event(dev);
		break;
	case MAXUSB_EVENT_BRST:
		LOG_DBG("BRST event occurred");
Loading