Skip to content

Commit 56b359b

Browse files
jfischer-nodanieldegrasse
authored andcommitted
drivers: udc_dwc2: do not throw error when FIFO settings can be reused
When the endpoint is re-enabled, check if the current FIFO settings can be reused. Further work is needed to improve FIFO memory handling for more advanced interface configurations. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
1 parent 732785a commit 56b359b

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

drivers/usb/udc/udc_dwc2.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,12 +1328,6 @@ static int dwc2_set_dedicated_fifo(const struct device *dev,
13281328
dwc2_unset_unused_fifo(dev);
13291329
}
13301330

1331-
if (priv->txf_set & ~BIT_MASK(ep_idx)) {
1332-
LOG_WRN("Some of the FIFOs higher than %u are set, %lx",
1333-
ep_idx, priv->txf_set & ~BIT_MASK(ep_idx));
1334-
return -EIO;
1335-
}
1336-
13371331
if ((ep_idx - 1) != 0U) {
13381332
txfaddr = dwc2_get_txfdep(dev, ep_idx - 2) +
13391333
dwc2_get_txfaddr(dev, ep_idx - 2);
@@ -1342,8 +1336,21 @@ static int dwc2_set_dedicated_fifo(const struct device *dev,
13421336
MIN(UDC_DWC2_FIFO0_DEPTH, priv->max_txfifo_depth[0]);
13431337
}
13441338

1339+
if (priv->txf_set & BIT(ep_idx)) {
1340+
uint32_t curaddr;
1341+
1342+
curaddr = dwc2_get_txfaddr(dev, ep_idx - 1);
1343+
txfdep = dwc2_get_txfdep(dev, ep_idx - 1);
1344+
if (txfaddr != curaddr || reqdep > txfdep) {
1345+
LOG_ERR("FIFO%u cannot be reused, new addr 0x%04x depth %u",
1346+
ep_idx, txfaddr, reqdep);
1347+
return -ENOMEM;
1348+
}
1349+
} else {
1350+
txfdep = reqdep;
1351+
}
1352+
13451353
/* Make sure to not set TxFIFO greater than hardware allows */
1346-
txfdep = reqdep;
13471354
if (txfdep > priv->max_txfifo_depth[ep_idx]) {
13481355
return -ENOMEM;
13491356
}

0 commit comments

Comments
 (0)