Open longfangsong opened 3 years ago
I'm not sure whether the implemention of sysctl_cpu_set_freq is right.
sysctl_cpu_set_freq
Not sure
In sysctl_cpu_set_freq, we set the pll0 like this:
sysctl_pll_set_freq(SYSCTL_PLL0, (sysctl->clk_sel0.aclk_divider_sel + 1) * 2 * freq);
So PLL0_freq = (sysctl->clk_sel0.aclk_divider_sel + 1) * 2 * CPU_FREQ, ie. CPU_FREQ = PLL0_freq / (2 * (sysctl->clk_sel0.aclk_divider_sel + 1))
PLL0_freq = (sysctl->clk_sel0.aclk_divider_sel + 1) * 2 * CPU_FREQ
CPU_FREQ = PLL0_freq / (2 * (sysctl->clk_sel0.aclk_divider_sel + 1))
But in sysctl_clock_get_freq:
sysctl_clock_get_freq
case SYSCTL_CLOCK_CPU: // ... source = sysctl_clock_source_get_freq(SYSCTL_SOURCE_PLL0) / (2ULL << sysctl_clock_get_threshold(SYSCTL_THRESHOLD_ACLK));
sysctl_clock_get_threshold(SYSCTL_THRESHOLD_ACLK) eval to sysctl->clk_sel0.aclk_divider_sel here
sysctl_clock_get_threshold(SYSCTL_THRESHOLD_ACLK)
sysctl->clk_sel0.aclk_divider_sel
So we have: CPU_FREQ = PLL0_freq / (2 << sysctl->clk_sel0.aclk_divider_sel)
CPU_FREQ = PLL0_freq / (2 << sysctl->clk_sel0.aclk_divider_sel)
Which is obviously different with the first fomula.
Did I missunderstood these code?
master
NA
I'm not sure whether the implemention of
sysctl_cpu_set_freq
is right.Expected behavior
Not sure
Actual behavior
Not sure
Code
In
sysctl_cpu_set_freq
, we set the pll0 like this:So
PLL0_freq = (sysctl->clk_sel0.aclk_divider_sel + 1) * 2 * CPU_FREQ
, ie.CPU_FREQ = PLL0_freq / (2 * (sysctl->clk_sel0.aclk_divider_sel + 1))
But in
sysctl_clock_get_freq
:sysctl_clock_get_threshold(SYSCTL_THRESHOLD_ACLK)
eval tosysctl->clk_sel0.aclk_divider_sel
hereSo we have:
CPU_FREQ = PLL0_freq / (2 << sysctl->clk_sel0.aclk_divider_sel)
Which is obviously different with the first fomula.
Did I missunderstood these code?
Document version
master
Hardware
NA
System
NA