@@ -807,14 +807,13 @@ static void uhc_dwc2_buffer_exec(const struct device *dev, struct uhc_dwc2_chan
807807}
808808
809809/*
810- * Runtime functions
810+ * Interrupt handler (ISR)
811811 *
812- * Handle the interrupts being dispatched into events, and the driver thread handling them
813- * as well as handlers called from them .
812+ * Handle the interrupts being dispatched into events, as well as some immediate handling of
813+ * events directly from the IRQ handler .
814814 */
815815
816- static enum uhc_dwc2_chan_event uhc_dwc2_hal_chan_decode_intr (const struct device * dev ,
817- struct uhc_dwc2_chan * chan )
816+ static void uhc_dwc2_isr_chan_handler (const struct device * dev , struct uhc_dwc2_chan * chan )
818817{
819818 const struct uhc_dwc2_config * const config = dev -> config ;
820819 struct usb_dwc2_reg * const dwc2 = config -> base ;
@@ -870,18 +869,6 @@ static enum uhc_dwc2_chan_event uhc_dwc2_hal_chan_decode_intr(const struct devic
870869 atomic_set_bit (& chan -> event , chan_event );
871870 k_event_set (& priv -> event , BIT (UHC_DWC2_EVENT_CHAN0 + chan -> chan_idx ));
872871 }
873-
874- return chan_event ;
875- }
876-
877- static inline enum uhc_dwc2_ctrl_stage cal_next_pid (enum uhc_dwc2_ctrl_stage pid , uint8_t pkt_count )
878- {
879- if (pkt_count & 0x01 ) {
880- /* Toggle DATA0 and DATA1 */
881- return pid ^ 0x02 ;
882- } else {
883- return pid ;
884- }
885872}
886873
887874static void uhc_dwc2_isr_handler (const struct device * dev )
@@ -916,12 +903,9 @@ static void uhc_dwc2_isr_handler(const struct device *dev)
916903 /* One or more channels have pending interrupts. Store the mask of those channels */
917904 channels = sys_read32 ((mem_addr_t )& dwc2 -> haint );
918905 for (uint8_t i ; (i = __builtin_ffs (channels )) != 0 ; channels &= !BIT (i - 1 )) {
919- struct uhc_dwc2_chan * chan = & priv -> chan [i - 1 ];
920- enum uhc_dwc2_chan_event chan_event =
921- uhc_dwc2_hal_chan_decode_intr (dev , chan );
922-
923- LOG_DBG ("Channel event: 0x%08x" , chan_event );
906+ uhc_dwc2_isr_chan_handler (dev , & priv -> chan [i - 1 ]);
924907 }
908+ LOG_DBG ("Handling channel event" );
925909 }
926910
927911 if (port_intrs & USB_DWC2_HPRT_PRTOVRCURRCHNG ) {
0 commit comments