Merge branch 'fix/fix_mpll_enable_order' into 'master'

fix(esp_hw_support): fix esp32s31 mpll initialization

Closes IDF-15820

See merge request espressif/esp-idf!49927
This commit is contained in:
Wu Zheng Hui
2026-07-01 16:35:20 +08:00
11 changed files with 33 additions and 21 deletions
@@ -15,6 +15,7 @@
#include "hal/ldo_ll.h"
#include "esp_ldo_regulator.h"
#include "esp_private/critical_section.h"
#include "esp_rom_sys.h"
ESP_LOG_ATTR_TAG(TAG, "ldo");
@@ -56,6 +57,7 @@ esp_err_t esp_ldo_acquire_channel(const esp_ldo_channel_config_t *config, esp_ld
bool check_adjustable_constraint_valid = true;
bool check_voltage_constraint_valid = true;
bool ldo_enabled = false;
esp_os_enter_critical(&s_spinlock);
if (config->flags.adjustable) {
// the user wants to adjust it
@@ -97,6 +99,7 @@ esp_err_t esp_ldo_acquire_channel(const esp_ldo_channel_config_t *config, esp_ld
ldo_ll_enable_ripple_suppression(unit_id, true);
ldo_ll_enable(unit_id, true);
ldo_ll_enable_current_limit(unit_id, false);
ldo_enabled = true;
}
// update the channel attributes
channel->ref_cnt++;
@@ -112,6 +115,10 @@ esp_err_t esp_ldo_acquire_channel(const esp_ldo_channel_config_t *config, esp_ld
ESP_RETURN_ON_FALSE(check_adjustable_constraint_valid, ESP_ERR_INVALID_ARG, TAG,
"can't acquire the channel, already in use by others or not adjustable");
if (ldo_enabled && config->voltage_stable_delay_us > 0) {
esp_rom_delay_us(config->voltage_stable_delay_us);
}
if (out_handle) {
*out_handle = channel;
}
@@ -25,6 +25,7 @@ typedef struct ldo_regulator_channel_t *esp_ldo_channel_handle_t;
typedef struct {
int chan_id; /*!< You must set the LDO channel ID according to the datasheet, e.g., set it to 1 for LDO_VO1 */
int voltage_mv; /*!< The voltage value to be set to the LDO channel */
uint32_t voltage_stable_delay_us; /*!< Delay in microseconds after LDO enable, wait for output voltage to stabilize. Set to 0 to skip */
/// Extra flags of a LDO channel
struct ldo_extra_flags {
@@ -63,4 +63,9 @@ menu "LDO Regulator Configurations"
config ESP_LDO_VOLTAGE_PSRAM_DOMAIN
int
default 1800 if ESP_LDO_VOLTAGE_PSRAM_1800_MV
config ESP_LDO_VOLTAGE_STABLE_DELAY_US
int
depends on ESP_LDO_RESERVE_PSRAM
default 0
endmenu
@@ -31,4 +31,9 @@ menu "LDO Regulator Configurations"
config ESP_LDO_VOLTAGE_PSRAM_DOMAIN
int
default 1800 if ESP_LDO_VOLTAGE_PSRAM_1800_MV
config ESP_LDO_VOLTAGE_STABLE_DELAY_US
int
depends on ESP_LDO_RESERVE_PSRAM
default 1000
endmenu
@@ -42,11 +42,11 @@ ESP_HW_LOG_ATTR_TAG(TAG, "pmu_param");
.xpd_cpll_i2c = 1, \
.xpd_bbpll_i2c = 1, \
.xpd_apll_i2c = 0, \
.xpd_mpll_i2c = 1, \
.xpd_mpll_i2c = 0, \
.xpd_cpll = 1, \
.xpd_bbpll = 1, \
.xpd_apll = 0, \
.xpd_mpll = 1, \
.xpd_mpll = 0, \
}, \
.xtal = { \
.xpd_xtal = 1 \
@@ -328,6 +328,7 @@ esp_err_t IRAM_ATTR esp_clk_tree_mpll_acquire(void)
esp_ldo_channel_config_t ldo_mpll_config = {
.chan_id = CONFIG_ESP_LDO_CHAN_PSRAM_DOMAIN,
.voltage_mv = CONFIG_ESP_LDO_VOLTAGE_PSRAM_DOMAIN,
.voltage_stable_delay_us = CONFIG_ESP_LDO_VOLTAGE_STABLE_DELAY_US,
};
ESP_RETURN_ON_ERROR(esp_ldo_acquire_channel(&ldo_mpll_config, &s_ldo_chan), TAG, "acquire internal LDO for MPLL failed");
}