-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 :)
dt_prop(clock-frequency PATH "/clocks/hfpll" PROPERTY "clock-frequency") | ||
math(EXPR clock_frequency_mhz "${clock_frequency} / 1000000") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
config SOC_NRF54LX_SKIP_CLOCK_CONFIG | ||
default y |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Kconfig skips the write to NRF_OSCILLATORS
:
https://github.com/zephyrproject-rtos/hal_nordic/blob/c563b0e56dfa7e3915637b12b3428e6de36012be/nrfx/mdk/system_nrf54l.c#L73
which may be necessary for certain targets - can you verify this works on L20 currently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PLL default is 64 MHz so skip is the same as setting to 64M. I checked that L20 i working correctly with that change.
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 <[email protected]>
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 <[email protected]>
e3978b4
to
1382123
Compare
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 changinghfpll
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.