Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(esp_clk_tree): SOC_MOD_CLK_REF_TICK now uses the corresponding de… (IDFGH-13580) #14468

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/esp_hw_support/port/esp32/esp_clk_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ uint32_t *freq_value)
clk_src_freq = esp_clk_tree_xtal32k_get_freq_hz(precision);
break;
case SOC_MOD_CLK_REF_TICK:
clk_src_freq = 1 * MHZ;
clk_src_freq = REF_CLK_FREQ;
break;
case SOC_MOD_CLK_APLL:
clk_src_freq = clk_hal_apll_get_freq_hz();
Expand Down
2 changes: 1 addition & 1 deletion components/esp_hw_support/port/esp32s2/esp_clk_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ uint32_t *freq_value)
clk_src_freq = esp_clk_tree_xtal32k_get_freq_hz(precision);
break;
case SOC_MOD_CLK_REF_TICK:
clk_src_freq = 1 * MHZ;
clk_src_freq = REF_CLK_FREQ;
break;
case SOC_MOD_CLK_APLL:
clk_src_freq = clk_hal_apll_get_freq_hz();
Expand Down
12 changes: 6 additions & 6 deletions components/hal/esp32/include/hal/clk_tree_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,31 +669,31 @@ static inline __attribute__((always_inline)) uint32_t clk_ll_cpu_get_divider_fro
}

/**
* @brief Set REF_TICK divider to make REF_TICK frequency at 1MHz
* @brief Set REF_TICK divider to make REF_TICK frequency at REF_CLK_FREQ
*
* @param cpu_clk_src Selected CPU clock source (one of soc_cpu_clk_src_t values)
* @param cpu_freq_mhz CPU frequency value, in MHz
*
* Divider = APB_CLK freq in Hz / 1MHz. Value in register = divider - 1.
* Divider = APB_CLK freq in Hz / (REF_CLK_FREQ / MHZ). Value in register = divider - 1.
*/
static inline __attribute__((always_inline)) void clk_ll_ref_tick_set_divider(soc_cpu_clk_src_t cpu_clk_src, uint32_t cpu_freq_mhz)
{
uint32_t apb_freq_mhz;
switch (cpu_clk_src) {
case SOC_CPU_CLK_SRC_XTAL:
apb_freq_mhz = cpu_freq_mhz;
apb_freq_mhz = cpu_freq_mhz / (REF_CLK_FREQ / MHZ);
REG_WRITE(SYSCON_XTAL_TICK_CONF_REG, apb_freq_mhz - 1);
break;
case SOC_CPU_CLK_SRC_PLL:
apb_freq_mhz = 80;
apb_freq_mhz = 80 / (REF_CLK_FREQ / MHZ);
REG_WRITE(SYSCON_PLL_TICK_CONF_REG, apb_freq_mhz - 1);
break;
case SOC_CPU_CLK_SRC_RC_FAST:
apb_freq_mhz = cpu_freq_mhz;
apb_freq_mhz = cpu_freq_mhz / (REF_CLK_FREQ / MHZ);
REG_WRITE(SYSCON_CK8M_TICK_CONF_REG, apb_freq_mhz - 1);
break;
case SOC_CPU_CLK_SRC_APLL:
apb_freq_mhz = cpu_freq_mhz >> 1;
apb_freq_mhz = (cpu_freq_mhz / (REF_CLK_FREQ / MHZ)) >> 1;
REG_WRITE(SYSCON_APLL_TICK_CONF_REG, apb_freq_mhz - 1);
break;
default:
Expand Down
Loading