diff --git a/components/bootloader_support/src/bootloader_console.c b/components/bootloader_support/src/bootloader_console.c index 85512b3607..42708911dd 100644 --- a/components/bootloader_support/src/bootloader_console.c +++ b/components/bootloader_support/src/bootloader_console.c @@ -6,6 +6,7 @@ #include "sdkconfig.h" #include "bootloader_console.h" +#include "soc/soc_caps.h" #include "soc/uart_periph.h" #include "soc/uart_channel.h" #include "soc/io_mux_reg.h" @@ -18,8 +19,8 @@ #include "esp32s2/rom/usb/cdc_acm.h" #include "esp32s2/rom/usb/usb_common.h" #endif -#if SOC_USB_SERIAL_JTAG_SUPPORTED -#include "hal/usb_fsls_phy_ll.h" +#if CONFIG_ESP_CONSOLE_USB_CDC && SOC_USB_SERIAL_JTAG_SUPPORTED +#include "hal/usb_wrap_ll.h" #endif #include "esp_rom_gpio.h" #include "esp_rom_uart.h" diff --git a/components/driver/usb_serial_jtag/usb_serial_jtag.c b/components/driver/usb_serial_jtag/usb_serial_jtag.c index c6c8951d3f..7071f5eb65 100644 --- a/components/driver/usb_serial_jtag/usb_serial_jtag.c +++ b/components/driver/usb_serial_jtag/usb_serial_jtag.c @@ -9,7 +9,6 @@ #include #include "esp_log.h" #include "hal/usb_serial_jtag_ll.h" -#include "hal/usb_fsls_phy_ll.h" #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" #include "freertos/ringbuf.h" @@ -186,7 +185,8 @@ esp_err_t usb_serial_jtag_driver_install(usb_serial_jtag_driver_config_t *usb_se atomic_store(&p_usb_serial_jtag_obj->fifo_status, FIFO_IDLE); // Configure PHY - usb_fsls_phy_ll_int_jtag_enable(&USB_SERIAL_JTAG); + usb_serial_jtag_ll_phy_enable_external(false); // Use internal PHY + usb_serial_jtag_ll_phy_enable_pad(true); // Enable USB PHY pads usb_serial_jtag_ll_clr_intsts_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY| USB_SERIAL_JTAG_INTR_SERIAL_OUT_RECV_PKT); diff --git a/components/hal/CMakeLists.txt b/components/hal/CMakeLists.txt index d54766d4fd..18e2c7a11e 100644 --- a/components/hal/CMakeLists.txt +++ b/components/hal/CMakeLists.txt @@ -237,7 +237,7 @@ if(NOT BOOTLOADER_BUILD) if(CONFIG_SOC_USB_OTG_SUPPORTED) list(APPEND srcs "usb_dwc_hal.c" - "usb_fsls_phy_hal.c") + "usb_wrap_hal.c") endif() if(${target} STREQUAL "esp32") diff --git a/components/hal/esp32c3/include/hal/usb_fsls_phy_ll.h b/components/hal/esp32c3/include/hal/usb_fsls_phy_ll.h deleted file mode 100644 index b8d98219b0..0000000000 --- a/components/hal/esp32c3/include/hal/usb_fsls_phy_ll.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include "soc/usb_serial_jtag_struct.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Configures the internal PHY for USB_Serial_JTAG - * - * @param hw Start address of the USB Serial_JTAG registers - */ -static inline void usb_fsls_phy_ll_int_jtag_enable(usb_serial_jtag_dev_t *hw) -{ - // USB_Serial_JTAG use internal PHY - hw->conf0.phy_sel = 0; - // Disable software control USB D+ D- pullup pulldown (Device FS: dp_pullup = 1) - hw->conf0.pad_pull_override = 0; - // Enable USB D+ pullup - hw->conf0.dp_pullup = 1; - // Enable USB pad function - hw->conf0.usb_pad_enable = 1; -} - -#ifdef __cplusplus -} -#endif diff --git a/components/hal/esp32c6/include/hal/usb_fsls_phy_ll.h b/components/hal/esp32c6/include/hal/usb_fsls_phy_ll.h deleted file mode 100644 index 4893e96106..0000000000 --- a/components/hal/esp32c6/include/hal/usb_fsls_phy_ll.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include "soc/usb_serial_jtag_struct.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Configures the internal PHY for USB_Serial_JTAG - * - * @param hw Start address of the USB Serial_JTAG registers - */ -static inline void usb_fsls_phy_ll_int_jtag_enable(usb_serial_jtag_dev_t *hw) -{ - // USB_Serial_JTAG use internal PHY - hw->conf0.phy_sel = 0; - // Disable software control USB D+ D- pullup pulldown (Device FS: dp_pullup = 1) - hw->conf0.pad_pull_override = 0; - // Enable USB D+ pullup - hw->conf0.dp_pullup = 1; - // Enable USB pad function - hw->conf0.usb_pad_enable = 1; -} - -#ifdef __cplusplus -} -#endif diff --git a/components/hal/esp32h2/include/hal/usb_fsls_phy_ll.h b/components/hal/esp32h2/include/hal/usb_fsls_phy_ll.h deleted file mode 100644 index 271f2fd83b..0000000000 --- a/components/hal/esp32h2/include/hal/usb_fsls_phy_ll.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include "soc/usb_serial_jtag_struct.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Configures the internal PHY for USB_Serial_JTAG - * - * @param hw Start address of the USB Serial_JTAG registers - */ -static inline void usb_fsls_phy_ll_int_jtag_enable(usb_serial_jtag_dev_t *hw) -{ - // USB_Serial_JTAG use internal PHY - hw->conf0.phy_sel = 0; - // Disable software control USB D+ D- pullup pulldown (Device FS: dp_pullup = 1) - hw->conf0.pad_pull_override = 0; - // Enable USB D+ pullup - hw->conf0.dp_pullup = 1; - // Enable USB pad function - hw->conf0.usb_pad_enable = 1; -} - -#ifdef __cplusplus -} -#endif diff --git a/components/hal/esp32s2/include/hal/usb_fsls_phy_ll.h b/components/hal/esp32s2/include/hal/usb_wrap_ll.h similarity index 100% rename from components/hal/esp32s2/include/hal/usb_fsls_phy_ll.h rename to components/hal/esp32s2/include/hal/usb_wrap_ll.h diff --git a/components/hal/esp32s3/include/hal/usb_fsls_phy_ll.h b/components/hal/esp32s3/include/hal/usb_wrap_ll.h similarity index 100% rename from components/hal/esp32s3/include/hal/usb_fsls_phy_ll.h rename to components/hal/esp32s3/include/hal/usb_wrap_ll.h diff --git a/components/hal/include/hal/usb_fsls_phy_hal.h b/components/hal/include/hal/usb_wrap_hal.h similarity index 100% rename from components/hal/include/hal/usb_fsls_phy_hal.h rename to components/hal/include/hal/usb_wrap_hal.h diff --git a/components/hal/usb_fsls_phy_hal.c b/components/hal/usb_wrap_hal.c similarity index 68% rename from components/hal/usb_fsls_phy_hal.c rename to components/hal/usb_wrap_hal.c index 7bceb8c364..58b77bba23 100644 --- a/components/hal/usb_fsls_phy_hal.c +++ b/components/hal/usb_wrap_hal.c @@ -4,8 +4,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "hal/usb_fsls_phy_ll.h" -#include "hal/usb_fsls_phy_hal.h" +#include "soc/soc_caps.h" +#include "soc/rtc_cntl_struct.h" +#if SOC_USB_SERIAL_JTAG_SUPPORTED +#include "hal/usb_serial_jtag_ll.h" +#endif +#include "hal/usb_wrap_ll.h" +#include "hal/usb_wrap_hal.h" void usb_fsls_phy_hal_init(usb_fsls_phy_hal_context_t *hal) { @@ -29,9 +34,18 @@ void usb_fsls_phy_hal_otg_conf(usb_fsls_phy_hal_context_t *hal, usb_phy_target_t void usb_fsls_phy_hal_jtag_conf(usb_fsls_phy_hal_context_t *hal, usb_phy_target_t phy_target) { if (phy_target == USB_PHY_TARGET_EXT) { - usb_fsls_phy_ll_ext_jtag_enable(hal->jtag_dev); + usb_serial_jtag_ll_phy_enable_external(true); // USJ uses external PHY + // Enable SW control of muxing USB OTG vs USJ to the internal USB FSLS PHY + RTCCNTL.usb_conf.sw_hw_usb_phy_sel = 1; + // Internal USB FSLS PHY is mapped to the USJ + RTCCNTL.usb_conf.sw_usb_phy_sel = 1; } else if (phy_target == USB_PHY_TARGET_INT) { - usb_fsls_phy_ll_int_jtag_enable(hal->jtag_dev); + usb_serial_jtag_ll_phy_enable_external(true); // USJ uses internal PHY + usb_serial_jtag_ll_phy_enable_pad(true); // Enable USB PHY pads + // Enable SW control of muxing USB OTG vs USJ to the internal USB FSLS PHY + RTCCNTL.usb_conf.sw_hw_usb_phy_sel = 1; + // Internal USB FSLS PHY is mapped to the USJ + RTCCNTL.usb_conf.sw_usb_phy_sel = 0; } } #endif diff --git a/components/usb/usb_phy.c b/components/usb/usb_phy.c index 4e1707441a..c687c21782 100644 --- a/components/usb/usb_phy.c +++ b/components/usb/usb_phy.c @@ -12,8 +12,8 @@ #include "esp_private/periph_ctrl.h" #include "esp_private/usb_phy.h" #include "soc/usb_dwc_periph.h" -#include "hal/usb_fsls_phy_hal.h" -#include "hal/usb_fsls_phy_ll.h" +#include "hal/usb_wrap_hal.h" +#include "hal/usb_wrap_ll.h" #include "esp_rom_gpio.h" #include "driver/gpio.h" #include "hal/gpio_ll.h"