feat(ldo): support s31 psram sdmmc power domain

Move S31 PSRAM/SDMMC power setup onto the common LDO path so shared users can control the domain consistently.
This commit is contained in:
armando
2026-05-21 09:09:14 +08:00
parent 09ff879535
commit 6d12e30433
12 changed files with 118 additions and 104 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -87,6 +87,7 @@ esp_err_t esp_ldo_acquire_channel(const esp_ldo_channel_config_t *config, esp_ld
uint8_t dref = 0;
uint8_t mul = 0;
bool use_rail_voltage = false;
ldo_ll_enable_current_limit(unit_id, true);
// calculate the dref and mul
ldo_ll_voltage_to_dref_mul(unit_id, config->voltage_mv, &dref, &mul, &use_rail_voltage);
ldo_ll_adjust_voltage(unit_id, dref, mul, use_rail_voltage);
@@ -95,6 +96,7 @@ esp_err_t esp_ldo_acquire_channel(const esp_ldo_channel_config_t *config, esp_ld
// suppress voltage ripple
ldo_ll_enable_ripple_suppression(unit_id, true);
ldo_ll_enable(unit_id, true);
ldo_ll_enable_current_limit(unit_id, false);
}
// update the channel attributes
channel->ref_cnt++;
@@ -146,7 +148,9 @@ esp_err_t esp_ldo_release_channel(esp_ldo_channel_handle_t chan)
esp_err_t esp_ldo_channel_adjust_voltage(esp_ldo_channel_handle_t chan, int voltage_mv)
{
ESP_RETURN_ON_FALSE(chan, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
ESP_RETURN_ON_FALSE(chan->flags.adjustable, ESP_ERR_NOT_SUPPORTED, TAG, "LDO is not adjustable");
if (chan->voltage_mv != voltage_mv) {
ESP_RETURN_ON_FALSE(chan->flags.adjustable, ESP_ERR_NOT_SUPPORTED, TAG, "LDO is not adjustable");
}
// check if the target voltage is within the recommended range
if (!((voltage_mv == LDO_LL_RAIL_VOLTAGE_MV) ||
(voltage_mv >= LDO_LL_RECOMMEND_MIN_VOLTAGE_MV && voltage_mv <= LDO_LL_RECOMMEND_MAX_VOLTAGE_MV))) {
@@ -0,0 +1,34 @@
menu "LDO Regulator Configurations"
depends on SOC_GP_LDO_SUPPORTED
config ESP_LDO_RESERVE_PSRAM
bool "Reserve one LDO regulator channel for PSRAM (READ HELP)"
default y
help
The LDO channel can be used to power the PSRAM chip.
If the PSRAM chip is not powered by ESP internal LDO, you can disable this option.
Then you will free up one LDO channel for other general purpose.
config ESP_LDO_CHAN_PSRAM_DOMAIN
int "LDO regulator channel that used to power PSRAM and MPLL (READ HELP)"
depends on ESP_LDO_RESERVE_PSRAM
default 1
range 1 1
help
Select which LDO channel to connect to the PSRAM chip.
choice ESP_LDO_VOLTAGE_PSRAM_DOMAIN
prompt "PSRAM power domain voltage"
depends on ESP_LDO_RESERVE_PSRAM
default ESP_LDO_VOLTAGE_PSRAM_1800_MV
help
Select the voltage used by the PSRAM power domain.
config ESP_LDO_VOLTAGE_PSRAM_1800_MV
bool "1.8V"
endchoice
config ESP_LDO_VOLTAGE_PSRAM_DOMAIN
int
default 1800 if ESP_LDO_VOLTAGE_PSRAM_1800_MV
endmenu
@@ -10,7 +10,9 @@ if(CONFIG_SOC_RNG_SUPPORTED)
list(APPEND srcs "test_random.c")
endif()
if(CONFIG_SOC_GP_LDO_SUPPORTED)
if(CONFIG_SOC_GP_LDO_SUPPORTED AND NOT CONFIG_IDF_TARGET_ESP32S31)
# on s31 ldo is general purpose (and also for psram), but runners all have psram
# so we don't run ldo test on s31 to avoid breaking psram
list(APPEND srcs "test_ldo.c")
endif()