mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 12:14:32 +02:00
Power Management: add XTAL power domain to control whether external 40MHz xtal is powered down during sleep
This commit is contained in:
@@ -137,8 +137,8 @@ void rtc_sleep_init(rtc_sleep_config_t cfg)
|
|||||||
REG_SET_FIELD(RTC_CNTL_SLP_REJECT_CONF_REG, RTC_CNTL_DEEP_SLP_REJECT_EN, cfg.deep_slp_reject);
|
REG_SET_FIELD(RTC_CNTL_SLP_REJECT_CONF_REG, RTC_CNTL_DEEP_SLP_REJECT_EN, cfg.deep_slp_reject);
|
||||||
REG_SET_FIELD(RTC_CNTL_SLP_REJECT_CONF_REG, RTC_CNTL_LIGHT_SLP_REJECT_EN, cfg.light_slp_reject);
|
REG_SET_FIELD(RTC_CNTL_SLP_REJECT_CONF_REG, RTC_CNTL_LIGHT_SLP_REJECT_EN, cfg.light_slp_reject);
|
||||||
|
|
||||||
/* gating XTAL clock */
|
REG_SET_FIELD(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_XTL_FORCE_PU, cfg.xtal_fpu);
|
||||||
REG_CLR_BIT(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_XTAL_GLOBAL_FORCE_NOGATING);
|
REG_SET_FIELD(RTC_CNTL_CLK_CONF_REG, RTC_CNTL_XTAL_GLOBAL_FORCE_NOGATING, cfg.xtal_fpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rtc_sleep_low_init(uint32_t slowclk_period)
|
void rtc_sleep_low_init(uint32_t slowclk_period)
|
||||||
|
@@ -136,6 +136,8 @@ void rtc_sleep_init(rtc_sleep_config_t cfg)
|
|||||||
|
|
||||||
REG_SET_FIELD(RTC_CNTL_SLP_REJECT_CONF_REG, RTC_CNTL_DEEP_SLP_REJECT_EN, cfg.deep_slp_reject);
|
REG_SET_FIELD(RTC_CNTL_SLP_REJECT_CONF_REG, RTC_CNTL_DEEP_SLP_REJECT_EN, cfg.deep_slp_reject);
|
||||||
REG_SET_FIELD(RTC_CNTL_SLP_REJECT_CONF_REG, RTC_CNTL_LIGHT_SLP_REJECT_EN, cfg.light_slp_reject);
|
REG_SET_FIELD(RTC_CNTL_SLP_REJECT_CONF_REG, RTC_CNTL_LIGHT_SLP_REJECT_EN, cfg.light_slp_reject);
|
||||||
|
|
||||||
|
REG_SET_FIELD(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_XTL_FORCE_PU, cfg.xtal_fpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rtc_sleep_low_init(uint32_t slowclk_period)
|
void rtc_sleep_low_init(uint32_t slowclk_period)
|
||||||
|
@@ -1320,9 +1320,9 @@ static uint32_t get_power_down_flags(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (s_config.pd_options[ESP_PD_DOMAIN_XTAL] == ESP_PD_OPTION_AUTO) {
|
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||||
s_config.pd_options[ESP_PD_DOMAIN_XTAL] = ESP_PD_OPTION_OFF;
|
s_config.pd_options[ESP_PD_DOMAIN_XTAL] = ESP_PD_OPTION_OFF;
|
||||||
}
|
#endif
|
||||||
|
|
||||||
const char *option_str[] = {"OFF", "ON", "AUTO(OFF)" /* Auto works as OFF */};
|
const char *option_str[] = {"OFF", "ON", "AUTO(OFF)" /* Auto works as OFF */};
|
||||||
ESP_LOGD(TAG, "RTC_PERIPH: %s", option_str[s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH]]);
|
ESP_LOGD(TAG, "RTC_PERIPH: %s", option_str[s_config.pd_options[ESP_PD_DOMAIN_RTC_PERIPH]]);
|
||||||
@@ -1353,10 +1353,9 @@ static uint32_t get_power_down_flags(void)
|
|||||||
if (s_config.pd_options[ESP_PD_DOMAIN_RTC8M] != ESP_PD_OPTION_ON) {
|
if (s_config.pd_options[ESP_PD_DOMAIN_RTC8M] != ESP_PD_OPTION_ON) {
|
||||||
pd_flags |= RTC_SLEEP_PD_INT_8M;
|
pd_flags |= RTC_SLEEP_PD_INT_8M;
|
||||||
}
|
}
|
||||||
|
if (s_config.pd_options[ESP_PD_DOMAIN_XTAL] != ESP_PD_OPTION_ON) {
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
|
||||||
pd_flags |= RTC_SLEEP_PD_XTAL;
|
pd_flags |= RTC_SLEEP_PD_XTAL;
|
||||||
#endif
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VDD_SDIO power domain shall be kept on during the light sleep
|
* VDD_SDIO power domain shall be kept on during the light sleep
|
||||||
|
@@ -649,6 +649,7 @@ typedef struct {
|
|||||||
uint32_t rtc_dbias_wak : 5; //!< set bias for RTC domain, in active mode
|
uint32_t rtc_dbias_wak : 5; //!< set bias for RTC domain, in active mode
|
||||||
uint32_t rtc_dbias_slp : 5; //!< set bias for RTC domain, in sleep mode
|
uint32_t rtc_dbias_slp : 5; //!< set bias for RTC domain, in sleep mode
|
||||||
uint32_t vddsdio_pd_en : 1; //!< power down VDDSDIO regulator
|
uint32_t vddsdio_pd_en : 1; //!< power down VDDSDIO regulator
|
||||||
|
uint32_t xtal_fpu : 1; //!< keep main XTAL powered up in sleep
|
||||||
uint32_t deep_slp_reject : 1;
|
uint32_t deep_slp_reject : 1;
|
||||||
uint32_t light_slp_reject : 1;
|
uint32_t light_slp_reject : 1;
|
||||||
} rtc_sleep_config_t;
|
} rtc_sleep_config_t;
|
||||||
@@ -684,6 +685,7 @@ typedef struct {
|
|||||||
: !((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? RTC_CNTL_DBIAS_1V10 \
|
: !((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? RTC_CNTL_DBIAS_1V10 \
|
||||||
: RTC_CNTL_DBIAS_SLP, \
|
: RTC_CNTL_DBIAS_SLP, \
|
||||||
.vddsdio_pd_en = ((sleep_flags) & RTC_SLEEP_PD_VDDSDIO) ? 1 : 0, \
|
.vddsdio_pd_en = ((sleep_flags) & RTC_SLEEP_PD_VDDSDIO) ? 1 : 0, \
|
||||||
|
.xtal_fpu = is_dslp(sleep_flags) ? 0 : ((sleep_flags) & RTC_SLEEP_PD_XTAL) ? 0 : 1, \
|
||||||
.deep_slp_reject = 1, \
|
.deep_slp_reject = 1, \
|
||||||
.light_slp_reject = 1 \
|
.light_slp_reject = 1 \
|
||||||
};
|
};
|
||||||
@@ -699,6 +701,7 @@ typedef struct {
|
|||||||
#define RTC_SLEEP_PD_CPU BIT(8) //!< Power down CPU when in lightsleep, but not restart
|
#define RTC_SLEEP_PD_CPU BIT(8) //!< Power down CPU when in lightsleep, but not restart
|
||||||
#define RTC_SLEEP_PD_DIG_PERIPH BIT(9) //!< Power down DIG peripherals
|
#define RTC_SLEEP_PD_DIG_PERIPH BIT(9) //!< Power down DIG peripherals
|
||||||
#define RTC_SLEEP_PD_INT_8M BIT(10) //!< Power down Internal 8M oscillator
|
#define RTC_SLEEP_PD_INT_8M BIT(10) //!< Power down Internal 8M oscillator
|
||||||
|
#define RTC_SLEEP_PD_XTAL BIT(11) //!< Power down main XTAL
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prepare the chip to enter sleep mode
|
* @brief Prepare the chip to enter sleep mode
|
||||||
|
@@ -663,6 +663,7 @@ typedef struct {
|
|||||||
uint32_t rtc_dbias_wak : 3; //!< set bias for RTC domain, in active mode
|
uint32_t rtc_dbias_wak : 3; //!< set bias for RTC domain, in active mode
|
||||||
uint32_t rtc_dbias_slp : 3; //!< set bias for RTC domain, in sleep mode
|
uint32_t rtc_dbias_slp : 3; //!< set bias for RTC domain, in sleep mode
|
||||||
uint32_t vddsdio_pd_en : 1; //!< power down VDDSDIO regulator
|
uint32_t vddsdio_pd_en : 1; //!< power down VDDSDIO regulator
|
||||||
|
uint32_t xtal_fpu : 1; //!< keep main XTAL powered up in sleep
|
||||||
uint32_t deep_slp_reject : 1;
|
uint32_t deep_slp_reject : 1;
|
||||||
uint32_t light_slp_reject : 1;
|
uint32_t light_slp_reject : 1;
|
||||||
} rtc_sleep_config_t;
|
} rtc_sleep_config_t;
|
||||||
@@ -695,6 +696,7 @@ typedef struct {
|
|||||||
: !((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? RTC_CNTL_DBIAS_1V10 \
|
: !((sleep_flags) & RTC_SLEEP_PD_INT_8M) ? RTC_CNTL_DBIAS_1V10 \
|
||||||
: RTC_CNTL_DBIAS_1V00, \
|
: RTC_CNTL_DBIAS_1V00, \
|
||||||
.vddsdio_pd_en = ((sleep_flags) & RTC_SLEEP_PD_VDDSDIO) ? 1 : 0, \
|
.vddsdio_pd_en = ((sleep_flags) & RTC_SLEEP_PD_VDDSDIO) ? 1 : 0, \
|
||||||
|
.xtal_fpu = is_dslp(sleep_flags) ? 0 : ((sleep_flags) & RTC_SLEEP_PD_XTAL) ? 0 : 1, \
|
||||||
.deep_slp_reject = 1, \
|
.deep_slp_reject = 1, \
|
||||||
.light_slp_reject = 1 \
|
.light_slp_reject = 1 \
|
||||||
};
|
};
|
||||||
@@ -707,6 +709,7 @@ typedef struct {
|
|||||||
#define RTC_SLEEP_PD_VDDSDIO BIT(5) //!< Power down VDDSDIO regulator
|
#define RTC_SLEEP_PD_VDDSDIO BIT(5) //!< Power down VDDSDIO regulator
|
||||||
#define RTC_SLEEP_PD_WIFI BIT(6)
|
#define RTC_SLEEP_PD_WIFI BIT(6)
|
||||||
#define RTC_SLEEP_PD_INT_8M BIT(7) //!< Power down Internal 8M oscillator
|
#define RTC_SLEEP_PD_INT_8M BIT(7) //!< Power down Internal 8M oscillator
|
||||||
|
#define RTC_SLEEP_PD_XTAL BIT(8) //!< Power down main XTAL
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prepare the chip to enter sleep mode
|
* @brief Prepare the chip to enter sleep mode
|
||||||
|
@@ -673,6 +673,7 @@ typedef struct {
|
|||||||
#define RTC_SLEEP_PD_VDDSDIO BIT(5) //!< Power down VDDSDIO regulator
|
#define RTC_SLEEP_PD_VDDSDIO BIT(5) //!< Power down VDDSDIO regulator
|
||||||
#define RTC_SLEEP_PD_WIFI BIT(6)
|
#define RTC_SLEEP_PD_WIFI BIT(6)
|
||||||
#define RTC_SLEEP_PD_INT_8M BIT(10) //!< Power down Internal 8M oscillator
|
#define RTC_SLEEP_PD_INT_8M BIT(10) //!< Power down Internal 8M oscillator
|
||||||
|
#define RTC_SLEEP_PD_XTAL BIT(11) //!< Power down main XTAL
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Prepare the chip to enter sleep mode
|
* @brief Prepare the chip to enter sleep mode
|
||||||
|
Reference in New Issue
Block a user