light sleep: add i/d-cache tagmem retention support for esp32s3

This commit is contained in:
Li Shuai
2021-08-20 20:33:33 +08:00
parent 03746de96f
commit ccf1a9a1fc
7 changed files with 312 additions and 9 deletions

View File

@@ -41,6 +41,10 @@ void * rtc_cntl_hal_dma_link_init(void *elem, void *buff, int size, void *next)
#if SOC_PM_SUPPORT_CPU_PD
#define DEFAULT_RETENTION_WAIT_CYCLES (0x7f)
#define DEFAULT_RETENTION_CLKOFF_WAIT_CYCLES (0xf)
#define DEFAULT_RETENTION_DONE_WAIT_CYCLES (0x7)
void rtc_cntl_hal_enable_cpu_retention(void *addr)
{
rtc_cntl_sleep_retent_t *retent = (rtc_cntl_sleep_retent_t *)addr;
@@ -57,6 +61,11 @@ void rtc_cntl_hal_enable_cpu_retention(void *addr)
pbuf->cfg[3] = 0xfffe0000;
rtc_cntl_ll_set_cpu_retention_link_addr((uint32_t)plink);
rtc_cntl_ll_config_cpu_retention_timing(
DEFAULT_RETENTION_WAIT_CYCLES,
DEFAULT_RETENTION_CLKOFF_WAIT_CYCLES,
DEFAULT_RETENTION_DONE_WAIT_CYCLES
);
rtc_cntl_ll_enable_cpu_retention_clock();
rtc_cntl_ll_enable_cpu_retention();
}
@@ -69,14 +78,70 @@ void IRAM_ATTR rtc_cntl_hal_disable_cpu_retention(void *addr)
if (addr) {
if (retent->cpu_pd_mem) {
/* TODO: I/d-cache tagmem retention has not been implemented yet,
* so after the system wakes up, all the contents of i/d-cache need
* to be invalidated. */
/* I/d-cache tagmem retention has not been included or not
* been enabled, after the system wakes up, all the contents
* of i/d-cache need to be invalidated. */
#if SOC_PM_SUPPORT_TAGMEM_PD
if (!retent->tagmem.icache.enable) {
Cache_Invalidate_ICache_All();
}
if (!retent->tagmem.dcache.enable) {
Cache_Invalidate_DCache_All();
}
#else
Cache_Invalidate_ICache_All();
Cache_Invalidate_DCache_All();
#endif // SOC_PM_SUPPORT_TAGMEM_PD
rtc_cntl_ll_disable_cpu_retention();
}
}
}
#endif // SOC_PM_SUPPORT_CPU_PD
#if SOC_PM_SUPPORT_TAGMEM_PD
void rtc_cntl_hal_enable_tagmem_retention(void *addr)
{
rtc_cntl_sleep_retent_t *retent = (rtc_cntl_sleep_retent_t *)addr;
if (addr) {
if (retent->tagmem.link_addr) {
rtc_cntl_ll_set_tagmem_retention_link_addr((uint32_t)(retent->tagmem.link_addr));
rtc_cntl_ll_enable_tagmem_retention();
if (retent->tagmem.icache.enable) {
rtc_cntl_ll_enable_icache_tagmem_retention(
retent->tagmem.icache.start_point,
retent->tagmem.icache.vld_size,
retent->tagmem.icache.size
);
}
if (retent->tagmem.dcache.enable) {
rtc_cntl_ll_enable_dcache_tagmem_retention(
retent->tagmem.dcache.start_point,
retent->tagmem.dcache.vld_size,
retent->tagmem.dcache.size
);
}
}
}
}
void IRAM_ATTR rtc_cntl_hal_disable_tagmem_retention(void *addr)
{
rtc_cntl_sleep_retent_t *retent = (rtc_cntl_sleep_retent_t *)addr;
if (addr) {
if (retent->tagmem.link_addr) {
rtc_cntl_ll_disable_tagmem_retention();
if (retent->tagmem.icache.enable) {
rtc_cntl_ll_disable_icache_tagmem_retention();
}
if (retent->tagmem.dcache.enable) {
rtc_cntl_ll_disable_dcache_tagmem_retention();
}
}
}
}
#endif // SOC_PM_SUPPORT_TAGMEM_PD