feat(usb): add ESP32-S31 DWC/UTMI support

Add ESP32-S31 USB DWC/UTMI LL headers, SoC register structures, peripheral
descriptors, capabilities, and linker mappings so the HS OTG controller and
UTMI PHY can be built in esp_hal_usb.

Introduce SOC_USB_FSLS_PHY_NUM on USB-OTG targets to separate FSLS USB_WRAP
support from OTG/UTMI support. Use it to gate usb_wrap, the USB PHY driver,
docs, and example build rules on targets without an FSLS PHY.

Also add UTMI data pulldown control to the HAL, clear the boot-time DWC
suspend state on ESP32-S31, alias the legacy internal PHY target to UTMI for
backward compatibility, and extend usb_phy tests for UTMI-only targets.
This commit is contained in:
igor.masar
2026-04-08 16:01:28 +08:00
committed by BOT
parent edb0e8dba9
commit 9ab7d5eb03
30 changed files with 3097 additions and 69 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -12,6 +12,10 @@
#include "soc/hp_sys_clkrst_struct.h"
#include "soc/hp_system_struct.h"
#include "soc/usb_utmi_struct.h"
#include "hal/config.h"
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
#include "soc/lp_system_struct.h"
#endif
#ifdef __cplusplus
extern "C" {
@@ -81,6 +85,29 @@ FORCE_INLINE_ATTR void _usb_utmi_ll_reset_register(void)
_usb_utmi_ll_reset_register(__VA_ARGS__); \
} while(0)
/**
* @brief Enable/disable 15k pulldown resistors on D+/D- lines
*
* In USB Host mode, 15k pulldown resistors must be connected on both D+ and D-.
* In USB Device mode, pulldown resistors must be disconnected.
*
* @note On ESP32-P4 v3+, pulldowns are no longer controlled by USB-OTG peripheral
* and must be controlled by software via LP_SYS registers.
* On earlier revisions, pulldowns are controlled by USB-OTG hardware.
*
* @param[in] enable true to connect pulldowns (Host mode), false to disconnect (Device mode)
*/
FORCE_INLINE_ATTR void usb_utmi_ll_enable_data_pulldowns(bool enable)
{
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
LP_SYS.hp_usb_otghs_phy_ctrl.hp_utmiotg_dppulldown = enable;
LP_SYS.hp_usb_otghs_phy_ctrl.hp_utmiotg_dmpulldown = enable;
#else
// On pre-v3 ESP32-P4, pulldowns are controlled by the USB-OTG peripheral
(void)enable;
#endif
}
/**
* @brief Enable precise detection of VBUS
*