refactor(periph_ctrl): remove orphaned clk_gate_ll.h

and deprecate the legacy periph_module_xxx functions for new targets
This commit is contained in:
morris
2024-03-29 10:53:05 +08:00
parent f29351b99a
commit 8e64a59fac
13 changed files with 49 additions and 209 deletions
@@ -1,11 +1,12 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include "sdkconfig.h"
#include "soc/periph_defs.h"
#ifdef __cplusplus
@@ -68,6 +69,24 @@ void periph_rcc_exit(void);
/*************************************************************************************************************
* @note The following APIs are no longer supported since ESP32P4, please use the RCC lock macros instead.
*************************************************************************************************************/
// allow the following targets to use the legacy periph_module_xyz APIs, to maintain backward compatibility,
// because periph_module_xyz is also used outside of the ESP-IDF
#if defined(CONFIG_IDF_TARGET_ESP32) || \
defined(CONFIG_IDF_TARGET_ESP32S2) || \
defined(CONFIG_IDF_TARGET_ESP32S3) || \
defined(CONFIG_IDF_TARGET_ESP32C2) || \
defined(CONFIG_IDF_TARGET_ESP32C3) || \
defined(CONFIG_IDF_TARGET_ESP32C6) || \
defined(CONFIG_IDF_TARGET_ESP32H2)
#define __PERIPH_CTRL_ALLOW_LEGACY_API
#endif
#ifdef __PERIPH_CTRL_ALLOW_LEGACY_API
#define __PERIPH_CTRL_DEPRECATE_ATTR
#else
#define __PERIPH_CTRL_DEPRECATE_ATTR __attribute__((deprecated("This function is not functional on "CONFIG_IDF_TARGET)))
#endif
/**
* @brief Enable peripheral module by un-gating the clock and de-asserting the reset signal.
*
@@ -77,6 +96,7 @@ void periph_rcc_exit(void);
* @c periph_module_disable() has to be called the same number of times,
* in order to put the peripheral into disabled state.
*/
__PERIPH_CTRL_DEPRECATE_ATTR
void periph_module_enable(periph_module_t periph);
/**
@@ -88,6 +108,7 @@ void periph_module_enable(periph_module_t periph);
* @c periph_module_disable() has to be called the same number of times,
* in order to put the peripheral into disabled state.
*/
__PERIPH_CTRL_DEPRECATE_ATTR
void periph_module_disable(periph_module_t periph);
/**
@@ -97,6 +118,7 @@ void periph_module_disable(periph_module_t periph);
*
* @note Calling this function does not enable or disable the clock for the module.
*/
__PERIPH_CTRL_DEPRECATE_ATTR
void periph_module_reset(periph_module_t periph);
/**
@@ -131,6 +153,8 @@ void wifi_module_enable(void);
*/
void wifi_module_disable(void);
#undef __PERIPH_CTRL_DEPRECATE_ATTR
#ifdef __cplusplus
}
#endif
@@ -36,7 +36,6 @@
#if CONFIG_PM_CHECK_SLEEP_RETENTION_FRAME
#include "esp_private/system_internal.h"
#include "hal/clk_gate_ll.h"
#include "hal/uart_hal.h"
#endif
@@ -36,7 +36,6 @@
#if CONFIG_PM_CHECK_SLEEP_RETENTION_FRAME
#include "esp_private/system_internal.h"
#include "hal/clk_gate_ll.h"
#include "hal/uart_hal.h"
#endif
@@ -36,7 +36,6 @@
#if CONFIG_PM_CHECK_SLEEP_RETENTION_FRAME
#include "esp_private/system_internal.h"
#include "hal/clk_gate_ll.h"
#include "hal/uart_hal.h"
#endif
@@ -37,7 +37,6 @@
#if CONFIG_PM_CHECK_SLEEP_RETENTION_FRAME
#include "esp_private/system_internal.h"
#include "hal/clk_gate_ll.h"
#include "hal/uart_hal.h"
#endif
-1
View File
@@ -12,7 +12,6 @@
#include "soc/soc.h"
#include "soc/soc_caps.h"
#include "freertos/FreeRTOS.h"
#include "hal/clk_gate_ll.h"
#include "esp_private/esp_modem_clock.h"
#include "esp_private/esp_pmu.h"
#include "esp_sleep.h"
+10 -2
View File
@@ -1,13 +1,15 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "freertos/FreeRTOS.h"
#include "hal/clk_gate_ll.h"
#include "esp_attr.h"
#include "esp_private/periph_ctrl.h"
#include "soc/soc_caps.h"
#ifdef __PERIPH_CTRL_ALLOW_LEGACY_API
#include "hal/clk_gate_ll.h"
#endif
#if SOC_MODEM_CLOCK_IS_INDEPENDENT
#include "esp_private/esp_modem_clock.h"
@@ -55,6 +57,7 @@ void periph_rcc_release_exit(periph_module_t periph, uint8_t ref_count)
void periph_module_enable(periph_module_t periph)
{
#ifdef __PERIPH_CTRL_ALLOW_LEGACY_API
assert(periph < PERIPH_MODULE_MAX);
portENTER_CRITICAL_SAFE(&periph_spinlock);
if (ref_counts[periph] == 0) {
@@ -62,10 +65,12 @@ void periph_module_enable(periph_module_t periph)
}
ref_counts[periph]++;
portEXIT_CRITICAL_SAFE(&periph_spinlock);
#endif
}
void periph_module_disable(periph_module_t periph)
{
#ifdef __PERIPH_CTRL_ALLOW_LEGACY_API
assert(periph < PERIPH_MODULE_MAX);
portENTER_CRITICAL_SAFE(&periph_spinlock);
ref_counts[periph]--;
@@ -73,14 +78,17 @@ void periph_module_disable(periph_module_t periph)
periph_ll_disable_clk_set_rst(periph);
}
portEXIT_CRITICAL_SAFE(&periph_spinlock);
#endif
}
void periph_module_reset(periph_module_t periph)
{
#ifdef __PERIPH_CTRL_ALLOW_LEGACY_API
assert(periph < PERIPH_MODULE_MAX);
portENTER_CRITICAL_SAFE(&periph_spinlock);
periph_ll_reset(periph);
portEXIT_CRITICAL_SAFE(&periph_spinlock);
#endif
}
#if !SOC_IEEE802154_BLE_ONLY
+5 -6
View File
@@ -48,7 +48,6 @@
#if SOC_TOUCH_SENSOR_SUPPORTED
#include "hal/touch_sensor_hal.h"
#endif
#include "hal/clk_gate_ll.h"
#include "sdkconfig.h"
#include "esp_rom_uart.h"
@@ -301,8 +300,8 @@ static void RTC_IRAM_ATTR __attribute__((used, noinline)) esp_wake_stub_start(vo
/* We must have a default deep sleep wake stub entry function, which must be
* located at the start address of the RTC fast memory, and its implementation
* must be simple enough to ensure that there is no litteral data before the
* wake stub entry, otherwise, the litteral data before the wake stub entry
* must be simple enough to ensure that there is no literal data before the
* wake stub entry, otherwise, the literal data before the wake stub entry
* will not be CRC checked. */
static void __attribute__((section(".rtc.entry.text"))) esp_wake_stub_entry(void)
{
@@ -769,7 +768,7 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
if (!deep_sleep) {
/* Enable sleep reject for faster return from this function,
* in case the wakeup is already triggerred.
* in case the wakeup is already triggered.
*/
reject_triggers |= sleep_modem_reject_triggers();
}
@@ -1216,8 +1215,8 @@ esp_err_t esp_light_sleep_start(void)
/*
* Adjustment time consists of parts below:
* 1. Hardware time waiting for internal 8M oscilate clock and XTAL;
* 2. Hardware state swithing time of the rtc main state machine;
* 1. Hardware time waiting for internal 8M oscillate clock and XTAL;
* 2. Hardware state switching time of the rtc main state machine;
* 3. Code execution time when clock is not stable;
* 4. Code execution time which can be measured;
*/