Skip to content

Commit 7b287ec

Browse files
jfischer-nofabiobaltieri
authored andcommitted
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: Johann Fischer <[email protected]>
1 parent 2d79957 commit 7b287ec

File tree

17 files changed

+42
-31
lines changed

17 files changed

+42
-31
lines changed

drivers/usb/udc/udc_ambiq.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ static void udc_ambiq_evt_callback(const struct device *dev, am_hal_usb_dev_even
156156
case AM_HAL_USB_DEV_EVT_BUS_RESET:
157157
/* enable usb bus interrupts */
158158
am_hal_usb_intr_usb_enable(priv->usb_handle,
159-
USB_CFG2_SOFE_Msk | USB_CFG2_ResumeE_Msk |
160-
USB_CFG2_SuspendE_Msk | USB_CFG2_ResetE_Msk);
159+
IF_ENABLED(CONFIG_UDC_ENABLE_SOF, (USB_CFG2_SOFE_Msk |))
160+
USB_CFG2_ResumeE_Msk |
161+
USB_CFG2_SuspendE_Msk | USB_CFG2_ResetE_Msk);
161162
/* init the endpoint */
162163
am_hal_usb_ep_init(priv->usb_handle, 0, 0, EP0_MPS);
163164
/* Set USB device speed to HAL */
@@ -174,7 +175,7 @@ static void udc_ambiq_evt_callback(const struct device *dev, am_hal_usb_dev_even
174175
udc_submit_event(dev, UDC_EVT_RESUME, 0);
175176
break;
176177
case AM_HAL_USB_DEV_EVT_SOF:
177-
udc_submit_event(dev, UDC_EVT_SOF, 0);
178+
udc_submit_sof_event(dev);
178179
break;
179180
case AM_HAL_USB_DEV_EVT_SUSPEND:
180181
/* Handle USB Suspend event, then set device state to suspended */

drivers/usb/udc/udc_dwc2.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,11 +2162,12 @@ static int udc_dwc2_init_controller(const struct device *dev)
21622162
}
21632163

21642164
/* Unmask interrupts */
2165-
sys_write32(USB_DWC2_GINTSTS_OEPINT | USB_DWC2_GINTSTS_IEPINT |
2165+
sys_write32(IF_ENABLED(CONFIG_UDC_ENABLE_SOF, (USB_DWC2_GINTSTS_SOF |
2166+
USB_DWC2_GINTSTS_INCOMPISOOUT |
2167+
USB_DWC2_GINTSTS_INCOMPISOIN |))
2168+
USB_DWC2_GINTSTS_OEPINT | USB_DWC2_GINTSTS_IEPINT |
21662169
USB_DWC2_GINTSTS_ENUMDONE | USB_DWC2_GINTSTS_USBRST |
2167-
USB_DWC2_GINTSTS_WKUPINT | USB_DWC2_GINTSTS_USBSUSP |
2168-
USB_DWC2_GINTSTS_INCOMPISOOUT | USB_DWC2_GINTSTS_INCOMPISOIN |
2169-
USB_DWC2_GINTSTS_SOF,
2170+
USB_DWC2_GINTSTS_WKUPINT | USB_DWC2_GINTSTS_USBSUSP,
21702171
(mem_addr_t)&base->gintmsk);
21712172

21722173
return 0;
@@ -2890,15 +2891,16 @@ static void udc_dwc2_isr_handler(const struct device *dev)
28902891

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

2893-
if (int_status & USB_DWC2_GINTSTS_SOF) {
2894+
if (IS_ENABLED(CONFIG_UDC_ENABLE_SOF) &&
2895+
int_status & USB_DWC2_GINTSTS_SOF) {
28942896
uint32_t dsts;
28952897

28962898
/* Clear USB SOF interrupt. */
28972899
sys_write32(USB_DWC2_GINTSTS_SOF, gintsts_reg);
28982900

28992901
dsts = sys_read32((mem_addr_t)&base->dsts);
29002902
priv->sof_num = usb_dwc2_get_dsts_soffn(dsts);
2901-
udc_submit_event(dev, UDC_EVT_SOF, 0);
2903+
udc_submit_sof_event(dev);
29022904
}
29032905

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

2944-
if (int_status & USB_DWC2_GINTSTS_INCOMPISOIN) {
2946+
if (IS_ENABLED(CONFIG_UDC_ENABLE_SOF) &&
2947+
int_status & USB_DWC2_GINTSTS_INCOMPISOIN) {
29452948
dwc2_handle_incompisoin(dev);
29462949
}
29472950

2948-
if (int_status & USB_DWC2_GINTSTS_INCOMPISOOUT) {
2951+
if (IS_ENABLED(CONFIG_UDC_ENABLE_SOF) &&
2952+
int_status & USB_DWC2_GINTSTS_INCOMPISOOUT) {
29492953
dwc2_handle_incompisoout(dev);
29502954
}
29512955

drivers/usb/udc/udc_it82xx2.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ LOG_MODULE_REGISTER(udc_it82xx2, CONFIG_UDC_DRIVER_LOG_LEVEL);
1717

1818
#define DT_DRV_COMPAT ite_it82xx2_usb
1919

20-
/* TODO: Replace this definition by Kconfig option */
21-
#define USB_DEVICE_CONFIG_SOF_NOTIFICATIONS (0U)
22-
2320
#define IT8XXX2_IS_EXTEND_ENDPOINT(n) (USB_EP_GET_IDX(n) >= 4)
2421

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

13581355
/* sof received */
13591356
if (status & DC_SOF_RECEIVED) {
1360-
if (!USB_DEVICE_CONFIG_SOF_NOTIFICATIONS) {
1357+
if (!IS_ENABLED(CONFIG_UDC_ENABLE_SOF)) {
13611358
it82xx2_enable_sof_int(dev, false);
13621359
} else {
13631360
usb_regs->dc_interrupt_status = DC_SOF_RECEIVED;
1364-
udc_submit_event(dev, UDC_EVT_SOF, 0);
1361+
udc_submit_sof_event(dev);
13651362
}
13661363
it82xx2_enable_resume_int(dev, false);
13671364
emit_resume_event(dev);
@@ -1411,7 +1408,7 @@ static void suspended_handler(struct k_work *item)
14111408

14121409
it82xx2_enable_resume_int(dev, true);
14131410

1414-
if (!USB_DEVICE_CONFIG_SOF_NOTIFICATIONS) {
1411+
if (!IS_ENABLED(CONFIG_UDC_ENABLE_SOF)) {
14151412
it82xx2_enable_sof_int(dev, true);
14161413
}
14171414

drivers/usb/udc/udc_kinetis.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ static void usbfsotg_isr_handler(const struct device *dev)
653653
}
654654

655655
if (istatus == USB_ISTAT_SOFTOK_MASK) {
656-
udc_submit_event(dev, UDC_EVT_SOF, 0);
656+
udc_submit_sof_event(dev);
657657
}
658658

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

drivers/usb/udc/udc_max32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ static int udc_max32_event_callback(maxusb_event_t event, void *cbdata)
533533
case MAXUSB_EVENT_DPACT:
534534
LOG_DBG("DPACT event occurred");
535535
udc_set_suspended(dev, false);
536-
udc_submit_event(dev, UDC_EVT_SOF, 0);
536+
udc_submit_sof_event(dev);
537537
break;
538538
case MAXUSB_EVENT_BRST:
539539
LOG_DBG("BRST event occurred");

drivers/usb/udc/udc_mcux_ehci.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ usb_status_t USB_DeviceNotificationTrigger(void *handle, void *msg)
531531
udc_submit_event(dev, UDC_EVT_VBUS_READY, 0);
532532
break;
533533
case kUSB_DeviceNotifySOF:
534-
udc_submit_event(dev, UDC_EVT_SOF, 0);
534+
udc_submit_sof_event(dev);
535535
break;
536536
default:
537537
udc_mcux_event_submit(dev, mcux_msg);

drivers/usb/udc/udc_mcux_ip3511.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ usb_status_t USB_DeviceNotificationTrigger(void *handle, void *msg)
531531
udc_submit_event(dev, UDC_EVT_VBUS_READY, 0);
532532
break;
533533
case kUSB_DeviceNotifySOF:
534-
udc_submit_event(dev, UDC_EVT_SOF, 0);
534+
udc_submit_sof_event(dev);
535535
break;
536536
default:
537537
udc_mcux_event_submit(dev, mcux_msg);

drivers/usb/udc/udc_nrf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ static void ev_sof_handler(void)
436436

437437
m_ep_armed &= ~USBD_EPISO_BIT_MASK;
438438

439-
udc_submit_event(udc_nrf_dev, UDC_EVT_SOF, 0);
439+
udc_submit_sof_event(udc_nrf_dev);
440440
}
441441

442442
static void usbd_in_packet_sent(uint8_t ep)
@@ -1547,7 +1547,7 @@ static void udc_nrf_power_handler(nrfx_power_usb_evt_t pwr_evt)
15471547
break;
15481548
case NRFX_POWER_USB_EVT_READY:
15491549
LOG_DBG("POWER event ready");
1550-
nrf_usbd_legacy_start(true);
1550+
nrf_usbd_legacy_start(IS_ENABLED(CONFIG_UDC_ENABLE_SOF));
15511551
break;
15521552
case NRFX_POWER_USB_EVT_REMOVED:
15531553
LOG_DBG("POWER event removed");

drivers/usb/udc/udc_numaker.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ static inline void numaker_usbd_sw_connect(const struct device *dev)
171171
base->INTSTS = base->INTSTS;
172172

173173
/* Enable relevant interrupts */
174-
base->INTEN = USBD_INT_BUS | USBD_INT_USB | USBD_INT_FLDET | USBD_INT_WAKEUP | USBD_INT_SOF;
174+
base->INTEN = USBD_INT_BUS | USBD_INT_USB | USBD_INT_FLDET |
175+
IF_ENABLED(CONFIG_UDC_ENABLE_SOF, (USBD_INT_SOF |))
176+
USBD_INT_WAKEUP;
175177

176178
/* Clear SE0 for connect */
177179
base->SE0 &= ~USBD_DRVSE0;
@@ -1298,7 +1300,7 @@ static void numaker_udbd_isr(const struct device *dev)
12981300
base->INTSTS = USBD_INTSTS_SOFIF_Msk;
12991301

13001302
/* UDC stack would handle bottom-half processing */
1301-
udc_submit_event(dev, UDC_EVT_SOF, 0);
1303+
udc_submit_sof_event(dev);
13021304
}
13031305

13041306
/* USB Setup/EP */

drivers/usb/udc/udc_renesas_ra.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static void udc_renesas_ra_event_handler(usbd_callback_arg_t *p_args)
7979
break;
8080

8181
case USBD_EVENT_SOF:
82-
udc_submit_event(dev, UDC_EVT_SOF, 0);
82+
udc_submit_sof_event(dev);
8383
break;
8484

8585
default:

0 commit comments

Comments
 (0)