Skip to content

Commit 228e74e

Browse files
committed
feat(esp_hw_support): do esp32p4 l1 cache invalidate by regdma
1 parent f3cc52d commit 228e74e

File tree

4 files changed

+10
-26
lines changed

4 files changed

+10
-26
lines changed

components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_asm.S

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -149,31 +149,6 @@ _rv_core_critical_regs_restore: /* export a strong symbol to jump to here, used
149149
nop
150150

151151
rv_core_critical_regs_restore:
152-
/* Invalidate L1 Cache by Core 0*/
153-
csrr t0, mhartid
154-
bnez t0, start_restore
155-
/* Core 0 is wakeup core, Invalidate L1 Cache here */
156-
/* Invalidate L1 cache is required here!!! */
157-
la t0, CACHE_SYNC_MAP_REG
158-
li t1, CACHE_MAP_L1_CACHE_MASK /* map l1 i/dcache */
159-
sw t1, 0x0(t0) /* set EXTMEM_CACHE_SYNC_MAP_REG bit 4 */
160-
la t2, CACHE_SYNC_ADDR_REG
161-
sw zero, 0x0(t2) /* clear EXTMEM_CACHE_SYNC_ADDR_REG */
162-
la t0, CACHE_SYNC_SIZE_REG
163-
sw zero, 0x0(t0) /* clear EXTMEM_CACHE_SYNC_SIZE_REG */
164-
165-
la t1, CACHE_SYNC_CTRL_REG
166-
lw t2, 0x0(t1)
167-
ori t2, t2, 0x1
168-
sw t2, 0x0(t1)
169-
170-
li t0, 0x10 /* SYNC_DONE bit */
171-
wait_cache_sync_done1:
172-
lw t2, 0x0(t1)
173-
and t2, t0, t2
174-
beqz t2, wait_cache_sync_done1
175-
176-
start_restore:
177152
la t0, rv_core_critical_regs_frame
178153
csrr t1, mhartid
179154
slli t1, t1, 2

components/esp_rom/esp32p4/include/esp32p4/rom/cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ typedef enum {
231231
#define CACHE_MAP_L2_CACHE BIT(5)
232232

233233
#define CACHE_MAP_L1_ICACHE_MASK (CACHE_MAP_L1_ICACHE_0 | CACHE_MAP_L1_ICACHE_1)
234+
#define CACHE_MAP_L1_CACHE_MASK (CACHE_MAP_L1_ICACHE_MASK | CACHE_MAP_L1_DCACHE)
234235
#define CACHE_MAP_MASK (CACHE_MAP_L1_ICACHE_MASK | CACHE_MAP_L1_DCACHE | CACHE_MAP_L2_CACHE)
235236

236237
struct cache_internal_stub_table {

components/soc/esp32p4/include/soc/system_periph_retention.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern const regdma_entries_config_t intr_matrix_regs_retention[INT_MTX_RETENTIO
3232
* This is an internal function of the sleep retention driver, and is not
3333
* useful for external use.
3434
*/
35-
#define CACHE_RETENTION_LINK_LEN 2
35+
#define CACHE_RETENTION_LINK_LEN 8
3636
extern const regdma_entries_config_t cache_regs_retention[CACHE_RETENTION_LINK_LEN];
3737

3838
/**

components/soc/esp32p4/system_retention_periph.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "soc/timer_group_reg.h"
2323
#include "soc/timer_periph.h"
2424
#include "soc/uart_reg.h"
25+
#include "esp32p4/rom/cache.h"
2526

2627
/* Interrupt Matrix Registers Context */
2728
#define N_REGS_INTR_CORE0() (((INTERRUPT_CORE0_CLOCK_GATE_REG - DR_REG_INTERRUPT_CORE0_BASE) / 4) + 1)
@@ -61,6 +62,13 @@ const regdma_entries_config_t cache_regs_retention[] = {
6162
l2_cache_regs_map[2], l2_cache_regs_map[3]), \
6263
.owner = ENTRY(0)
6364
},
65+
// Invalidate L1 Cache
66+
[2] = { .config = REGDMA_LINK_WRITE_INIT(REGDMA_CACHE_LINK(0x02), CACHE_SYNC_ADDR_REG, 0, CACHE_SYNC_ADDR_M, 1, 0), .owner = ENTRY(0) },
67+
[3] = { .config = REGDMA_LINK_WRITE_INIT(REGDMA_CACHE_LINK(0x03), CACHE_SYNC_SIZE_REG, 0, CACHE_SYNC_SIZE_M, 1, 0), .owner = ENTRY(0) },
68+
[4] = { .config = REGDMA_LINK_WRITE_INIT(REGDMA_CACHE_LINK(0x04), CACHE_SYNC_MAP_REG, CACHE_MAP_L1_CACHE_MASK, CACHE_SYNC_MAP_M, 1, 0), .owner = ENTRY(0) },
69+
[5] = { .config = REGDMA_LINK_WRITE_INIT(REGDMA_CACHE_LINK(0x05), CACHE_SYNC_CTRL_REG, 0, CACHE_SYNC_RGID_M, 1, 0), .owner = ENTRY(0) },
70+
[6] = { .config = REGDMA_LINK_WRITE_INIT(REGDMA_CACHE_LINK(0x06), CACHE_SYNC_CTRL_REG, CACHE_INVALIDATE_ENA, CACHE_INVALIDATE_ENA_M, 1, 0), .owner = ENTRY(0) },
71+
[7] = { .config = REGDMA_LINK_WAIT_INIT(REGDMA_CACHE_LINK(0x07), CACHE_SYNC_CTRL_REG, CACHE_SYNC_DONE, CACHE_SYNC_DONE_M, 1, 0), .owner = ENTRY(0) },
6472
};
6573
_Static_assert(ARRAY_SIZE(cache_regs_retention) == CACHE_RETENTION_LINK_LEN, "Inconsistent L2 CACHE retention link length definitions");
6674

0 commit comments

Comments
 (0)