Skip to content

Conversation

Holt-Sun
Copy link
Contributor

Create generic NXP RTC driver using Zephyr RTC driver model. The RTC driver invokes counter APIs. It can works with existing RTC counter drivers counter_mcux_rtc.c and counter_mcux_lpc_rtc.c.

@Holt-Sun
Copy link
Contributor Author

The twister build failure is caused by: cba0742#diff-db8ba35bdefd7627bfa4c2a0d7d13c9d1f20787ddf7181333981f6c01a32cc34

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.

Why is the counter based rtc driver not based on the counter API? It should not need to be specific to any vendor, that's what the APIs are there to abstract.

@Holt-Sun
Copy link
Contributor Author

Holt-Sun commented Aug 28, 2025

Why is the counter based rtc driver not based on the counter API? It should not need to be specific to any vendor, that's what the APIs are there to abstract.

@bjarki-andreasen Do you mean the "set_calibration", "get_calibration"? There are no such corresponding APIs in counter driver model. All other APIs are using counter APIs.

Or I miss understand anything? If so, please be more specific.

@bjarki-andreasen
Copy link
Contributor

Why is the counter based rtc driver not based on the counter API? It should not need to be specific to any vendor, that's what the APIs are there to abstract.

@bjarki-andreasen Do you mean the "set_calibration", "get_calibration"? There are no such corresponding APIs in counter driver model. All other APIs are using counter APIs.

Or I miss understand anything? If so, please be more specific.

Yes, fsl anything should not be in a generic counter to rtc wrapper. Keyword here is generic. If the counter API is missing a feature, like calibration it would seem, that should be added to the counter API first, then the generic wrapper can wrap it.

@Holt-Sun Holt-Sun force-pushed the gaps-generic-rtc-using-counter-api branch from 838fb61 to b06d820 Compare August 28, 2025 12:56
@Holt-Sun Holt-Sun force-pushed the gaps-generic-rtc-using-counter-api branch from 90f26ec to 79a8187 Compare September 1, 2025 09:56
@Holt-Sun Holt-Sun requested a review from pdgendt September 1, 2025 09:59
@JarmouniA
Copy link
Contributor

JarmouniA commented Sep 1, 2025

@sylvioalves Your input would be useful here I think since ESP32 can also use this new driver to provide Zephyr RTC API, following the rejection of #92253

@Holt-Sun Holt-Sun force-pushed the gaps-generic-rtc-using-counter-api branch from 79a8187 to cb69f1d Compare September 1, 2025 10:09
@Holt-Sun Holt-Sun requested a review from pdgendt September 1, 2025 10:10
@pdgendt
Copy link
Contributor

pdgendt commented Sep 1, 2025

Need to fix the compliance check here

@Holt-Sun Holt-Sun force-pushed the gaps-generic-rtc-using-counter-api branch from cb69f1d to 57cc2e5 Compare September 1, 2025 13:42
@JarmouniA JarmouniA changed the title Gaps generic rtc using counter api Drivers: RTC: introduce Counter-based generic driver Sep 1, 2025
Add new zephyr,counter-rtc.yaml for virtual RTC device wrapping
counter APIs

Signed-off-by: Holt Sun <[email protected]>
Fix some build warning.

Signed-off-by: Holt Sun <[email protected]>
@Holt-Sun Holt-Sun force-pushed the gaps-generic-rtc-using-counter-api branch from 57cc2e5 to a381a40 Compare September 3, 2025 08:38
@nandojve nandojve changed the title Drivers: RTC: introduce Counter-based generic driver Drivers: RTC: NXP: introduce Counter-based generic driver Sep 3, 2025
@Holt-Sun Holt-Sun requested a review from sylvioalves September 3, 2025 08:48
Counter RTC driver is written using the counter API as a
target instead of a hardware. It can adapt to all RTC
device without broken-down time register but with counter.

Signed-off-by: Holt Sun <[email protected]>
Add counter_rtc in nxp device and board.

Signed-off-by: Holt Sun <[email protected]>
Add confs for nxp boards.

Signed-off-by: Holt Sun <[email protected]>
Add rtc test confs for nxp boards.

Signed-off-by: Holt Sun <[email protected]>
@Holt-Sun Holt-Sun force-pushed the gaps-generic-rtc-using-counter-api branch from a381a40 to 9929a45 Compare September 3, 2025 13:23
@Holt-Sun Holt-Sun requested a review from pdgendt September 3, 2025 13:23
Copy link

sonarqubecloud bot commented Sep 3, 2025

return -EINVAL;
}

const struct counter_rtc_config *config = dev->config;
Copy link
Contributor

Choose a reason for hiding this comment

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

For the sake of code organization, would you mind moving all declarations/variables (specially all those struct) to the beginning of the function?

Comment on lines +172 to +173
static int counter_rtc_alarm_get_supported_fields(const struct device *dev, uint16_t id,
uint16_t *mask)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't you map the id to an alarm channel? For example NXP's SNVS RTC (Real Time Counter) has 2 channels, HP (High Power) and LP (Low Power)

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

Successfully merging this pull request may close these issues.

8 participants