feat(esp_hw_support): set USB2.0 phy to suspend mode at startup for active power saving

This commit is contained in:
wuzhenghui
2026-01-30 15:30:58 +08:00
parent fc9c0984b1
commit 5981b0ea4e
2 changed files with 26 additions and 4 deletions
+15
View File
@@ -109,6 +109,21 @@ static void set_defaults(usb_dwc_hal_context_t *hal)
hbstlen = 1; //Set AHB burst to INCR to workaround hardware errata
}
#endif // SOC_IS(ESP32S2)
#if SOC_IS(ESP32P4)
/*
* ESP32P4-specific initialization: Clear USB PHY suspend state set during system boot.
*
* During system initialization (see clk_gate_ll.h:periph_ll_clk_gate_set_default), the USB PHY
* is forced into suspend mode before disabling clocks to prevent USB leakage current and ensure
* proper power management.
*
* When initializing the USB DWC HAL, we need to restore the USB PHY to normal operation by:
* 1. Clearing GOTGCTL.BvalidOvEn (disable override, allow hardware to detect session validity)
* 2. Clearing PCGCCTL.StopPclk (resume PHY clock for normal operation)
*/
usb_dwc_ll_enable_bvalid_override(hal->dev, false);
usb_dwc_ll_set_stoppclk(hal->dev, false);
#endif // SOC_IS(ESP32P4)
usb_dwc_ll_gahbcfg_set_hbstlen(hal->dev, hbstlen); //Set AHB burst mode
//GUSBCFG register
usb_dwc_ll_gusbcfg_dis_hnp_cap(hal->dev); //Disable HNP