feat(systimer): support ETM on esp32p4

This commit is contained in:
morris
2023-12-07 17:30:39 +08:00
parent fb7ffb5112
commit e96491fb1f
13 changed files with 234 additions and 16 deletions

View File

@@ -34,8 +34,6 @@ static inline uint32_t periph_ll_get_clk_en_mask(periph_module_t periph)
return 0;
case PERIPH_I3C_MODULE:
return HP_SYS_CLKRST_REG_I3C_MST_CLK_EN;
case PERIPH_SYSTIMER_MODULE:
return HP_SYS_CLKRST_REG_SYSTIMER_CLK_EN;
case PERIPH_SARADC_MODULE:
return HP_SYS_CLKRST_REG_ADC_CLK_EN;
case PERIPH_PVT_MODULE:
@@ -85,8 +83,6 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en
return HP_SYS_CLKRST_REG_RST_EN_DMA2D;
case PERIPH_PPA_MODULE:
return HP_SYS_CLKRST_REG_RST_EN_PPA;
case PERIPH_SYSTIMER_MODULE:
return HP_SYS_CLKRST_REG_RST_EN_STIMER;
case PERIPH_UHCI_MODULE:
return HP_SYS_CLKRST_REG_RST_EN_UHCI;
case PERIPH_I3C_MODULE:
@@ -144,7 +140,6 @@ static inline uint32_t periph_ll_get_clk_en_reg(periph_module_t periph)
case PERIPH_MIPI_DSI_MODULE:
return HP_SYS_CLKRST_PERI_CLK_CTRL03_REG;
case PERIPH_I3C_MODULE:
case PERIPH_SYSTIMER_MODULE:
case PERIPH_SARADC_MODULE:
return HP_SYS_CLKRST_PERI_CLK_CTRL22_REG;
case PERIPH_PVT_MODULE:
@@ -178,7 +173,6 @@ static inline uint32_t periph_ll_get_rst_en_reg(periph_module_t periph)
case PERIPH_DMA2D_MODULE:
return HP_SYS_CLKRST_HP_RST_EN0_REG;
case PERIPH_PPA_MODULE:
case PERIPH_SYSTIMER_MODULE:
case PERIPH_UHCI_MODULE:
case PERIPH_I3C_MODULE:
case PERIPH_SARADC_MODULE:

View File

@@ -36,12 +36,40 @@ static inline void systimer_ll_set_clock_source(soc_periph_systimer_clk_src_t cl
/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance
#define systimer_ll_set_clock_source(...) (void)__DECLARE_RCC_ATOMIC_ENV; systimer_ll_set_clock_source(__VA_ARGS__)
static inline soc_periph_systimer_clk_src_t systimer_ll_get_clock_source(void)
{
return (HP_SYS_CLKRST.peri_clk_ctrl21.reg_systimer_clk_src_sel == 1) ? SYSTIMER_CLK_SRC_RC_FAST : SYSTIMER_CLK_SRC_XTAL;
}
/**
* @brief Enable the bus clock for systimer module
*
* @param enable true to enable, false to disable
*/
static inline void systimer_ll_enable_bus_clock(bool enable)
{
HP_SYS_CLKRST.soc_clk_ctrl2.reg_systimer_apb_clk_en = 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 systimer_ll_enable_bus_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; systimer_ll_enable_bus_clock(__VA_ARGS__)
/**
* @brief Reset the systimer module
*
* @param group_id Group ID
*/
static inline void systimer_ll_reset_register(void)
{
HP_SYS_CLKRST.hp_rst_en1.reg_rst_en_stimer = 1;
HP_SYS_CLKRST.hp_rst_en1.reg_rst_en_stimer = 0;
}
/// 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 systimer_ll_reset_register(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; systimer_ll_reset_register(__VA_ARGS__)
/********************** ETM *****************************/
__attribute__((always_inline)) static inline void systimer_ll_enable_etm(systimer_dev_t *dev, bool en)