Skip to content

Commit 1dc332e

Browse files
authored
Merge pull request #9986 from hathach/s3-usb-timing-workaround
ports/espressif/supervisor/usb.c: workaround ESP32-S3 USB PHY setup (cont)
2 parents 401295f + df142f2 commit 1dc332e

File tree

1 file changed

+3
-33
lines changed
  • ports/espressif/supervisor

1 file changed

+3
-33
lines changed

ports/espressif/supervisor/usb.c

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -89,49 +89,19 @@ void tud_cdc_rx_cb(uint8_t itf) {
8989
}
9090
#endif // CIRCUITPY_USB_DEVICE
9191

92-
93-
#if defined(CONFIG_IDF_TARGET_ESP32S3)
94-
// TEMPORARY WORKAROUND for https://github.com/hathach/tinyusb/issues/2943
95-
#include "soc/rtc_cntl_struct.h"
96-
#include "soc/usb_wrap_struct.h"
97-
#endif
98-
9992
void init_usb_hardware(void) {
10093
#if CIRCUITPY_USB_DEVICE
10194
// Configure USB PHY
102-
103-
// TEMPORARY WORKAROUND for https://github.com/hathach/tinyusb/issues/2943
104-
#if defined(CONFIG_IDF_TARGET_ESP32S3)
105-
106-
(void)phy_hdl;
107-
periph_module_reset(PERIPH_USB_MODULE);
108-
periph_module_enable(PERIPH_USB_MODULE);
109-
110-
USB_WRAP.otg_conf.pad_enable = 1;
111-
// USB_OTG use internal PHY
112-
USB_WRAP.otg_conf.phy_sel = 0;
113-
// phy_sel is controlled by the following register value
114-
RTCCNTL.usb_conf.sw_hw_usb_phy_sel = 1;
115-
// phy_sel=sw_usb_phy_sel=1, USB_OTG is connected with internal PHY
116-
RTCCNTL.usb_conf.sw_usb_phy_sel = 1;
117-
118-
gpio_set_drive_capability(USBPHY_DM_NUM, GPIO_DRIVE_CAP_3);
119-
gpio_set_drive_capability(USBPHY_DP_NUM, GPIO_DRIVE_CAP_3);
120-
#else
121-
12295
usb_phy_config_t phy_conf = {
12396
.controller = USB_PHY_CTRL_OTG,
12497
.target = USB_PHY_TARGET_INT,
12598

12699
.otg_mode = USB_OTG_MODE_DEVICE,
127-
#ifdef CONFIG_IDF_TARGET_ESP32P4
128-
.otg_speed = USB_PHY_SPEED_HIGH,
129-
#else
130-
.otg_speed = USB_PHY_SPEED_FULL,
131-
#endif
100+
// https://github.com/hathach/tinyusb/issues/2943#issuecomment-2601888322
101+
// Set speed to undefined (auto-detect) to avoid timing/race issue with S3 with host such as macOS
102+
.otg_speed = USB_PHY_SPEED_UNDEFINED,
132103
};
133104
usb_new_phy(&phy_conf, &phy_hdl);
134-
#endif
135105

136106
// Pin the USB task to the same core as CircuitPython. This way we leave
137107
// the other core for networking.

0 commit comments

Comments
 (0)