- Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: clock_control: nrf driver reimplementation #17293
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
drivers: clock_control: nrf driver reimplementation #17293
Conversation
| All checks are passing now. Review history of this comment for details about previous failed status. |
9026473 to e320b09 Compare 604cbae to 8de2f92 Compare
anangl left a comment
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.
Just some initial comments. I'll need some more time to dive into nrf_power_clock.c.
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.
missing CONFIG_ before TEMP_NRF5
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
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.
staticmissing- you should use
K_WORK_DEFINEfor this initialization
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
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.
Do we really need to involve floats here? The sensor's resolution is 0.25 °C, so multiplying by 4 should be sufficient.
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.
changed to work in 0,25 degree units. Also modified kconfig option to use same units which allows to chose fractional temperature diff that will trigger calibration.
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.
k_work_submit(&temp_measure_work);
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.
done
drivers/timer/nrf_rtc_timer.c Outdated
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.
NULL, just for consistency.
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.
done
drivers/sensor/nrf5/temp_nrf5.c Outdated
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.
0 -> NULL, for consistency, same below
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.
done
drivers/sensor/nrf5/temp_nrf5.c Outdated
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.
static missing
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.
done
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.
NRF_POWER_HAS_POFCON is defined in <nrf_power.h>, which may not have been included yet.
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.
now nrf_power.h is always included.
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.
I guess it would be better to place this initial | after NRF_CLOCK_INT_LF_STARTED_MASK above and use (0) as the "else" part.
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.
done
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.
Why is it defined as atomic_t when atomic API is not used for this field?
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.
changed to s32_t
| @nordic-krch In https://github.com/aescolar/zephyr/tree/clock_control_calibration_fix you have this branch with a couple of updates for simulation and rebased on top of #17301 . With it the nrf52_bsim works nicely |
8de2f92 to 4dc534d Compare | It's been out for 3 months. There are 3 approvals. @carlescufi @ioannisg can we merge this then unless someone plans to review it soon? |
| For the record, I have no issue with this PR. The only file changed I own is perfectly fine. But as this is a Nordic only change, I do not believe I should approve it. I presume BT and USB maintainers would have a similar feeling as the BT and USB code changes are minor and circumstantial. |
I would appreciate if @pabigot could re-review once more (and approve if possible). I guess we can merge this afterwards ;) |
pabigot left a comment
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.
My comments appear to have been addressed. I haven't tested this or done an in-depth functional review so don't feel comfortable "approving" it, but I don't see any reason it should be kept out.
| I haven't looked much at the code, this switch to zephyr is all new to me, so I am still confused. So so this is more a question than a suggestion. After this PR we will still use the Calibration timer in the NRF_CLOCK peripheral right? how easy would it be to switch to using some other source for the periodic timer to drive the calibration state machine in zephyr world? we always wanted to do that in SoftDevice, but never did. The calibration timer in in NRF_CLOCK has some big awkward weaknesses, since some register can not be written withing the same 32khz clock cycle as some things happens. Another reason to stop using the calibration timer, is that we want to remove it from the chip, to save silicon, if sw could do without it. |
| @martintv i don't see any obstacles. In the next step we can replace calibration timer with k_timer. |
Your description is still blocking this PR @nordic-krch. |
The incomming new NRF clock driver requires extra nrf HAL and drivers functions, which are only supported in the HW models after version 1.8 Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
1735cec to 364818b Compare | @ioannisg, done. |
carlescufi left a comment
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.
I tested the following:
central_hron nRF51 DKperipheral(complete with bonding and reconnection) on nRF51 DKcentral_hron BBC micro:bitperipheral_hron BBC micro:bit
| There is by default a lot of info lines being printed. Can we change the settings so that that doesn't happen? Tested connections using 2 nrf52840. and 500 PPM, works fine. |
I saw that as well, I assumed this was my config but now that @joerchan also brings it up I think this is worth cleaning up. @nordic-krch could you please disable those by default? |
Reimplementation of clock control driver for nrf platform. It includes latest API changes: asynchronous starting and getting clock status. Additionally, it implements calibration algorithm which optionally skips calibration based on no temperature change. Internal temperature sensor is used for that. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added test suite for clock control driver. It covers latest API update for starting clock asynchronously and getting status. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added test for LF clock calibration when RC source is used. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Align to use clock_control_get_status for blocking clock start. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Align drivers to use new clock control API. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Test for bbc_microbit was failing due to RAM usage. Reduced main stack size and turned off temperature algorithm to fit. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
364818b to 7b6754d Compare | @carlescufi @joerchan removed those log calls. @carlescufi I've reduced irq locking time. Additionally, i did measurement to check longest locking time in clock driver vs other lockings (used peripheral_hr sample for that). Clock locking is up to 1.4us while there are many many more longer lockings (up to 2.5ms which seems very odd). In general locking in clock is one of the shortest. |
Thank you @nordic-krch. I will merge this as soon as CI passes. |
Clock_control has been re-implemented to support new clock control API and calibration algorithm which optionally uses temperature sensor and skips calibration on no temperature change.
Fixes #12114