diff --git a/components/esp_hal_pmu/esp32p4/include/hal/ldo_ll.h b/components/esp_hal_pmu/esp32p4/include/hal/ldo_ll.h index a8d8c164836..bcee4858167 100644 --- a/components/esp_hal_pmu/esp32p4/include/hal/ldo_ll.h +++ b/components/esp_hal_pmu/esp32p4/include/hal/ldo_ll.h @@ -21,7 +21,6 @@ extern "C" { #endif -#define LDO_LL_NUM_UNITS 4 // Number of LDO units #define LDO_LL_ADJUSTABLE_CHAN_MASK 0x0F // all the 4 channels are adjustable by setting "mul" and "dref" registers #define LDO_LL_RECOMMEND_MAX_VOLTAGE_MV 2700 @@ -51,7 +50,7 @@ typedef enum { __attribute__((always_inline)) static inline bool ldo_ll_is_valid_ldo_channel(int ldo_chan) { - return (ldo_chan > 0) && (ldo_chan <= LDO_LL_NUM_UNITS); + return (ldo_chan > 0) && (ldo_chan <= 4); } /** @@ -154,7 +153,7 @@ static inline void ldo_ll_voltage_to_dref_mul(int ldo_unit, int voltage_mv, uint __attribute__((always_inline)) static inline void ldo_ll_set_owner(int ldo_unit, ldo_ll_unit_owner_t owner) { - uint8_t index_array[LDO_LL_NUM_UNITS] = {0, 3, 1, 4}; + uint8_t index_array[4] = {0, 3, 1, 4}; /* * force_tieh_sel: * - 0: efuse, i.e. by hardware @@ -185,7 +184,7 @@ static inline void ldo_ll_set_owner(int ldo_unit, ldo_ll_unit_owner_t owner) __attribute__((always_inline)) static inline void ldo_ll_adjust_voltage(int ldo_unit, uint8_t dref, uint8_t mul, bool use_rail_voltage) { - uint8_t index_array[LDO_LL_NUM_UNITS] = {0, 3, 1, 4}; + uint8_t index_array[4] = {0, 3, 1, 4}; /** * tieh: * - 0: Vref * Mul @@ -205,7 +204,7 @@ static inline void ldo_ll_adjust_voltage(int ldo_unit, uint8_t dref, uint8_t mul __attribute__((always_inline)) static inline void ldo_ll_enable(int ldo_unit, bool enable) { - uint8_t index_array[LDO_LL_NUM_UNITS] = {0, 3, 1, 4}; + uint8_t index_array[4] = {0, 3, 1, 4}; if (ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 100) && (ldo_unit == 0)) { // If chip_rev >= v1.0, slp_mem_dbias[3] is used to control the volt output of VO1. PMU.hp_sys[PMU_MODE_HP_ACTIVE].regulator0.xpd_0p1a = (enable ? 8 : 0); @@ -222,7 +221,7 @@ static inline void ldo_ll_enable(int ldo_unit, bool enable) __attribute__((always_inline)) static inline void ldo_ll_enable_power_on_delay(int ldo_unit, bool enable) { - uint8_t index_array[LDO_LL_NUM_UNITS] = {0, 3, 1, 4}; + uint8_t index_array[4] = {0, 3, 1, 4}; PMU.ext_ldo[index_array[ldo_unit]].pmu_ext_ldo.tieh_pos_en = enable; } @@ -235,7 +234,7 @@ static inline void ldo_ll_enable_power_on_delay(int ldo_unit, bool enable) __attribute__((always_inline)) static inline void ldo_ll_enable_power_off_delay(int ldo_unit, bool enable) { - uint8_t index_array[LDO_LL_NUM_UNITS] = {0, 3, 1, 4}; + uint8_t index_array[4] = {0, 3, 1, 4}; PMU.ext_ldo[index_array[ldo_unit]].pmu_ext_ldo.tieh_neg_en = enable; } @@ -249,7 +248,7 @@ static inline void ldo_ll_enable_power_off_delay(int ldo_unit, bool enable) __attribute__((always_inline)) static inline void ldo_ll_set_delay_target(int ldo_unit, uint8_t target0, uint8_t target1) { - uint8_t index_array[LDO_LL_NUM_UNITS] = {0, 3, 1, 4}; + uint8_t index_array[4] = {0, 3, 1, 4}; HAL_FORCE_MODIFY_U32_REG_FIELD(PMU.ext_ldo[index_array[ldo_unit]].pmu_ext_ldo, target0, target0); HAL_FORCE_MODIFY_U32_REG_FIELD(PMU.ext_ldo[index_array[ldo_unit]].pmu_ext_ldo, target1, target1); } @@ -263,7 +262,7 @@ static inline void ldo_ll_set_delay_target(int ldo_unit, uint8_t target0, uint8_ __attribute__((always_inline)) static inline void ldo_ll_enable_current_limit(int ldo_unit, bool enable) { - uint8_t index_array[LDO_LL_NUM_UNITS] = {0, 3, 1, 4}; + uint8_t index_array[4] = {0, 3, 1, 4}; PMU.ext_ldo[index_array[ldo_unit]].pmu_ext_ldo_ana.en_cur_lim = enable; } @@ -276,7 +275,7 @@ static inline void ldo_ll_enable_current_limit(int ldo_unit, bool enable) __attribute__((always_inline)) static inline void ldo_ll_enable_ripple_suppression(int ldo_unit, bool enable) { - uint8_t index_array[LDO_LL_NUM_UNITS] = {0, 3, 1, 4}; + uint8_t index_array[4] = {0, 3, 1, 4}; PMU.ext_ldo[index_array[ldo_unit]].pmu_ext_ldo_ana.en_vdet = enable; } diff --git a/components/esp_hal_pmu/esp32s31/include/hal/ldo_ll.h b/components/esp_hal_pmu/esp32s31/include/hal/ldo_ll.h index 1eefc467139..e68f850f21b 100644 --- a/components/esp_hal_pmu/esp32s31/include/hal/ldo_ll.h +++ b/components/esp_hal_pmu/esp32s31/include/hal/ldo_ll.h @@ -16,7 +16,6 @@ extern "C" { #endif -#define LDO_LL_NUM_UNITS 1 // Number of LDO units #define LDO_LL_ADJUSTABLE_CHAN_MASK 0x01 // all the channels are adjustable by setting "mul" and "dref" registers #define LDO_LL_RECOMMEND_MAX_VOLTAGE_MV 2700 @@ -46,7 +45,7 @@ typedef enum { __attribute__((always_inline)) static inline bool ldo_ll_is_valid_ldo_channel(int ldo_chan) { - return (ldo_chan > 0) && (ldo_chan <= LDO_LL_NUM_UNITS); + return (ldo_chan > 0) && (ldo_chan <= 1); } /** diff --git a/components/esp_hw_support/ldo/esp_ldo_regulator.c b/components/esp_hw_support/ldo/esp_ldo_regulator.c index f8be42b2bfe..de02a7b88dd 100644 --- a/components/esp_hw_support/ldo/esp_ldo_regulator.c +++ b/components/esp_hw_support/ldo/esp_ldo_regulator.c @@ -33,8 +33,8 @@ static const uint32_t s_ldo_channel_adjustable_mask = LDO_LL_ADJUSTABLE_CHAN_MAS // Allocate LDO channel memory statically // LDO is a fundamental module and should be usable even without a heap allocator -static ldo_regulator_channel_t s_ldo_channels[LDO_LL_NUM_UNITS] = { - [0 ... LDO_LL_NUM_UNITS - 1] = { +static ldo_regulator_channel_t s_ldo_channels[SOC_GP_LDO_NUM_UNITS] = { + [0 ... SOC_GP_LDO_NUM_UNITS - 1] = { .chan_id = -1, .voltage_mv = 0, .ref_cnt = 0, @@ -178,7 +178,7 @@ esp_err_t esp_ldo_dump(FILE *stream) char line[100]; fprintf(stream, "ESP LDO Channel State:\n"); fprintf(stream, "%-5s %-5s %-10s %-12s %-5s\n", "Index", "ID", "ref_cnt", "voltage_mv", "adjustable"); - for (int i = 0; i < LDO_LL_NUM_UNITS; i++) { + for (int i = 0; i < SOC_GP_LDO_NUM_UNITS; i++) { char *buf = line; size_t len = sizeof(line); memset(line, 0x0, len); diff --git a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in index 9770b1a1104..a98278031d0 100644 --- a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in @@ -1079,6 +1079,10 @@ config SOC_LEDC_SUPPORT_ETM bool default y +config SOC_GP_LDO_NUM_UNITS + int + default 4 + config SOC_MMU_PERIPH_NUM int default 2 diff --git a/components/soc/esp32p4/include/soc/soc_caps.h b/components/soc/esp32p4/include/soc/soc_caps.h index 9f5caac5a3c..0615d3e32ea 100644 --- a/components/soc/esp32p4/include/soc/soc_caps.h +++ b/components/soc/esp32p4/include/soc/soc_caps.h @@ -111,7 +111,7 @@ #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_TOUCH_SENSOR_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 -#define SOC_GP_LDO_SUPPORTED 1 // General purpose LDO +#define SOC_GP_LDO_SUPPORTED 1 #define SOC_PPA_SUPPORTED 1 #define SOC_LIGHT_SLEEP_SUPPORTED 1 #define SOC_DEEP_SLEEP_SUPPORTED 1 @@ -394,6 +394,9 @@ #define SOC_LEDC_SUPPORT_SLEEP_RETENTION (1) #define SOC_LEDC_SUPPORT_ETM (1) +/*-------------------------- LDO CAPS ----------------------------------------*/ +#define SOC_GP_LDO_NUM_UNITS 4 // Number of general purpose LDO units + /*-------------------------- MMU CAPS ----------------------------------------*/ #define SOC_MMU_PERIPH_NUM (2U) #define SOC_MMU_LINEAR_ADDRESS_REGION_NUM (2U) diff --git a/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in index a8bf900c0ff..d036c1d55ff 100644 --- a/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in @@ -719,6 +719,10 @@ config SOC_LEDC_SUPPORT_ETM bool default y +config SOC_GP_LDO_NUM_UNITS + int + default 1 + config SOC_RMT_MEM_WORDS_PER_CHANNEL int default 48 diff --git a/components/soc/esp32s31/include/soc/soc_caps.h b/components/soc/esp32s31/include/soc/soc_caps.h index 8907cf8458b..a86accff6bd 100644 --- a/components/soc/esp32s31/include/soc/soc_caps.h +++ b/components/soc/esp32s31/include/soc/soc_caps.h @@ -276,6 +276,9 @@ #define SOC_LEDC_SUPPORT_SLEEP_RETENTION (1) #define SOC_LEDC_SUPPORT_ETM (1) +/*-------------------------- LDO CAPS ----------------------------------------*/ +#define SOC_GP_LDO_NUM_UNITS 1U // Number of general purpose LDO units + /*--------------------------- RMT CAPS ---------------------------------------*/ #define SOC_RMT_MEM_WORDS_PER_CHANNEL 48 /*!< Each channel owns 48 words memory (1 word = 4 Bytes) */ #define SOC_RMT_SUPPORT_RX_PINGPONG 1 /*!< Support Ping-Pong mode on RX path */ diff --git a/docs/en/api-reference/peripherals/ldo_regulator.rst b/docs/en/api-reference/peripherals/ldo_regulator.rst index 3734c91894c..2df967e9fa3 100644 --- a/docs/en/api-reference/peripherals/ldo_regulator.rst +++ b/docs/en/api-reference/peripherals/ldo_regulator.rst @@ -3,12 +3,10 @@ Low Dropout Voltage Regulator (LDO) :link_to_translation:`zh_CN:[中文]` -{IDF_TARGET_LDO_CHANNELS:default="unknown", esp32p4="4"} - Introduction ------------ -The {IDF_TARGET_NAME} chip internally integrates {IDF_TARGET_LDO_CHANNELS} channels of low-dropout voltage regulators (LDOs). Each channel's voltage is programmable. In our hardware reference designs, some of these LDO outputs are typically used to power the internal Flash and PSRAM, while the remaining LDOs can be used to supply external devices. +The {IDF_TARGET_NAME} chip internally integrates {IDF_TARGET_SOC_GP_LDO_NUM_UNITS} channels of low-dropout voltage regulators (LDOs). Each channel's voltage is programmable. In our hardware reference designs, some of these LDO outputs are typically used to power the internal Flash and PSRAM, while the remaining LDOs can be used to supply external devices. .. note:: diff --git a/docs/zh_CN/api-reference/peripherals/ldo_regulator.rst b/docs/zh_CN/api-reference/peripherals/ldo_regulator.rst index ab8634e5c21..2d5b706e440 100644 --- a/docs/zh_CN/api-reference/peripherals/ldo_regulator.rst +++ b/docs/zh_CN/api-reference/peripherals/ldo_regulator.rst @@ -3,12 +3,10 @@ :link_to_translation:`en:[English]` -{IDF_TARGET_LDO_CHANNELS:default="unknown", esp32p4="4"} - 简介 ---- -{IDF_TARGET_NAME} 芯片内部集成了 {IDF_TARGET_LDO_CHANNELS} 路低压差线性稳压器 (LDO),每路的电压都是可编程调节的。在硬件的参考设计中,我们通常会将其中一些的 LDO 输出作为内部 Flash 和 PSRAM 的电源,剩余的一些 LDO 可以用于给外部设备供电。 +{IDF_TARGET_NAME} 芯片内部集成了 {IDF_TARGET_SOC_GP_LDO_NUM_UNITS} 路低压差线性稳压器 (LDO),每路的电压都是可编程调节的。在硬件的参考设计中,我们通常会将其中一些的 LDO 输出作为内部 Flash 和 PSRAM 的电源,剩余的一些 LDO 可以用于给外部设备供电。 .. note::