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

Question: sysctl_cpu_set_freq and sysctl_clock_get_freq for CPU seems not match #120

Open
longfangsong opened this issue Jan 27, 2021 · 0 comments

Comments

@longfangsong
Copy link

longfangsong commented Jan 27, 2021

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:

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))

But in 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

So 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant