summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2026-07-03 17:46:21 +0700
committerhathach <[email protected]>2026-07-03 17:46:21 +0700
commitb218b477a3c841f3f59cf0a6d34cfcd7a86ca8fb (patch)
treec859858cc5cc89fa1e36b98889f868eb97d54994
parentd28628b52beb40b10258eb063acb247ce59a6bc8 (diff)
dcd: retire dcd_edpt_close() on the iso-migrated drivers
Now that ip3511, rusb2 and nrf5x are on ISO_ALLOC, the stack's usbd_edpt_close() is a no-op for them, so dcd_edpt_close() is no longer a public DCD entry point. Audit of the remaining callers: - ip3511, nrf5x: dcd_edpt_close_all() does its own teardown and no longer calls dcd_edpt_close() -> it is dead code, removed. - rusb2: dcd_edpt_close_all() still tears down each pipe via it -> kept but made a static internal helper (edpt_close), not a public dcd_ API. Revert dcd.h to declaring dcd_edpt_close() only under TUP_DCD_EDPT_CLOSE_API (for the remaining close-API MCUs); ISO_ALLOC IPs declare iso alloc/activate instead. Behaviour-neutral (removed/renamed uncalled functions); dwc2 still builds and nrf5x still passes bulk/iso/halt on hardware. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HeF2gZ1M7GWkz6Av4BpKPg
-rw-r--r--src/device/dcd.h9
-rw-r--r--src/portable/nordic/nrf5x/dcd_nrf5x.c37
-rw-r--r--src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c9
-rw-r--r--src/portable/renesas/rusb2/dcd_rusb2.c8
4 files changed, 11 insertions, 52 deletions
diff --git a/src/device/dcd.h b/src/device/dcd.h
index 8f980c11e..f861eb258 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -174,18 +174,19 @@ void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr);
// This API never calls with control endpoints, since it is auto cleared when receiving setup packet
void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr);
-// Close an endpoint. On CLOSE_API IPs the stack calls this from usbd_edpt_close(); on ISO_ALLOC
-// IPs it is a no-op in the stack, but some drivers (rusb2, ip3511, nrf5x) still use it internally
-// from dcd_edpt_close_all(), so it is declared unconditionally.
+#ifdef TUP_DCD_EDPT_CLOSE_API
+// Close an endpoint.
void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr);
-#ifdef TUP_DCD_EDPT_ISO_ALLOC
+#else
+
// Allocate packet buffer used by ISO endpoints
// Some MCU need manual packet buffer allocation, we allocate the largest size to avoid clustering
bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size);
// Configure and enable an ISO endpoint according to descriptor
bool dcd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * desc_ep);
+
#endif
//--------------------------------------------------------------------+
diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c
index 6c301e4b6..e0baa1f4a 100644
--- a/src/portable/nordic/nrf5x/dcd_nrf5x.c
+++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c
@@ -396,43 +396,6 @@ void dcd_edpt_close_all(uint8_t rhport) {
dcd_int_enable(rhport);
}
-void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr) {
- (void) rhport;
-
- uint8_t const epnum = tu_edpt_number(ep_addr);
- uint8_t const dir = tu_edpt_dir(ep_addr);
-
- if (epnum != EP_ISO_NUM) {
- // CBI
- if (dir == TUSB_DIR_OUT) {
- NRF_USBD->INTENCLR = TU_BIT(USBD_INTEN_ENDEPOUT0_Pos + epnum);
- NRF_USBD->EPOUTEN &= ~TU_BIT(epnum);
- } else {
- NRF_USBD->INTENCLR = TU_BIT(USBD_INTEN_ENDEPIN0_Pos + epnum);
- NRF_USBD->EPINEN &= ~TU_BIT(epnum);
- }
- } else {
- _dcd.xfer[EP_ISO_NUM][dir].mps = 0;
- // ISO
- if (dir == TUSB_DIR_OUT) {
- NRF_USBD->INTENCLR = USBD_INTENCLR_ENDISOOUT_Msk;
- NRF_USBD->EPOUTEN &= ~USBD_EPOUTEN_ISOOUT_Msk;
- NRF_USBD->EVENTS_ENDISOOUT = 0;
- } else {
- NRF_USBD->INTENCLR = USBD_INTENCLR_ENDISOIN_Msk;
- NRF_USBD->EPINEN &= ~USBD_EPINEN_ISOIN_Msk;
- }
- // One of the ISO endpoints closed, no need to split buffers any more.
- NRF_USBD->ISOSPLIT = USBD_ISOSPLIT_SPLIT_OneDir;
- // When both ISO endpoint are close there is no need for SOF any more.
- if (_dcd.xfer[EP_ISO_NUM][TUSB_DIR_IN].mps + _dcd.xfer[EP_ISO_NUM][TUSB_DIR_OUT].mps == 0)
- NRF_USBD->INTENCLR = USBD_INTENCLR_SOF_Msk;
- }
- _dcd.xfer[epnum][dir].started = false;
- __ISB();
- __DSB();
-}
-
bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size) {
(void)rhport;
(void)largest_packet_size;
diff --git a/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c b/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
index 451b07e15..1b591cf99 100644
--- a/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
+++ b/src/portable/nxp/lpc_ip3511/dcd_lpc_ip3511.c
@@ -423,15 +423,6 @@ void dcd_edpt_close_all (uint8_t rhport)
}
}
-void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
-{
- (void) rhport;
-
- uint8_t ep_id = ep_addr2id(ep_addr);
- _dcd.ep[ep_id][0].cmd_sts.active = _dcd.ep[ep_id][0].cmd_sts.active = 0; // TODO proper way is to EPSKIP then wait ep[][].active then write ep[][].disable (see table 778 in LPC55S69 Use Manual)
- _dcd.ep[ep_id][0].cmd_sts.disable = _dcd.ep[ep_id][1].cmd_sts.disable = 1;
-}
-
bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size) {
(void) largest_packet_size;
// Reserve the endpoint command/status entry once (persists across altsetting changes); the
diff --git a/src/portable/renesas/rusb2/dcd_rusb2.c b/src/portable/renesas/rusb2/dcd_rusb2.c
index ddd3fe0f2..0ef7661fe 100644
--- a/src/portable/renesas/rusb2/dcd_rusb2.c
+++ b/src/portable/renesas/rusb2/dcd_rusb2.c
@@ -766,6 +766,8 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * ep_desc)
return true;
}
+static void edpt_close(uint8_t rhport, uint8_t ep_addr);
+
void dcd_edpt_close_all(uint8_t rhport)
{
unsigned i = TU_ARRAY_SIZE(_dcd.pipe);
@@ -775,12 +777,14 @@ void dcd_edpt_close_all(uint8_t rhport)
if (!ep_addr) {
continue;
}
- dcd_edpt_close(rhport, (uint8_t)ep_addr);
+ edpt_close(rhport, (uint8_t)ep_addr);
}
dcd_int_enable(rhport);
}
-void dcd_edpt_close(uint8_t rhport, uint8_t ep_addr)
+// Internal helper: on this (ISO_ALLOC) IP the stack no longer calls dcd_edpt_close(); only
+// dcd_edpt_close_all() uses it to tear down each pipe.
+static void edpt_close(uint8_t rhport, uint8_t ep_addr)
{
rusb2_reg_t * rusb = RUSB2_REG(rhport);
const unsigned epn = tu_edpt_number(ep_addr);