Skip to content

MSPM0: RTC Support #90844

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

karthi012
Copy link
Contributor

This PR add real time clock support for Texas Instruments MSPM0 Family Series

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.

compatible: "ti,mspm0-rtc"

include:
- name: rtc.yaml
Copy link
Collaborator

Choose a reason for hiding this comment

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

only rtc-device.yaml should be included, rtc.yaml is an old relic :)


#define DT_DRV_COMPAT ti_mspm0_rtc

#include <errno.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

not needed since its part of zephyr/kernel.h :)

timeptr->tm_year = DL_RTC_Common_getCalendarYearBinary(cfg->base);
timeptr->tm_wday = DL_RTC_Common_getCalendarDayOfWeekBinary(cfg->base);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

remember to initialize remaining fields tm_nsec = 0, and tm_isdst = -1

Comment on lines 363 to 366
__disable_irq();
ret = alarm->is_pending ? 1 : 0;
alarm->is_pending = false;
__enable_irq();
Copy link
Collaborator

Choose a reason for hiding this comment

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

disable IRQ is not needed here as that is what a spinlock does, so you are already in a critical section here because of line 349 :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

also, this is not tracking (they key part), so it seems it could break the kernel by not restoring interrupt mask to correct state :) I have not seen __disable_irq() before

{
#if defined(CONFIG_RTC_ALARM)
uint8_t id;
uint32_t key = irq_lock();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use spinlock if needed :)

Comment on lines 396 to 381
alarm->is_pending = true;
if (alarm->callback) {
alarm->callback(dev, id, alarm->user_data);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Its safer to store the callback and user data in a local variable, reenable irqs as critical section is no longer needed, then call the callback. This way the callback is not called with irqs disabled (or more appropriately spinlock held) :)

Comment on lines 448 to 450
.base = (RTC_Regs *)DT_INST_REG_ADDR(n), \
.rtc_x = DT_INST_PROP(n, ti_rtc_x), \
.irq_config_func = ti_mspm0_config_irq_##n, \
Copy link
Collaborator

Choose a reason for hiding this comment

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

alingment here should be

static type sym = {
        .member = foo,
};

reg = <0x40094000 0x2000>;
interrupts = <30 0>;
prescaler = <1>;
clock-frequency = <32768>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing alarms-count = <2>; property inhereted from rtc-device.yaml :)

@parthitce parthitce linked an issue May 30, 2025 that may be closed by this pull request
karthi012 added 4 commits May 31, 2025 15:41
add Real-Time Clock binding for Texas Instruments MSPM0 Family

Signed-off-by: Karthikeyan Krishnasamy <karthikeyan@linumiz.com>
added Real-Time Clock driver support for Texas Instruments
MSPM0 Family

Signed-off-by: Karthikeyan Krishnasamy <karthikeyan@linumiz.com>
Add a rtc support for mspm0

Signed-off-by: Karthikeyan Krishnasamy <karthikeyan@linumiz.com>
Add rtc overlay for lp_mspm0g3507 to enable test coverage

Signed-off-by: Karthikeyan Krishnasamy <karthikeyan@linumiz.com>
@karthi012 karthi012 force-pushed the upstream/ti/mspm0-rtc branch from 4e49499 to bb57eaa Compare May 31, 2025 10:14
Copy link

@karthi012
Copy link
Contributor Author

@bjarki-andreasen Updated the changes. Please have a look

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

Successfully merging this pull request may close these issues.

RTC
2 participants