Skip to content

Commit 8e268f4

Browse files
author
Josuah Demangeon
committed
support events for multiple channels
1 parent 7b122b0 commit 8e268f4

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

drivers/usb/uhc/uhc_dwc2.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ enum uhc_dwc2_event {
3939
/* Root port event */
4040
UHC_DWC2_EVENT_PORT,
4141
/* Root chan event */
42-
UHC_DWC2_EVENT_CHAN,
42+
UHC_DWC2_EVENT_CHAN0,
4343
};
4444

4545
enum uhc_dwc2_speed {
@@ -1089,7 +1089,7 @@ static void uhc_dwc2_handle_chan_intr(const struct device *dev, struct uhc_dwc2_
10891089
}
10901090
chan->last_event = chan_event;
10911091
chan->event_pending = 1;
1092-
k_event_post(&priv->drv_evt, BIT(UHC_DWC2_EVENT_CHAN));
1092+
k_event_post(&priv->drv_evt, BIT(UHC_DWC2_EVENT_CHAN0));
10931093
break;
10941094
case DWC2_CHAN_EVENT_ERROR:
10951095
LOG_ERR("Channel error handling not implemented yet");
@@ -1104,8 +1104,6 @@ static void uhc_dwc2_handle_chan_intr(const struct device *dev, struct uhc_dwc2_
11041104

11051105
/* Hint:
11061106
* We've halted a transfer, so we need to trigger the chan callback
1107-
* chan->last_event = DWC2_CHAN_EVENT_CPLT;
1108-
* ret = chan->last_event;
11091107
* Halt request event is triggered when packet is successful completed.
11101108
* But just treat all halted transfers as errors
11111109
* chan->state = UHC_CHAN_STATE_HALTED;
@@ -1114,9 +1112,7 @@ static void uhc_dwc2_handle_chan_intr(const struct device *dev, struct uhc_dwc2_
11141112
*/
11151113
break;
11161114
default:
1117-
/* Should never happen */
1118-
LOG_WRN("Unknown channel event %d", chan_event);
1119-
break;
1115+
CODE_UNREACHABLE;
11201116
}
11211117
}
11221118

@@ -1633,13 +1629,11 @@ static inline void uhc_dwc2_handle_port_events(const struct device *dev)
16331629
}
16341630
}
16351631

1636-
static inline void uhc_dwc2_handle_chan_events(const struct device *dev)
1632+
static inline void uhc_dwc2_handle_chan_events(const struct device *dev, struct uhc_dwc2_chan *chan)
16371633
{
16381634
struct uhc_dwc2_data *priv = uhc_get_private(dev);
16391635
const struct uhc_dwc2_config *const config = dev->config;
16401636
struct usb_dwc2_reg *const dwc2 = config->base;
1641-
/* TODO: support more than CTRL chan */
1642-
struct uhc_dwc2_chan *chan = &priv->chan[0];
16431637
const struct usb_dwc2_host_chan *chan_regs = UHC_DWC2_CHAN_REG(dwc2, chan->chan_idx);
16441638

16451639
LOG_DBG("Pipe event: %d", chan->last_event);
@@ -1694,9 +1688,11 @@ static inline void uhc_dwc2_thread_handler(void *const arg)
16941688
uhc_dwc2_handle_port_events(dev);
16951689
}
16961690

1697-
if (evt & BIT(UHC_DWC2_EVENT_CHAN)) {
1698-
k_event_clear(&priv->drv_evt, BIT(UHC_DWC2_EVENT_CHAN));
1699-
uhc_dwc2_handle_chan_events(dev);
1691+
for (uint32_t i = 0; i < 32; i++) {
1692+
if (evt & BIT(UHC_DWC2_EVENT_CHAN0 + i)) {
1693+
k_event_clear(&priv->drv_evt, BIT(UHC_DWC2_EVENT_CHAN0 + i));
1694+
uhc_dwc2_handle_chan_events(dev, &priv->chan[i]);
1695+
}
17001696
}
17011697

17021698
uhc_unlock_internal(dev);

0 commit comments

Comments
 (0)