mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
refactor(usb/host): Move P4 HS PHY function to correct LL file
Moved usb_wrap_ll_enable_precise_detection() in usb_wrap_ll.h to usb_utmi_ll_enable_precise_detection() in usb_utmi_ll.h Fixes commit 97d30e7c48bfedec59a03ccebb7bc203ba86e126
This commit is contained in:
parent
21c6c62087
commit
ba16f50560
@ -10,6 +10,7 @@
|
||||
#include "esp_attr.h"
|
||||
#include "soc/lp_clkrst_struct.h"
|
||||
#include "soc/hp_sys_clkrst_struct.h"
|
||||
#include "soc/hp_system_struct.h"
|
||||
#include "soc/usb_utmi_struct.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -54,7 +55,6 @@ FORCE_INLINE_ATTR void usb_utmi_ll_enable_bus_clock(bool clk_en)
|
||||
*/
|
||||
FORCE_INLINE_ATTR void usb_utmi_ll_reset_register(void)
|
||||
{
|
||||
//@todo call this function somewhere
|
||||
// Reset the USB_UTMI and USB_DWC_HS
|
||||
LP_AON_CLKRST.hp_usb_clkrst_ctrl1.rst_en_usb_otg20 = 1;
|
||||
LP_AON_CLKRST.hp_usb_clkrst_ctrl1.rst_en_usb_otg20_phy = 1;
|
||||
@ -62,9 +62,20 @@ FORCE_INLINE_ATTR void usb_utmi_ll_reset_register(void)
|
||||
LP_AON_CLKRST.hp_usb_clkrst_ctrl1.rst_en_usb_otg20 = 0;
|
||||
}
|
||||
|
||||
// P_AON_CLKRST.hp_usb_clkrst_ctrlx are shared registers, so this function must be used in an atomic way
|
||||
// P_AON_CLKRST.hp_usb_clkrst_ctrlx is shared register, so this function must be used in an atomic way
|
||||
#define usb_utmi_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; usb_utmi_ll_reset_register(__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Enable precise detection of VBUS
|
||||
*
|
||||
* @param[in] enable Enable/Disable precise detection
|
||||
*/
|
||||
FORCE_INLINE_ATTR void usb_utmi_ll_enable_precise_detection(bool enable)
|
||||
{
|
||||
// Enable VBUS precise detection
|
||||
HP_SYSTEM.sys_usbotg20_ctrl.sys_otg_suspendm = enable;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "soc/lp_system_struct.h"
|
||||
#include "soc/lp_clkrst_struct.h"
|
||||
#include "soc/hp_sys_clkrst_struct.h"
|
||||
#include "soc/hp_system_struct.h" // For HP_SYSTEM domain
|
||||
#include "soc/usb_wrap_struct.h"
|
||||
#include "hal/usb_wrap_types.h"
|
||||
|
||||
@ -263,14 +262,6 @@ FORCE_INLINE_ATTR void usb_wrap_ll_reset_register(void)
|
||||
// P_AON_CLKRST.hp_usb_clkrst_ctrlx are shared registers, so this function must be used in an atomic way
|
||||
#define usb_wrap_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; usb_wrap_ll_reset_register(__VA_ARGS__)
|
||||
|
||||
/* ------------------------------- HP System ------------------------------- */
|
||||
|
||||
FORCE_INLINE_ATTR void usb_wrap_ll_enable_precise_detection(void)
|
||||
{
|
||||
// Enable VBUS precise detection
|
||||
HP_SYSTEM.sys_usbotg20_ctrl.sys_otg_suspendm = 1;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -7,8 +7,8 @@
|
||||
// TODO: Refactor during the IDF-9198
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/usb_dwc_cfg.h"
|
||||
#include "hal/usb_wrap_hal.h"
|
||||
#include "hal/usb_utmi_ll.h"
|
||||
#include "hal/usb_utmi_ll.h" // We don't have usb_utmi_hal yet
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
// TODO: Remove this file when proper support of P4 PHYs is implemented IDF-7323
|
||||
#include "esp_private/usb_phy.h"
|
||||
|
||||
@ -16,13 +16,17 @@ esp_err_t usb_new_phy(const usb_phy_config_t *config, usb_phy_handle_t *handle_r
|
||||
{
|
||||
#if (OTG_HSPHY_INTERFACE != 0)
|
||||
#if CONFIG_IDF_TARGET_ESP32P4
|
||||
PERIPH_RCC_ATOMIC() {
|
||||
usb_utmi_ll_enable_bus_clock(true);
|
||||
usb_utmi_ll_reset_register();
|
||||
}
|
||||
/*
|
||||
Additional setting to solve missing DCONN event on ESP32P4 (IDF-9953).
|
||||
|
||||
Note: On ESP32P4, the HP_SYSTEM_OTG_SUSPENDM is not connected to 1 by hardware.
|
||||
For correct detection of the device detaching, internal signal should be set to 1 by the software.
|
||||
*/
|
||||
usb_wrap_ll_enable_precise_detection();
|
||||
usb_utmi_ll_enable_precise_detection(true);
|
||||
usb_utmi_ll_configure_ls(&USB_UTMI, true);
|
||||
#endif // CONFIG_IDF_TARGET_ESP32P4
|
||||
#endif // (OTG_HSPHY_INTERFACE != 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user