From d3e0e3e3b62acc41840a4790ff0db5c3965219a3 Mon Sep 17 00:00:00 2001 From: Li Shuai Date: Tue, 14 Feb 2023 14:25:31 +0800 Subject: [PATCH] pau: implement the pau regdma driver for esp32c6 --- components/esp_hw_support/CMakeLists.txt | 4 ++ .../include/esp_private/esp_pau.h | 64 +++++++++++++++++ components/esp_hw_support/port/pau_regdma.c | 69 +++++++++++++++++++ components/hal/include/hal/pau_types.h | 2 +- 4 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 components/esp_hw_support/include/esp_private/esp_pau.h create mode 100644 components/esp_hw_support/port/pau_regdma.c diff --git a/components/esp_hw_support/CMakeLists.txt b/components/esp_hw_support/CMakeLists.txt index fb5e8056fc..527a2ccec3 100644 --- a/components/esp_hw_support/CMakeLists.txt +++ b/components/esp_hw_support/CMakeLists.txt @@ -73,6 +73,10 @@ if(NOT BOOTLOADER_BUILD) list(APPEND srcs "esp_ds.c") endif() + if(CONFIG_SOC_PAU_SUPPORTED) + list(APPEND srcs "port/pau_regdma.c") + endif() + if(CONFIG_SOC_PM_CPU_RETENTION_BY_SW) list(APPEND srcs "sleep_cpu_asm.S") set_property(TARGET ${COMPONENT_LIB} diff --git a/components/esp_hw_support/include/esp_private/esp_pau.h b/components/esp_hw_support/include/esp_private/esp_pau.h new file mode 100644 index 0000000000..66c5e6ab3a --- /dev/null +++ b/components/esp_hw_support/include/esp_private/esp_pau.h @@ -0,0 +1,64 @@ +/* + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include +#include +#include "soc/soc.h" +#include "soc/soc_caps.h" + +#if SOC_PAU_SUPPORTED +#include "hal/pau_hal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Set the addresses of all REGDMA Links + * @param link_entries all linked lists addresses + */ +void pau_regdma_set_entry_link_addr(pau_regdma_link_addr_t *link_entries); + +/** + * @brief Set the address of WiFi MAC REGDMA Link in modem state + * @param link_addr linked lists address + */ +void pau_regdma_set_modem_link_addr(void *link_addr); + +/** + * @brief Software trigger regdma to perform modem link backup + */ +void pau_regdma_trigger_modem_link_backup(void); + +/** + * @brief Software trigger regdma to perform modem link restore + */ +void pau_regdma_trigger_modem_link_restore(void); + +/** + * @brief Set the address of extra REGDMA Link in active state + * @param link_addr linked lists address + */ +void pau_regdma_set_extra_link_addr(void *link_addr); + +/** + * @brief Software trigger regdma to perform extra link backup + */ +void pau_regdma_trigger_extra_link_backup(void); + +/** + * @brief Software trigger regdma to perform extra link restore + */ +void pau_regdma_trigger_extra_link_restore(void); + +#ifdef __cplusplus +} +#endif + +#endif //SOC_PAU_SUPPORTED diff --git a/components/esp_hw_support/port/pau_regdma.c b/components/esp_hw_support/port/pau_regdma.c new file mode 100644 index 0000000000..9f2b213ef7 --- /dev/null +++ b/components/esp_hw_support/port/pau_regdma.c @@ -0,0 +1,69 @@ +/* + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include "sdkconfig.h" +#include "esp_attr.h" +#include "soc/soc.h" +#include "esp_private/esp_pau.h" +#include "esp_log.h" +#include "soc/pcr_reg.h" + +static __attribute__((unused)) const char *TAG = "pau_regdma"; + +typedef struct { + pau_hal_context_t *hal; +} pau_context_t; + +pau_context_t * __attribute__((weak)) PAU_instance(void) +{ + static pau_hal_context_t pau_hal = { .dev = &PAU }; + static pau_context_t pau_context = { .hal = &pau_hal }; + *(volatile uint32_t *)PCR_REGDMA_CONF_REG |= PCR_REGDMA_CLK_EN; + return &pau_context; +} + +void pau_regdma_set_entry_link_addr(pau_regdma_link_addr_t *link_entries) +{ + ESP_LOGD(TAG, "All link addresses %p,%p,%p,%p", (*link_entries)[0], (*link_entries)[1], (*link_entries)[2], (*link_entries)[3]); + pau_hal_set_regdma_entry_link_addr(PAU_instance()->hal, link_entries); +} + +void pau_regdma_set_modem_link_addr(void *link_addr) +{ + pau_hal_set_regdma_modem_link_addr(PAU_instance()->hal, link_addr); +} + +void pau_regdma_trigger_modem_link_backup(void) +{ + pau_hal_start_regdma_modem_link(PAU_instance()->hal, true); + pau_hal_stop_regdma_modem_link(PAU_instance()->hal); +} + +void pau_regdma_trigger_modem_link_restore(void) +{ + pau_hal_start_regdma_modem_link(PAU_instance()->hal, false); + pau_hal_stop_regdma_modem_link(PAU_instance()->hal); +} + +void pau_regdma_set_extra_link_addr(void *link_addr) +{ + pau_hal_set_regdma_extra_link_addr(PAU_instance()->hal, link_addr); +} + +void pau_regdma_trigger_extra_link_backup(void) +{ + pau_hal_start_regdma_extra_link(PAU_instance()->hal, true); + pau_hal_stop_regdma_extra_link(PAU_instance()->hal); +} + +void pau_regdma_trigger_extra_link_restore(void) +{ + pau_hal_start_regdma_extra_link(PAU_instance()->hal, false); + pau_hal_stop_regdma_extra_link(PAU_instance()->hal); +} diff --git a/components/hal/include/hal/pau_types.h b/components/hal/include/hal/pau_types.h index 0d4002ce4d..19b4028f5a 100644 --- a/components/hal/include/hal/pau_types.h +++ b/components/hal/include/hal/pau_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */