Skip to content

Commit 3b2a14f

Browse files
committed
change(esp_hw_support): esp32p4 rev3.0 dummy read workaround refactor
1 parent 3ee348f commit 3b2a14f

File tree

7 files changed

+58
-24
lines changed

7 files changed

+58
-24
lines changed

components/esp_hw_support/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ if(NOT non_os_build)
5656
list(APPEND srcs "sleep_modem.c"
5757
"sleep_modes.c"
5858
"sleep_console.c"
59+
"sleep_mspi.c"
5960
"sleep_usb.c"
6061
"sleep_gpio.c"
6162
"sleep_event.c"

components/esp_hw_support/include/esp_private/esp_pmu.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,11 +346,6 @@ void pmu_init(void);
346346
*/
347347
uint32_t pmu_sleep_get_wakup_retention_cost(void);
348348

349-
/**
350-
* Workaround for esp32p4 v3 MPSI access failure after power up.
351-
*/
352-
void pmu_sleep_p4_rev3_workaround(void);
353-
354349
#endif //#if SOC_PMU_SUPPORTED
355350

356351
#ifdef __cplusplus
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
#include <stdint.h>
9+
#include "sdkconfig.h"
10+
#include "soc/soc_caps.h"
11+
12+
#ifdef __cplusplus
13+
extern "C" {
14+
#endif
15+
16+
#if CONFIG_IDF_TARGET_ESP32P4 && (CONFIG_ESP_REV_MIN_FULL == 300)
17+
/**
18+
* Workaround for esp32p4 v3 MPSI access failure after power up.
19+
*/
20+
void sleep_flash_p4_rev3_workaround(void);
21+
#endif
22+
23+
#ifdef __cplusplus
24+
}
25+
#endif

components/esp_hw_support/linker.lf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ entries:
3535
rtc_sleep:rtc_sleep_pu (noflash)
3636
if SOC_PMU_SUPPORTED = y && SOC_LIGHT_SLEEP_SUPPORTED = y:
3737
pmu_sleep (noflash)
38+
sleep_mspi (noflash)
3839
if SPIRAM_FLASH_LOAD_TO_PSRAM = y:
3940
pmu_init (noflash)
4041
pmu_param (noflash)

components/esp_hw_support/port/esp32p4/pmu_sleep.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -506,21 +506,3 @@ uint32_t pmu_sleep_get_wakup_retention_cost(void)
506506
{
507507
return PMU_REGDMA_S2A_WORK_TIME_US;
508508
}
509-
510-
#if (CONFIG_ESP_REV_MIN_FULL == 300)
511-
void pmu_sleep_p4_rev3_workaround(void)
512-
{
513-
REG_CLR_BIT(SPI_MEM_C_CACHE_FCTRL_REG, SPI_MEM_C_CLOSE_AXI_INF_EN);
514-
REG_SET_BIT(SPI_MEM_C_CACHE_FCTRL_REG, SPI_MEM_C_AXI_REQ_EN);
515-
REG_SET_FIELD(HP_SYSTEM_CORE_ERR_RESP_DIS_REG, HP_SYSTEM_CORE_ERR_RESP_DIS, 0x7);
516-
REG_WRITE(SPI_MEM_C_MMU_ITEM_INDEX_REG, 0);
517-
uint32_t mmu_backup = mmu_ll_read_entry(MMU_LL_FLASH_MMU_ID, 0);
518-
mmu_ll_write_entry(MMU_LL_FLASH_MMU_ID, 0, 0, MMU_TARGET_FLASH0);
519-
__attribute__((unused)) volatile uint32_t val = 0;
520-
val = *(uint32_t *)(0x80000000);
521-
val = *(uint32_t *)(0x80000080);
522-
mmu_ll_write_entry(MMU_LL_FLASH_MMU_ID, 0, mmu_backup, MMU_TARGET_FLASH0);
523-
_mspi_timing_ll_reset_mspi();
524-
_mspi_timing_ll_reset_mspi_apb();
525-
}
526-
#endif

components/esp_hw_support/sleep_modes.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
#include "esp_private/sleep_console.h"
7979
#include "esp_private/sleep_cpu.h"
8080
#include "esp_private/sleep_modem.h"
81+
#include "esp_private/sleep_flash.h"
8182
#include "esp_private/sleep_usb.h"
8283
#include "esp_private/esp_clk.h"
8384
#include "esp_private/esp_task_wdt.h"
@@ -950,7 +951,7 @@ static esp_err_t FORCE_IRAM_ATTR esp_sleep_start_safe(uint32_t sleep_flags, uint
950951
esp_sleep_mmu_retention(false);
951952
#endif
952953
#if CONFIG_IDF_TARGET_ESP32P4 && (CONFIG_ESP_REV_MIN_FULL == 300)
953-
pmu_sleep_p4_rev3_workaround();
954+
sleep_flash_p4_rev3_workaround();
954955
sleep_retention_do_extra_retention(false);
955956
#endif
956957
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#include "sdkconfig.h"
7+
8+
#if CONFIG_IDF_TARGET_ESP32P4 && (CONFIG_ESP_REV_MIN_FULL == 300)
9+
#include "soc/hp_system_reg.h"
10+
#include "hal/mmu_ll.h"
11+
#include "hal/mspi_ll.h"
12+
13+
void sleep_flash_p4_rev3_workaround(void)
14+
{
15+
REG_CLR_BIT(SPI_MEM_C_CACHE_FCTRL_REG, SPI_MEM_C_CLOSE_AXI_INF_EN);
16+
REG_SET_BIT(SPI_MEM_C_CACHE_FCTRL_REG, SPI_MEM_C_AXI_REQ_EN);
17+
REG_SET_FIELD(HP_SYSTEM_CORE_ERR_RESP_DIS_REG, HP_SYSTEM_CORE_ERR_RESP_DIS, 0x7);
18+
REG_WRITE(SPI_MEM_C_MMU_ITEM_INDEX_REG, 0);
19+
uint32_t mmu_backup = mmu_ll_read_entry(MMU_LL_FLASH_MMU_ID, 0);
20+
mmu_ll_write_entry(MMU_LL_FLASH_MMU_ID, 0, 0, MMU_TARGET_FLASH0);
21+
__attribute__((unused)) volatile uint32_t val = 0;
22+
val = REG_READ(0x80000000);
23+
val = REG_READ(0x80000080);
24+
mmu_ll_write_entry(MMU_LL_FLASH_MMU_ID, 0, mmu_backup, MMU_TARGET_FLASH0);
25+
_mspi_timing_ll_reset_mspi();
26+
_mspi_timing_ll_reset_mspi_apb();
27+
REG_SET_FIELD(HP_SYSTEM_CORE_ERR_RESP_DIS_REG, HP_SYSTEM_CORE_ERR_RESP_DIS, 0);
28+
}
29+
#endif

0 commit comments

Comments
 (0)