From 0b0da680d260d41bbc5adca5d675fd5fcdea7c4e Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Tue, 7 Feb 2023 15:23:39 +0800 Subject: [PATCH] codeclean: turn on the regdma clock only once --- components/esp_hw_support/port/pau_regdma.c | 14 ++++++++++---- components/hal/esp32c6/include/hal/clk_gate_ll.h | 8 ++++++++ components/soc/esp32c6/include/soc/periph_defs.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/components/esp_hw_support/port/pau_regdma.c b/components/esp_hw_support/port/pau_regdma.c index 9f2b213ef7..5d340c1b0a 100644 --- a/components/esp_hw_support/port/pau_regdma.c +++ b/components/esp_hw_support/port/pau_regdma.c @@ -9,10 +9,11 @@ #include #include "sdkconfig.h" #include "esp_attr.h" -#include "soc/soc.h" -#include "esp_private/esp_pau.h" #include "esp_log.h" +#include "soc/soc.h" #include "soc/pcr_reg.h" +#include "esp_private/esp_pau.h" +#include "esp_private/periph_ctrl.h" static __attribute__((unused)) const char *TAG = "pau_regdma"; @@ -22,9 +23,14 @@ typedef struct { pau_context_t * __attribute__((weak)) PAU_instance(void) { - static pau_hal_context_t pau_hal = { .dev = &PAU }; + static pau_hal_context_t pau_hal = { .dev = NULL }; static pau_context_t pau_context = { .hal = &pau_hal }; - *(volatile uint32_t *)PCR_REGDMA_CONF_REG |= PCR_REGDMA_CLK_EN; + + if (pau_hal.dev == NULL) { + pau_hal.dev = &PAU; + periph_module_enable(PERIPH_REGDMA_MODULE); + } + return &pau_context; } diff --git a/components/hal/esp32c6/include/hal/clk_gate_ll.h b/components/hal/esp32c6/include/hal/clk_gate_ll.h index df4004c48c..4e221908e3 100644 --- a/components/hal/esp32c6/include/hal/clk_gate_ll.h +++ b/components/hal/esp32c6/include/hal/clk_gate_ll.h @@ -74,6 +74,8 @@ static inline uint32_t periph_ll_get_clk_en_mask(periph_module_t periph) return PCR_TSENS_CLK_EN; case PERIPH_SDIO_SLAVE_MODULE: return PCR_SDIO_SLAVE_CLK_EN; + case PERIPH_REGDMA_MODULE: + return PCR_REGDMA_CLK_EN; // case PERIPH_RNG_MODULE: // return PCR_WIFI_CLK_RNG_EN; // case PERIPH_WIFI_MODULE: @@ -163,6 +165,8 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en return PCR_DS_RST_EN; case PERIPH_SDIO_SLAVE_MODULE: return PCR_SDIO_SLAVE_RST_EN; + case PERIPH_REGDMA_MODULE: + return PCR_REGDMA_RST_EN; // case PERIPH_RNG_MODULE: // return PCR_WIFI_CLK_RNG_EN; // case PERIPH_WIFI_MODULE: @@ -245,6 +249,8 @@ static uint32_t periph_ll_get_clk_en_reg(periph_module_t periph) return PCR_TSENS_CLK_CONF_REG; case PERIPH_SDIO_SLAVE_MODULE: return PCR_SDIO_SLAVE_CONF_REG; + case PERIPH_REGDMA_MODULE: + return PCR_REGDMA_CONF_REG; default: return 0; } @@ -307,6 +313,8 @@ static uint32_t periph_ll_get_rst_en_reg(periph_module_t periph) return PCR_TSENS_CLK_CONF_REG; case PERIPH_SDIO_SLAVE_MODULE: return PCR_SDIO_SLAVE_CONF_REG; + case PERIPH_REGDMA_MODULE: + return PCR_REGDMA_CONF_REG; default: return 0; } diff --git a/components/soc/esp32c6/include/soc/periph_defs.h b/components/soc/esp32c6/include/soc/periph_defs.h index 906d0ff07b..90e8d777fd 100644 --- a/components/soc/esp32c6/include/soc/periph_defs.h +++ b/components/soc/esp32c6/include/soc/periph_defs.h @@ -40,6 +40,7 @@ typedef enum { PERIPH_SYSTIMER_MODULE, PERIPH_SARADC_MODULE, PERIPH_TEMPSENSOR_MODULE, + PERIPH_REGDMA_MODULE, PERIPH_WIFI_MODULE, PERIPH_BT_MODULE, PERIPH_IEEE802154_MODULE,