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

Add clocks property to CPUs in nRF54L series which can be used to get CPU clock frequency #83527

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nordic-krch
Copy link
Contributor

nRF54L CPUs and fast peripherals can run at 64 MHz or 128 MHz. So far DT was indicating that CPU is running at 128 MHz and changing that to 64 MHz did not result in changing actual CPU frequency. On the other hand to use 64 MHz a cryptic Kconfig had to be set (CONFIG_SOC_NRF54LX_SKIP_CLOCK_CONFIG=y).

Added clocks = <&hfpll> property to CPU cores in nRF54L and reworked cmake file so that changing hfpll frequency in DT results in changing CPU frequency.

#82901 is adding same property to TIMERs so that there will be a single source of truth regarding frequency of peripherals clocked by the same source.

Add clocks property to CPUs. nRF54Lx series is using hfpll as clock
source for CPU (and fast peripherals). CPU clock frequency can be
derived from frequency of the source clock so clock-frequency property
is removed from cpu as it is redundant.

nrfx/MDK expects that NRF_CONFIG_CPU_FREQ_MHZ define is set to correct
CPU frequency. Modified nrfx CMakeLists.txt to use clock frequency of
hfpll instead of CPU clock-frequency property.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
nrf54l20pdk must use 64 MHz for now. So far it was done by using
SOC_NRF54LX_SKIP_CLOCK_CONFIG Kconfig option which was skipping
oscillator configuration so that it was running the default frequency
(which is 64 MHz). This approach was a bit cryptic because DT was
indicating that CPU was running 128 MHz when actual frequency was
different (and it was relying on assumption that default frequency
is 64 MHz).

After adding hfpll as clock source for CPU Kconfig option can
be replaced with DT setting where actual frequency is correctly
indicated. Since hfpll is a clock source for fast peripherals (e.g.
TIMER00) it is possible to have single source of information
regarding frequency.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
Copy link
Collaborator

@bjarki-andreasen bjarki-andreasen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, apart from the possible typo :)

Comment on lines +187 to 188
dt_prop(clock-frequency PATH "/clocks/hfpll" PROPERTY "clock-frequency")
math(EXPR clock_frequency_mhz "${clock_frequency} / 1000000")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clock-frequency on line 187 has a dash in it, ${clock_frequency} on line 188 does not, is this expected?

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

Successfully merging this pull request may close these issues.

4 participants