Skip to content

Commit 2ff38cc

Browse files
benpiccocarlescufi
authored andcommitted
usb: sam0: Support more then one USB IRQ
Newer SoCs like SAME54 have multiple IRQs for the USB peripheral. Automatically enable all IRQs configured in the DTS. Signed-off-by: Benjamin Valentin <[email protected]>
1 parent 9a7a1b0 commit 2ff38cc

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

drivers/usb/device/usb_dc_sam0.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ static void usb_sam0_load_padcal(void)
166166
regs->PADCAL.bit.TRIM = pad_trim;
167167
}
168168

169+
#define SAM0_USB_IRQ_CONNECT(n) \
170+
do { \
171+
IRQ_CONNECT(DT_INST_0_ATMEL_SAM0_USB_IRQ_##n, \
172+
DT_INST_0_ATMEL_SAM0_USB_IRQ_##n##_PRIORITY,\
173+
usb_sam0_isr, 0, 0); \
174+
irq_enable(DT_INST_0_ATMEL_SAM0_USB_IRQ_##n); \
175+
} while (0)
176+
169177
/* Attach by initializing the device */
170178
int usb_dc_attach(void)
171179
{
@@ -203,10 +211,18 @@ int usb_dc_attach(void)
203211
regs->INTENSET.reg = USB_DEVICE_INTENSET_EORST;
204212

205213
/* Connect and enable the interrupt */
206-
IRQ_CONNECT(DT_INST_0_ATMEL_SAM0_USB_IRQ_0,
207-
DT_INST_0_ATMEL_SAM0_USB_IRQ_0_PRIORITY,
208-
usb_sam0_isr, 0, 0);
209-
irq_enable(DT_INST_0_ATMEL_SAM0_USB_IRQ_0);
214+
#ifdef DT_INST_0_ATMEL_SAM0_USB_IRQ_0
215+
SAM0_USB_IRQ_CONNECT(0);
216+
#endif
217+
#ifdef DT_INST_0_ATMEL_SAM0_USB_IRQ_1
218+
SAM0_USB_IRQ_CONNECT(1);
219+
#endif
220+
#ifdef DT_INST_0_ATMEL_SAM0_USB_IRQ_2
221+
SAM0_USB_IRQ_CONNECT(2);
222+
#endif
223+
#ifdef DT_INST_0_ATMEL_SAM0_USB_IRQ_3
224+
SAM0_USB_IRQ_CONNECT(3);
225+
#endif
210226

211227
/* Enable and attach */
212228
regs->CTRLA.bit.ENABLE = 1;

0 commit comments

Comments
 (0)