From 42f3bca5a1ca0b1314f3f6d12a15f68411d4bb03 Mon Sep 17 00:00:00 2001 From: morris Date: Fri, 9 Jul 2021 11:09:28 +0800 Subject: [PATCH] usb: update LL to support PHY selection ESP32-S3 has two USB peripheral, one is USB_OTG, another is USB_JTAG_SERIAL A new mux has been introduced to select internal/external PHY interface. --- components/esp32s3/ld/esp32s3.peripherals.ld | 1 + components/hal/esp32s3/include/hal/usb_ll.h | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/components/esp32s3/ld/esp32s3.peripherals.ld b/components/esp32s3/ld/esp32s3.peripherals.ld index 6d86e13bfd..5b15a44618 100644 --- a/components/esp32s3/ld/esp32s3.peripherals.ld +++ b/components/esp32s3/ld/esp32s3.peripherals.ld @@ -37,5 +37,6 @@ PROVIDE ( DMA = 0x6003F000 ); PROVIDE ( APB_SARADC = 0x60040000 ); PROVIDE ( LCD_CAM = 0x60041000 ); PROVIDE ( USB_SERIAL_JTAG = 0x60038000 ); +PROVIDE ( USB0 = 0x60080000 ); PROVIDE ( USBH = 0x60080000 ); PROVIDE ( USB_WRAP = 0x60039000 ); diff --git a/components/hal/esp32s3/include/hal/usb_ll.h b/components/hal/esp32s3/include/hal/usb_ll.h index 2be637f55c..81950021d2 100644 --- a/components/hal/esp32s3/include/hal/usb_ll.h +++ b/components/hal/esp32s3/include/hal/usb_ll.h @@ -17,17 +17,28 @@ #include "soc/system_reg.h" #include "soc/gpio_sig_map.h" #include "soc/usb_periph.h" +#include "soc/rtc_cntl_struct.h" static inline void usb_ll_int_phy_enable(void) { USB_WRAP.otg_conf.pad_enable = 1; + // USB_OTG use internal PHY USB_WRAP.otg_conf.phy_sel = 0; + // phy_sel is controlled by the following register value + RTCCNTL.usb_conf.sw_hw_usb_phy_sel = 1; + // phy_sel=sw_usb_phy_sel=1, USB_OTG is connected with internal PHY + RTCCNTL.usb_conf.sw_usb_phy_sel = 1; } static inline void usb_ll_ext_phy_enable(void) { USB_WRAP.otg_conf.pad_enable = 1; + // USB_OTG use external PHY USB_WRAP.otg_conf.phy_sel = 1; + // phy_sel is controlled by the following register value + RTCCNTL.usb_conf.sw_hw_usb_phy_sel = 1; + // phy_sel=sw_usb_phy_sel=0, USB_OTG is connected with external PHY through GPIO Matrix + RTCCNTL.usb_conf.sw_usb_phy_sel = 0; } static inline void usb_ll_int_phy_pullup_conf(bool dp_pu, bool dp_pd, bool dm_pu, bool dm_pd)