Skip to content

Commit 0ead362

Browse files
committed
Merge branch 'fix/usb_host_hcd_dma_ls_via_fs_hubs' into 'master'
fix(hcd): Added delay to slow down scatter-gather dma for ls device via fs hubs Closes IDF-11264 and IDFGH-14984 See merge request espressif/esp-idf!38118
2 parents d38c05c + dbf9d78 commit 0ead362

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

components/usb/hcd_dwc.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -383,10 +383,17 @@ static void _buffer_exec(pipe_t *pipe);
383383
*/
384384
static inline bool _buffer_check_done(pipe_t *pipe)
385385
{
386+
// Only control transfers need to be continued
386387
if (pipe->ep_char.type != USB_DWC_XFER_TYPE_CTRL) {
387388
return true;
388389
}
389-
// Only control transfers need to be continued
390+
#if (CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3)
391+
// The HW can't handle two transactions with preamble in one frame.
392+
// TODO: IDF-15060
393+
if (pipe->ep_char.ls_via_fs_hub) {
394+
esp_rom_delay_us(1000);
395+
}
396+
#endif // CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
390397
dma_buffer_block_t *buffer_inflight = pipe->buffers[pipe->multi_buffer_control.rd_idx];
391398
return (buffer_inflight->flags.ctrl.cur_stg == 2);
392399
}
@@ -1616,7 +1623,13 @@ static void pipe_set_ep_char(const hcd_pipe_config_t *pipe_config, usb_transfer_
16161623
ep_char->mps = USB_EP_DESC_GET_MPS(pipe_config->ep_desc);
16171624
}
16181625
ep_char->dev_addr = pipe_config->dev_addr;
1619-
ep_char->ls_via_fs_hub = (port_speed == USB_SPEED_FULL && pipe_config->dev_speed == USB_SPEED_LOW);
1626+
if (pipe_idx > 0) {
1627+
// TODO: remove warning after IDF-15060
1628+
if (port_speed == USB_SPEED_FULL && pipe_config->dev_speed == USB_SPEED_LOW) {
1629+
ESP_LOGW(HCD_DWC_TAG, "Low-speed, extra delay will be applied in ISR");
1630+
ep_char->ls_via_fs_hub = 1;
1631+
}
1632+
}
16201633
// Calculate the pipe's interval in terms of USB frames
16211634
// @see USB-OTG programming guide chapter 6.5 for more information
16221635
if (type == USB_TRANSFER_TYPE_INTR || type == USB_TRANSFER_TYPE_ISOCHRONOUS) {

0 commit comments

Comments
 (0)