system/sleep: further fix spi flash/ram current leakage
This commit is contained in:
committed by
Jiang Jiang Jian
parent
3c2c9206dd
commit
66395a5c00
@@ -24,13 +24,15 @@ menu "Hardware Settings"
|
||||
config ESP_SLEEP_POWER_DOWN_FLASH
|
||||
bool "Power down flash in light sleep when there is no SPIRAM"
|
||||
depends on !SPIRAM
|
||||
default y
|
||||
default n
|
||||
help
|
||||
If enabled, chip will try to power down flash as part of esp_light_sleep_start(), which costs
|
||||
more time when chip wakes up. Can only be enabled if there is no SPIRAM configured.
|
||||
This option will in fact consider VDD_SDIO auto power value (ESP_PD_OPTION_AUTO) as OFF. Also, it is
|
||||
possible to force a power domain to stay ON during light sleep by using esp_sleep_pd_config()
|
||||
function.
|
||||
|
||||
This option will power down flash under a strict but relatively safe condition. Also, it is possible to
|
||||
power down flash under a relaxed condition by using esp_sleep_pd_config() to set ESP_PD_DOMAIN_VDDSDIO
|
||||
to ESP_PD_OPTION_OFF. It should be noted that there is a risk in powering down flash, you can refer
|
||||
`ESP-IDF Programming Guide/API Reference/System API/Sleep Modes/Power-down of Flash` for more details.
|
||||
|
||||
config ESP_SLEEP_RTC_BUS_ISO_WORKAROUND
|
||||
bool
|
||||
@@ -58,6 +60,7 @@ menu "Hardware Settings"
|
||||
config ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND
|
||||
bool "PSRAM leakage current workaround in light sleep"
|
||||
depends on SPIRAM
|
||||
default y
|
||||
help
|
||||
When the CS pin of SPIRAM is not pulled up, the sleep current will
|
||||
increase during light sleep. If the CS pin of SPIRAM has an external
|
||||
@@ -66,12 +69,22 @@ menu "Hardware Settings"
|
||||
|
||||
config ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND
|
||||
bool "Flash leakage current workaround in light sleep"
|
||||
default y
|
||||
help
|
||||
When the CS pin of Flash is not pulled up, the sleep current will
|
||||
increase during light sleep. If the CS pin of Flash has an external
|
||||
pull-up, you do not need to select this option, otherwise, you
|
||||
should enable this option.
|
||||
|
||||
config ESP_SLEEP_MSPI_NEED_ALL_IO_PU
|
||||
bool "All pins of mspi need pull up"
|
||||
depends on ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND || ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND
|
||||
default y if IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32S3
|
||||
help
|
||||
To reduce leakage current, some types of SPI Flash/RAM only need to pull up the CS pin
|
||||
during light sleep. But there are also some kinds of SPI Flash/RAM that need to pull up
|
||||
all pins. It depends on the SPI Flash/RAM chip used.
|
||||
|
||||
config ESP_SLEEP_DEEP_SLEEP_WAKEUP_DELAY
|
||||
int "Extra delay in deep sleep wake stub (in us)"
|
||||
depends on IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -19,11 +19,7 @@
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_private/gpio.h"
|
||||
#include "esp_private/sleep_gpio.h"
|
||||
#include "bootloader_common.h"
|
||||
|
||||
#if CONFIG_SPIRAM
|
||||
#include "esp_private/esp_psram_io.h"
|
||||
#endif
|
||||
#include "esp_private/spi_flash_os.h"
|
||||
|
||||
static const char *TAG = "sleep";
|
||||
|
||||
@@ -51,24 +47,41 @@ IRAM_ATTR void gpio_sleep_mode_config_unapply(void)
|
||||
|
||||
void esp_sleep_config_gpio_isolate(void)
|
||||
{
|
||||
ESP_LOGI(TAG, "Configure to isolate all GPIO pins in sleep state");
|
||||
ESP_EARLY_LOGI(TAG, "Configure to isolate all GPIO pins in sleep state");
|
||||
for (gpio_num_t gpio_num = GPIO_NUM_0; gpio_num < GPIO_NUM_MAX; gpio_num++) {
|
||||
if (GPIO_IS_VALID_GPIO(gpio_num)) {
|
||||
gpio_sleep_set_direction(gpio_num, GPIO_MODE_DISABLE);
|
||||
gpio_sleep_set_pull_mode(gpio_num, GPIO_FLOATING);
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND && CONFIG_SPIRAM
|
||||
gpio_sleep_set_pull_mode(esp_psram_io_get_cs_io(), GPIO_PULLUP_ONLY);
|
||||
#endif
|
||||
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_CS1), GPIO_PULLUP_ONLY);
|
||||
#endif // CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND && CONFIG_SPIRAM
|
||||
|
||||
#if CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND
|
||||
gpio_sleep_set_pull_mode(bootloader_flash_get_cs_io(), GPIO_PULLUP_ONLY);
|
||||
#endif
|
||||
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_CS0), GPIO_PULLUP_ONLY);
|
||||
#endif // CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND
|
||||
|
||||
#if CONFIG_ESP_SLEEP_MSPI_NEED_ALL_IO_PU
|
||||
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_CLK), GPIO_PULLUP_ONLY);
|
||||
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_Q), GPIO_PULLUP_ONLY);
|
||||
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_D), GPIO_PULLUP_ONLY);
|
||||
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_HD), GPIO_PULLUP_ONLY);
|
||||
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_WP), GPIO_PULLUP_ONLY);
|
||||
#if CONFIG_SPIRAM_MODE_OCT || CONFIG_ESPTOOLPY_FLASHMODE_OPI
|
||||
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_DQS), GPIO_PULLUP_ONLY);
|
||||
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_D4), GPIO_PULLUP_ONLY);
|
||||
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_D5), GPIO_PULLUP_ONLY);
|
||||
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_D6), GPIO_PULLUP_ONLY);
|
||||
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_D7), GPIO_PULLUP_ONLY);
|
||||
#endif // CONFIG_SPIRAM_MODE_OCT || CONFIG_ESPTOOLPY_FLASHMODE_OPI
|
||||
#endif // CONFIG_ESP_SLEEP_MSPI_NEED_ALL_IO_PU
|
||||
}
|
||||
|
||||
void esp_sleep_enable_gpio_switch(bool enable)
|
||||
{
|
||||
ESP_LOGI(TAG, "%s automatic switching of GPIO sleep configuration", enable ? "Enable" : "Disable");
|
||||
ESP_EARLY_LOGI(TAG, "%s automatic switching of GPIO sleep configuration", enable ? "Enable" : "Disable");
|
||||
for (gpio_num_t gpio_num = GPIO_NUM_0; gpio_num < GPIO_NUM_MAX; gpio_num++) {
|
||||
if (GPIO_IS_VALID_GPIO(gpio_num)) {
|
||||
if (enable) {
|
||||
|
||||
Reference in New Issue
Block a user