change(gptimer): use private unsafe RCC LL functions in bootloader

pull/13660/head
morris 2024-04-08 16:05:47 +08:00
rodzic 1ca8de6e89
commit e8b6d2280d
20 zmienionych plików z 63 dodań i 83 usunięć

Wyświetl plik

@ -203,9 +203,7 @@ static void enable_timer_group0_for_calibration(void)
}
}
#else
// no critical section is needed for bootloader
int __DECLARE_RCC_RC_ATOMIC_ENV;
timer_ll_enable_bus_clock(0, true);
timer_ll_reset_register(0);
_timer_ll_enable_bus_clock(0, true);
_timer_ll_reset_register(0);
#endif
}

Wyświetl plik

@ -36,7 +36,7 @@
uint32_t rtc_clk_cal_internal(rtc_cal_sel_t cal_clk, uint32_t slowclk_cycles)
{
/* On ESP32-C2, choosing RTC_CAL_RTC_MUX results in calibration of
* the 150k RTC clock regardless of the currenlty selected SLOW_CLK.
* the 150k RTC clock regardless of the currently selected SLOW_CLK.
* On the ESP32, it used the currently selected SLOW_CLK.
* The following code emulates ESP32 behavior:
*/
@ -203,9 +203,7 @@ static void enable_timer_group0_for_calibration(void)
}
}
#else
// no critical section is needed for bootloader
int __DECLARE_RCC_RC_ATOMIC_ENV;
timer_ll_enable_bus_clock(0, true);
timer_ll_reset_register(0);
_timer_ll_enable_bus_clock(0, true);
_timer_ll_reset_register(0);
#endif
}

Wyświetl plik

@ -36,7 +36,7 @@
uint32_t rtc_clk_cal_internal(rtc_cal_sel_t cal_clk, uint32_t slowclk_cycles)
{
/* On ESP32C3, choosing RTC_CAL_RTC_MUX results in calibration of
* the 150k RTC clock regardless of the currenlty selected SLOW_CLK.
* the 150k RTC clock regardless of the currently selected SLOW_CLK.
* On the ESP32, it used the currently selected SLOW_CLK.
* The following code emulates ESP32 behavior:
*/
@ -206,9 +206,7 @@ static void enable_timer_group0_for_calibration(void)
}
}
#else
// no critical section is needed for bootloader
int __DECLARE_RCC_RC_ATOMIC_ENV;
timer_ll_enable_bus_clock(0, true);
timer_ll_reset_register(0);
_timer_ll_enable_bus_clock(0, true);
_timer_ll_reset_register(0);
#endif
}

Wyświetl plik

@ -83,7 +83,7 @@ static uint32_t rtc_clk_cal_internal(rtc_cal_sel_t cal_clk, uint32_t slowclk_cyc
/* Enable requested clock (150k clock is always on) */
// All clocks on/off takes time to be stable, so we shouldn't frequently enable/disable the clock
// Only enable if orignally was disabled, and set back to the disable state after calibration is done
// Only enable if originally was disabled, and set back to the disable state after calibration is done
// If the clock is already on, then do nothing
bool dig_32k_xtal_enabled = clk_ll_xtal32k_digi_is_enabled();
if (cal_clk == RTC_CAL_32K_XTAL && !dig_32k_xtal_enabled) {
@ -277,9 +277,7 @@ static void enable_timer_group0_for_calibration(void)
}
}
#else
// no critical section is needed for bootloader
int __DECLARE_RCC_RC_ATOMIC_ENV;
timer_ll_enable_bus_clock(0, true);
timer_ll_reset_register(0);
_timer_ll_enable_bus_clock(0, true);
_timer_ll_reset_register(0);
#endif
}

Wyświetl plik

@ -81,7 +81,7 @@ static uint32_t rtc_clk_cal_internal(rtc_cal_sel_t cal_clk, uint32_t slowclk_cyc
/* Enable requested clock (150k clock is always on) */
// All clocks on/off takes time to be stable, so we shouldn't frequently enable/disable the clock
// Only enable if orignally was disabled, and set back to the disable state after calibration is done
// Only enable if originally was disabled, and set back to the disable state after calibration is done
// If the clock is already on, then do nothing
bool dig_32k_xtal_enabled = clk_ll_xtal32k_digi_is_enabled();
if (cal_clk == RTC_CAL_32K_XTAL && !dig_32k_xtal_enabled) {
@ -283,9 +283,7 @@ static void enable_timer_group0_for_calibration(void)
}
}
#else
// no critical section is needed for bootloader
int __DECLARE_RCC_RC_ATOMIC_ENV;
timer_ll_enable_bus_clock(0, true);
timer_ll_reset_register(0);
_timer_ll_enable_bus_clock(0, true);
_timer_ll_reset_register(0);
#endif
}

Wyświetl plik

@ -280,9 +280,7 @@ static void enable_timer_group0_for_calibration(void)
}
}
#else
// no critical section is needed for bootloader
int __DECLARE_RCC_RC_ATOMIC_ENV;
timer_ll_enable_bus_clock(0, true);
timer_ll_reset_register(0);
_timer_ll_enable_bus_clock(0, true);
_timer_ll_reset_register(0);
#endif
}

Wyświetl plik

@ -81,7 +81,7 @@ static uint32_t rtc_clk_cal_internal(rtc_cal_sel_t cal_clk, uint32_t slowclk_cyc
/* Enable requested clock (150k clock is always on) */
// All clocks on/off takes time to be stable, so we shouldn't frequently enable/disable the clock
// Only enable if orignally was disabled, and set back to the disable state after calibration is done
// Only enable if originally was disabled, and set back to the disable state after calibration is done
// If the clock is already on, then do nothing
bool dig_32k_xtal_enabled = clk_ll_xtal32k_digi_is_enabled();
if (cal_clk == RTC_CAL_32K_XTAL && !dig_32k_xtal_enabled) {
@ -283,9 +283,7 @@ static void enable_timer_group0_for_calibration(void)
}
}
#else
// no critical section is needed for bootloader
int __DECLARE_RCC_RC_ATOMIC_ENV;
timer_ll_enable_bus_clock(0, true);
timer_ll_reset_register(0);
_timer_ll_enable_bus_clock(0, true);
_timer_ll_reset_register(0);
#endif
}

Wyświetl plik

@ -69,7 +69,7 @@ uint32_t rtc_clk_cal_internal(rtc_cal_sel_t cal_clk, uint32_t slowclk_cycles)
/* Enable requested clock (some clocks are always on) */
// All clocks on/off takes time to be stable, so we shouldn't frequently enable/disable the clock
// Only enable if orignally was disabled, and set back to the disable state after calibration is done
// Only enable if originally was disabled, and set back to the disable state after calibration is done
// If the clock is already on, then do nothing
bool dig_32k_xtal_enabled = clk_ll_xtal32k_digi_is_enabled();
if (cal_clk == RTC_CAL_32K_XTAL && !dig_32k_xtal_enabled) {
@ -240,9 +240,7 @@ static void enable_timer_group0_for_calibration(void)
}
}
#else
// no critical section is needed for bootloader
int __DECLARE_RCC_RC_ATOMIC_ENV;
timer_ll_enable_bus_clock(0, true);
timer_ll_reset_register(0);
_timer_ll_enable_bus_clock(0, true);
_timer_ll_reset_register(0);
#endif
}

Wyświetl plik

@ -116,7 +116,7 @@ static uint32_t rtc_clk_cal_internal_cycling(rtc_cal_sel_t cal_clk, uint32_t slo
}
/**
* @brief Slowclk period calculating funtion used by rtc_clk_cal and rtc_clk_cal_cycling
* @brief Slowclk period calculating function used by rtc_clk_cal and rtc_clk_cal_cycling
* @param xtal_cycles number of xtal cycles count
* @param slowclk_cycles number of slow clock cycles to count
* @return slow clock period
@ -140,7 +140,7 @@ static uint32_t rtc_clk_xtal_to_slowclk(uint64_t xtal_cycles, uint32_t slowclk_c
uint32_t rtc_clk_cal_internal(rtc_cal_sel_t cal_clk, uint32_t slowclk_cycles, uint32_t cal_mode)
{
/* On ESP32S2, choosing RTC_CAL_RTC_MUX results in calibration of
* the 90k RTC clock regardless of the currenlty selected SLOW_CLK.
* the 90k RTC clock regardless of the currently selected SLOW_CLK.
* On the ESP32, it used the currently selected SLOW_CLK.
* The following code emulates ESP32 behavior:
*/
@ -271,9 +271,7 @@ static void enable_timer_group0_for_calibration(void)
}
}
#else
// no critical section is needed for bootloader
int __DECLARE_RCC_RC_ATOMIC_ENV;
timer_ll_enable_bus_clock(0, true);
timer_ll_reset_register(0);
_timer_ll_enable_bus_clock(0, true);
_timer_ll_reset_register(0);
#endif
}

Wyświetl plik

@ -35,7 +35,7 @@
uint32_t rtc_clk_cal_internal(rtc_cal_sel_t cal_clk, uint32_t slowclk_cycles)
{
/* On ESP32S3, choosing RTC_CAL_RTC_MUX results in calibration of
* the 150k RTC clock regardless of the currenlty selected SLOW_CLK.
* the 150k RTC clock regardless of the currently selected SLOW_CLK.
* On the ESP32, it used the currently selected SLOW_CLK.
* The following code emulates ESP32 behavior:
*/
@ -205,9 +205,7 @@ static void enable_timer_group0_for_calibration(void)
}
}
#else
// no critical section is needed for bootloader
int __DECLARE_RCC_RC_ATOMIC_ENV;
timer_ll_enable_bus_clock(0, true);
timer_ll_reset_register(0);
_timer_ll_enable_bus_clock(0, true);
_timer_ll_reset_register(0);
#endif
}

Wyświetl plik

@ -56,7 +56,7 @@ static inline void _timer_ll_enable_bus_clock(int group_id, bool enable)
*
* @param group_id Group ID
*/
static inline void timer_ll_reset_register(int group_id)
static inline void _timer_ll_reset_register(int group_id)
{
if (group_id == 0) {
DPORT_WRITE_PERI_REG(DPORT_PERIP_RST_EN_REG, DPORT_TIMERGROUP_RST);
@ -71,7 +71,7 @@ static inline void timer_ll_reset_register(int group_id)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; timer_ll_reset_register(__VA_ARGS__)
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_reset_register(__VA_ARGS__)
/**
* @brief Set clock source for timer
@ -166,7 +166,7 @@ static inline void timer_ll_set_count_direction(timg_dev_t *hw, uint32_t timer_n
}
/**
* @brief Enable timer, start couting
* @brief Enable timer, start counting
*
* @param hw Timer Group register base address
* @param timer_num Timer number in the group

Wyświetl plik

@ -49,7 +49,7 @@ static inline void _timer_ll_enable_bus_clock(int group_id, bool enable)
*
* @param group_id Group ID
*/
static inline void timer_ll_reset_register(int group_id)
static inline void _timer_ll_reset_register(int group_id)
{
(void)group_id;
SYSTEM.perip_rst_en0.timergroup_rst = 1;
@ -59,7 +59,7 @@ static inline void timer_ll_reset_register(int group_id)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; timer_ll_reset_register(__VA_ARGS__)
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_reset_register(__VA_ARGS__)
/**
* @brief Set clock source for timer
@ -154,7 +154,7 @@ static inline void timer_ll_set_count_direction(timg_dev_t *hw, uint32_t timer_n
}
/**
* @brief Enable timer, start couting
* @brief Enable timer, start counting
*
* @param hw Timer Group register base address
* @param timer_num Timer number in the group

Wyświetl plik

@ -52,7 +52,7 @@ static inline void _timer_ll_enable_bus_clock(int group_id, bool enable)
*
* @param group_id Group ID
*/
static inline void timer_ll_reset_register(int group_id)
static inline void _timer_ll_reset_register(int group_id)
{
if (group_id == 0) {
SYSTEM.perip_rst_en0.reg_timergroup_rst = 1;
@ -67,7 +67,7 @@ static inline void timer_ll_reset_register(int group_id)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; timer_ll_reset_register(__VA_ARGS__)
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_reset_register(__VA_ARGS__)
/**
* @brief Set clock source for timer
@ -162,7 +162,7 @@ static inline void timer_ll_set_count_direction(timg_dev_t *hw, uint32_t timer_n
}
/**
* @brief Enable timer, start couting
* @brief Enable timer, start counting
*
* @param hw Timer Group register base address
* @param timer_num Timer number in the group

Wyświetl plik

@ -34,7 +34,7 @@ extern "C" {
* @param group_id Group ID
* @param enable true to enable, false to disable
*/
static inline void timer_ll_enable_bus_clock(int group_id, bool enable)
static inline void _timer_ll_enable_bus_clock(int group_id, bool enable)
{
if (group_id == 0) {
PCR.timergroup0_conf.tg0_clk_en = enable;
@ -45,7 +45,7 @@ static inline void timer_ll_enable_bus_clock(int group_id, bool enable)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_enable_bus_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; timer_ll_enable_bus_clock(__VA_ARGS__)
#define timer_ll_enable_bus_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_enable_bus_clock(__VA_ARGS__)
/**
* @brief Reset the timer group module
@ -56,7 +56,7 @@ static inline void timer_ll_enable_bus_clock(int group_id, bool enable)
*
* @param group_id Group ID
*/
static inline void timer_ll_reset_register(int group_id)
static inline void _timer_ll_reset_register(int group_id)
{
if (group_id == 0) {
PCR.timergroup0_conf.tg0_rst_en = 1;
@ -71,7 +71,7 @@ static inline void timer_ll_reset_register(int group_id)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; timer_ll_reset_register(__VA_ARGS__)
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_reset_register(__VA_ARGS__)
/**
* @brief Set clock source for timer
@ -197,7 +197,7 @@ static inline void timer_ll_set_count_direction(timg_dev_t *hw, uint32_t timer_n
}
/**
* @brief Enable timer, start couting
* @brief Enable timer, start counting
*
* @param hw Timer Group register base address
* @param timer_num Timer number in the group

Wyświetl plik

@ -79,7 +79,7 @@ static inline void _timer_ll_enable_bus_clock(int group_id, bool enable)
*
* @param group_id Group ID
*/
static inline void timer_ll_reset_register(int group_id)
static inline void _timer_ll_reset_register(int group_id)
{
if (group_id == 0) {
PCR.timergroup0_conf.tg0_rst_en = 1;
@ -94,7 +94,7 @@ static inline void timer_ll_reset_register(int group_id)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; timer_ll_reset_register(__VA_ARGS__)
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_reset_register(__VA_ARGS__)
/**
* @brief Set clock source for timer
@ -203,7 +203,7 @@ static inline void timer_ll_set_count_direction(timg_dev_t *hw, uint32_t timer_n
}
/**
* @brief Enable timer, start couting
* @brief Enable timer, start counting
*
* @param hw Timer Group register base address
* @param timer_num Timer number in the group

Wyświetl plik

@ -59,7 +59,7 @@ extern "C" {
* @param group_id Group ID
* @param enable true to enable, false to disable
*/
static inline void timer_ll_enable_bus_clock(int group_id, bool enable)
static inline void _timer_ll_enable_bus_clock(int group_id, bool enable)
{
if (group_id == 0) {
PCR.timergroup0_conf.tg0_clk_en = enable;
@ -70,7 +70,7 @@ static inline void timer_ll_enable_bus_clock(int group_id, bool enable)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_enable_bus_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; timer_ll_enable_bus_clock(__VA_ARGS__)
#define timer_ll_enable_bus_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_enable_bus_clock(__VA_ARGS__)
/**
* @brief Reset the timer group module
@ -81,7 +81,7 @@ static inline void timer_ll_enable_bus_clock(int group_id, bool enable)
*
* @param group_id Group ID
*/
static inline void timer_ll_reset_register(int group_id)
static inline void _timer_ll_reset_register(int group_id)
{
if (group_id == 0) {
PCR.timergroup0_conf.tg0_rst_en = 1;
@ -96,7 +96,7 @@ static inline void timer_ll_reset_register(int group_id)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; timer_ll_reset_register(__VA_ARGS__)
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_reset_register(__VA_ARGS__)
/**
* @brief Set clock source for timer
@ -205,7 +205,7 @@ static inline void timer_ll_set_count_direction(timg_dev_t *hw, uint32_t timer_n
}
/**
* @brief Enable timer, start couting
* @brief Enable timer, start counting
*
* @param hw Timer Group register base address
* @param timer_num Timer number in the group

Wyświetl plik

@ -79,7 +79,7 @@ static inline void _timer_ll_enable_bus_clock(int group_id, bool enable)
*
* @param group_id Group ID
*/
static inline void timer_ll_reset_register(int group_id)
static inline void _timer_ll_reset_register(int group_id)
{
if (group_id == 0) {
PCR.timergroup0_conf.tg0_rst_en = 1;
@ -94,7 +94,7 @@ static inline void timer_ll_reset_register(int group_id)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; timer_ll_reset_register(__VA_ARGS__)
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_reset_register(__VA_ARGS__)
/**
* @brief Set clock source for timer
@ -203,7 +203,7 @@ static inline void timer_ll_set_count_direction(timg_dev_t *hw, uint32_t timer_n
}
/**
* @brief Enable timer, start couting
* @brief Enable timer, start counting
*
* @param hw Timer Group register base address
* @param timer_num Timer number in the group

Wyświetl plik

@ -109,7 +109,7 @@ static inline void _timer_ll_enable_bus_clock(int group_id, bool enable)
*
* @param group_id Group ID
*/
static inline void timer_ll_reset_register(int group_id)
static inline void _timer_ll_reset_register(int group_id)
{
if (group_id == 0) {
HP_SYS_CLKRST.hp_rst_en1.reg_rst_en_timergrp0 = 1;
@ -124,7 +124,7 @@ static inline void timer_ll_reset_register(int group_id)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; timer_ll_reset_register(__VA_ARGS__)
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_reset_register(__VA_ARGS__)
/**
* @brief Set clock source for timer
@ -255,7 +255,7 @@ static inline void timer_ll_set_count_direction(timg_dev_t *hw, uint32_t timer_n
}
/**
* @brief Enable timer, start couting
* @brief Enable timer, start counting
*
* @param hw Timer Group register base address
* @param timer_num Timer number in the group

Wyświetl plik

@ -56,7 +56,7 @@ static inline void _timer_ll_enable_bus_clock(int group_id, bool enable)
*
* @param group_id Group ID
*/
static inline void timer_ll_reset_register(int group_id)
static inline void _timer_ll_reset_register(int group_id)
{
if (group_id == 0) {
WRITE_PERI_REG(DPORT_PERIP_RST_EN0_REG, DPORT_TIMERGROUP_RST_M);
@ -71,7 +71,7 @@ static inline void timer_ll_reset_register(int group_id)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; timer_ll_reset_register(__VA_ARGS__)
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_reset_register(__VA_ARGS__)
/**
* @brief Set clock source for timer
@ -170,7 +170,7 @@ static inline void timer_ll_set_count_direction(timg_dev_t *hw, uint32_t timer_n
}
/**
* @brief Enable timer, start couting
* @brief Enable timer, start counting
*
* @param hw Timer Group register base address
* @param timer_num Timer number in the group

Wyświetl plik

@ -52,7 +52,7 @@ static inline void _timer_ll_enable_bus_clock(int group_id, bool enable)
*
* @param group_id Group ID
*/
static inline void timer_ll_reset_register(int group_id)
static inline void _timer_ll_reset_register(int group_id)
{
if (group_id == 0) {
SYSTEM.perip_rst_en0.timergroup_rst = 1;
@ -67,7 +67,7 @@ static inline void timer_ll_reset_register(int group_id)
/// use a macro to wrap the function, force the caller to use it in a critical section
/// the critical section needs to declare the __DECLARE_RCC_RC_ATOMIC_ENV variable in advance
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; timer_ll_reset_register(__VA_ARGS__)
#define timer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _timer_ll_reset_register(__VA_ARGS__)
/**
* @brief Set clock source for timer
@ -165,7 +165,7 @@ static inline void timer_ll_set_count_direction(timg_dev_t *hw, uint32_t timer_n
}
/**
* @brief Enable timer, start couting
* @brief Enable timer, start counting
*
* @param hw Timer Group register base address
* @param timer_num Timer number in the group