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

Drivers: RTC: Initial implementation of RTC for IFX cyw920829m2evk_02 platform #79343

Merged

Conversation

mcatee-infineon
Copy link
Contributor

- Initial driver implementation
          - Basic set/get and calibration
- Overlay for rtc_api test
- dtsi updates.
- board updates

drivers/rtc/rtc_ifx_cat1.c Outdated Show resolved Hide resolved
drivers/rtc/rtc_ifx_cat1.c Outdated Show resolved Hide resolved
Comment on lines 165 to 169
if (Cy_RTC_IsExternalResetOccurred()) {
/* Reset to default time */
Cy_RTC_SetDateAndTime(&default_time);
_ifx_cat1_rtc_set_century(_IFX_CAT1_RTC_INIT_CENTURY);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The expected behavior of the RTC is to return -ENODATA until the time has actually been set to a valid value, rather than defaulting to a pseudo random value.

The init function should just do the minimal amount of init, like configuring the IRQ. Setting the time is done with rtc_set_time() at which point the RTC's time will be initialized to a valid value

drivers/rtc/rtc_ifx_cat1.c Show resolved Hide resolved
drivers/rtc/rtc_ifx_cat1.c Outdated Show resolved Hide resolved
@ifyall
Copy link
Collaborator

ifyall commented Oct 3, 2024

Just wanted to say thanks to @bjarki-andreasen for the detailed review!

@bjarki-andreasen
Copy link
Collaborator

Just wanted to say thanks to @bjarki-andreasen for the detailed review!

happy to help :)

@mcatee-infineon
Copy link
Contributor Author

@bjarki-andreasen and @npal-cy, thank you for your feedback. I have pushed up updates that should address your concerns. I have done so in the form of a second commit so that changes are clear. If you both find the new version acceptable, I will then be sure to squash the commits together. Once again, thank you for your feedback.

@mcatee-infineon mcatee-infineon force-pushed the ifx-cat1-rtc-driver branch 4 times, most recently from a963e4a to 2a3ffc5 Compare October 3, 2024 21:41
npal-cy
npal-cy previously approved these changes Oct 4, 2024
@@ -87,7 +93,8 @@ struct ifx_cat1_rtc_config {
};

struct ifx_cat1_rtc_data {
struct k_mutex lock;
struct k_spinlock lock;
bool valid_time_set;
Copy link
Collaborator

@bjarki-andreasen bjarki-andreasen Oct 4, 2024

Choose a reason for hiding this comment

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

I believe this var should be replaced by checking the state of the RTC by looking at its registers, a quick search for a HAL for the RTC https://infineon.github.io/mtb-hal-cat1/html/group__group__hal__rtc.html#gac6891d0e8b9de6c32f46f179aa32b800 (I could not find a reference manual) does indicate the RTC can survive a system reset, and it is possible to check if the time has been set and RTC is counting. By reading the RTC, if the time was set before the system was reset, rtc_get_time() would work after reset without setting the time, which is not possible if the valid_time_set is stored in RAM, since it is reset every time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bjarki-andreasen, I have squashed the old verification commit and replaced it with a new one for review. It should resolve this concern.

drivers/rtc/rtc_ifx_cat1.c Outdated Show resolved Hide resolved
drivers/rtc/rtc_ifx_cat1.c Show resolved Hide resolved
drivers/rtc/rtc_ifx_cat1.c Show resolved Hide resolved
@mcatee-infineon mcatee-infineon force-pushed the ifx-cat1-rtc-driver branch 2 times, most recently from 82e872d to 186e9ce Compare October 7, 2024 19:42
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.

a little nit, otherwise I think it looks good, just to clarify, have you run the RTC test suite with RTC_CALIBRATION=y and validated the set/get values?

Comment on lines 91 to 93
struct ifx_cat1_rtc_config {
uint32_t irqn;
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

this not not actually used, you can remove it, along with its instance in the CAT1_RTC_INIT macro :) save a whole 4 bytes of memory :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great! Thank you @bjarki-andreasen. This final version of the "verification commit" should resolve this. As for calibration, the test has been ran and the results were as expected.

ifyall
ifyall previously approved these changes Oct 8, 2024
	- Initial driver implementation
	- Overlay for rtc_api test
	- dtsi updates.

Signed-off-by: McAtee Maxwell (CSS ICW SW MTO INT 2) <[email protected]>
	- verify code changes from PR review

Signed-off-by: McAtee Maxwell <[email protected]>
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.

Nice work!

@aescolar aescolar merged commit 61b0009 into zephyrproject-rtos:main Oct 9, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: RTC Real Time Clock platform: Infineon Infineon Technologies AG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants