Skip to content

Conversation

Holt-Sun
Copy link
Contributor

@Holt-Sun Holt-Sun commented Oct 14, 2025

Update snvs rtc for generic rtc driver.
Enable it for RT10xx boards: samples and tests.

EmilioCBen
EmilioCBen previously approved these changes Oct 14, 2025
Comment on lines 52 to 55
SNVS_HP_RTC_EnableInterrupts(config->base, kSNVS_RTC_AlarmInterrupt);
#ifdef MCUX_SNVS_SRTC
SNVS_LP_SRTC_EnableInterrupts(config->base, kSNVS_SRTC_AlarmInterrupt);
#endif
Copy link
Member

Choose a reason for hiding this comment

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

nit: you could #define SNVS_ALARM_INERRUPT or something to the right value in one place instead of repeating this #ifdef MCUX_SNVS_SRTC in multiple places of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated: add SRTC helper macros.

Comment on lines 230 to 231
cb = data->alarm_hp_rtc_callback;
data->alarm_hp_rtc_callback = NULL;
Copy link
Member

Choose a reason for hiding this comment

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

I think I don't have the context, but why are you setting the stored callback pointer to null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Counter API semantics (counter.h) say alarms are single-shot: “After expiration … channel is considered available and can be set again.” Drivers must clear their “alarm active” state so counter_set_channel_alarm can succeed again. Calling mcux_snvs_cancel_alarm() inside the ISR is not ideal (it busy-waits on HPCR/LPCR bits). Nulling the stored callback is the more common way, many Zephyr drivers do this way(e.g., mcux_rtc.c, mcux_lpc_rtc.c, mcux_gpt.c, mcux_ctimer.c).

mcux_snvs_cancel_alarm(dev, 0);
cb = data->alarm_hp_rtc_callback;
data->alarm_hp_rtc_callback = NULL;
cb(dev, 0, current, data->alarm_hp_rtc_user_data);
Copy link
Member

Choose a reason for hiding this comment

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

check for null pointer first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, NXP
* Copyright (c) 2018,2025 NXP
Copy link
Member

Choose a reason for hiding this comment

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

remove (c) and put a space after the comma.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@@ -1,5 +1,5 @@
/*
* Copyright 2017,2023,2024 NXP
* Copyright 2017,2023,2024,2025 NXP
Copy link
Member

Choose a reason for hiding this comment

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

put spaces after commas

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to "2017, 2023-2025".

dvp_fpc24_interface: &csi {};

&snvs_rtc {
status = "okay";
Copy link
Member

Choose a reason for hiding this comment

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

this one looks redundant, it looks not disabled in the soc dtsi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

Comment on lines +1 to +8
#
# Copyright 2025 NXP
#
# SPDX-License-Identifier: Apache-2.0
#

CONFIG_RTC_ALARM=y
CONFIG_RTC_INIT_PRIORITY=70
Copy link
Member

Choose a reason for hiding this comment

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

IMO squash overlay to previous (board) commit, we dont want to bloat the commit log with habit of putting an overlay for a test of a feature in another commit as where the feature is added, this is really not necessary, it's a routine basic part of enabling the feature on a board

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have enabled all RT10xx boards, so I reorganize the commits. Please review again.

Comment on lines 1 to 9
#
# Copyright 2025 NXP
#
# SPDX-License-Identifier: Apache-2.0
#

CONFIG_RTC_ALARM=y
CONFIG_RTC_INIT_PRIORITY=70
CONFIG_TEST_RTC_ALARM_TIME_MASK=255
Copy link
Member

Choose a reason for hiding this comment

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

two commits each for an overlay, squash to the board commit. there should only be 2 commits on this PR, not 4. We don't need a commit for every file added, that is too much. A commit is for a reviewable and isolatable and complete unit of work. These tiny overlay is part of the work of enabling the feature on the board.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have enabled all RT10xx boards, so I reorganize the commits. Please review again.

@Holt-Sun Holt-Sun force-pushed the update-rt1064-snvs-rtc-for-generic-rtc-driver branch from b033e53 to 089bd2d Compare October 15, 2025 10:08
@Holt-Sun Holt-Sun changed the title Update mimxrt1064 snvs rtc for generic rtc driver Update snvs rtc for generic rtc driver and enable it for RT10xx boards Oct 15, 2025
@Holt-Sun Holt-Sun requested review from EmilioCBen and decsny October 15, 2025 10:12
Copy link
Contributor

@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.

The board using the "virtual" RTC to the rtc api test suite must be redundant, it should work with any counter, and should be tested using FFF. If the counter test suites pass, the RTC API test will also pass if the rtc_counter has been tested well enough.

@decsny
Copy link
Member

decsny commented Oct 15, 2025

@Holt-Sun since the test overlay are all the same, i would look to make a testcase in the .yaml instead, I think bjarki is blocking because all the overlay can get annoying

@Holt-Sun Holt-Sun force-pushed the update-rt1064-snvs-rtc-for-generic-rtc-driver branch from 089bd2d to 9029b4a Compare October 15, 2025 14:07
@Holt-Sun
Copy link
Contributor Author

Holt-Sun commented Oct 15, 2025

The board using the "virtual" RTC to the rtc api test suite must be redundant, it should work with any counter, and should be tested using FFF. If the counter test suites pass, the RTC API test will also pass if the rtc_counter has been tested well enough.

Not exactly, the rtc_counter APIs have limitation, like it cannot support frequency not equal 1. When I enable a new platform, the counter test cases all run passed but RTC test cases run failed.
As suggested by @decsny , I add a new test case and deprecate the conf in rtc test folder. Now it is more clear. Please review.

@Holt-Sun
Copy link
Contributor Author

@Holt-Sun since the test overlay are all the same, i would look to make a testcase in the .yaml instead, I think bjarki is blocking because all the overlay can get annoying

Good suggestion, updated.

@Holt-Sun Holt-Sun force-pushed the update-rt1064-snvs-rtc-for-generic-rtc-driver branch from 9029b4a to 0873a20 Compare October 15, 2025 14:35
Copy link
Contributor

@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.

ok, I like this better, though still not a fan of testing a purely software feature with real hardware, better than not testing it, but it makes it hard to see if an issue is with the hardware or rtc counter wrapper if something fails

decsny
decsny previously approved these changes Oct 15, 2025
@EmilioCBen
Copy link
Contributor

EmilioCBen commented Oct 15, 2025

@Holt-Sun Please add
- rtc
to the board.yaml files or twister will not pick up on the tests for running.

Copy link
Contributor

@EmilioCBen EmilioCBen left a comment

Choose a reason for hiding this comment

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

Blocking on adding the rtc to the board.yaml as mentioned above.

1. Add SRTC helper macros.
2. Implement start/stop APIs.

Signed-off-by: Holt Sun <[email protected]>
The counter_rtc child node is for rtc-counter.

Signed-off-by: Holt Sun <[email protected]>
enable SNVS counter_rtc for mimxrt10xx board.

Signed-off-by: Holt Sun <[email protected]>
Add "rtc" into supported board.yaml.

Signed-off-by: Holt Sun <[email protected]>
enable alarm and init priority for mimxrt10xx
sample/drivers/rtc

Signed-off-by: Holt Sun <[email protected]>
@Holt-Sun Holt-Sun dismissed stale reviews from decsny and bjarki-andreasen via 649e73c October 16, 2025 04:51
@Holt-Sun Holt-Sun force-pushed the update-rt1064-snvs-rtc-for-generic-rtc-driver branch from 0873a20 to 649e73c Compare October 16, 2025 04:51
@Holt-Sun Holt-Sun force-pushed the update-rt1064-snvs-rtc-for-generic-rtc-driver branch from 649e73c to 8ca451e Compare October 16, 2025 05:38
add drivers.rtc.rtc_api.rtc_counter test case
for counter rtc.

Signed-off-by: Holt Sun <[email protected]>
@Holt-Sun Holt-Sun force-pushed the update-rt1064-snvs-rtc-for-generic-rtc-driver branch from 8ca451e to 20f6af6 Compare October 16, 2025 06:34
Copy link

@Holt-Sun Holt-Sun requested review from EmilioCBen and decsny October 16, 2025 07:42
@cfriedt cfriedt merged commit 69cdf19 into zephyrproject-rtos:main Oct 16, 2025
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Boards/SoCs area: Counter area: RTC Real Time Clock area: Samples Samples area: Tests Issues related to a particular existing or missing test platform: NXP MCU platform: NXP NXP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants