feat(ldo): add config to let hardware control the ldo output

If LDO1 is used by spi flash, then we recommend to give the ownership to
the hardware. Software just read the parameters from the efuse and set
to PMU.
This commit is contained in:
morris
2024-08-07 19:09:49 +08:00
parent 11831cc0db
commit 631e15c6eb
6 changed files with 206 additions and 92 deletions

View File

@@ -437,15 +437,18 @@ esp_err_t esp_flash_app_init(void)
// Acquire the LDO channel used by the SPI NOR flash
// in case the LDO voltage is changed by other users
#if defined(CONFIG_ESP_LDO_CHAN_SPI_NOR_FLASH_DOMAIN) && CONFIG_ESP_LDO_CHAN_SPI_NOR_FLASH_DOMAIN != -1
#if CONFIG_ESP_LDO_RESERVE_SPI_NOR_FLASH
static esp_ldo_channel_handle_t s_ldo_chan = NULL;
esp_ldo_channel_config_t ldo_config = {
.chan_id = CONFIG_ESP_LDO_CHAN_SPI_NOR_FLASH_DOMAIN,
.voltage_mv = CONFIG_ESP_LDO_VOLTAGE_SPI_NOR_FLASH_DOMAIN,
.flags = {
.owned_by_hw = true, // LDO output is totally controlled by hardware
},
};
err = esp_ldo_acquire_channel(&ldo_config, &s_ldo_chan);
if (err != ESP_OK) return err;
#endif
#endif // CONFIG_ESP_LDO_RESERVE_SPI_NOR_FLASH
spi_flash_init_lock();
spi_flash_guard_set(&g_flash_guard_default_ops);