Skip to content

am243x_evm/am2434/r50_0: configure timer clock source#101283

Closed
natto1784 wants to merge 1 commit into
zephyrproject-rtos:mainfrom
natto1784:dmtimer_source
Closed

am243x_evm/am2434/r50_0: configure timer clock source#101283
natto1784 wants to merge 1 commit into
zephyrproject-rtos:mainfrom
natto1784:dmtimer_source

Conversation

@natto1784
Copy link
Copy Markdown
Contributor

Write the protected MMR region during early init to select the correct clock source for the specified timer. To get the correct offset, recognize the timer currently in use via the DT alias system-timer. Then we do some soc-specific calculations to configure this source. This can be removed once there are clock control APIs to set parent sources in place.

Write the protected MMR region during early init to select the correct
clock source for the specified timer. To get the correct offset,
recognize the timer currently in use via the DT alias
system-timer. Then we do some soc-specific calculations to configure
this source. This can be removed once there are clock control APIs to set
parent sources in place.

Signed-off-by: Amneesh Singh <amneesh@ti.com>
@zephyrbot zephyrbot added area: Boards/SoCs platform: TI K3 Texas Instruments Keystone 3 Processors labels Dec 18, 2025
#define MAIN_PADCFG_BASE (0xf0000)
#define MAIN_MMR_BASE (0x43000000)
#define MAIN_MMR_TIMER_CLKSEL_PART CTRL_PARTITION(MAIN_MMR_BASE, 2)
#define MAIN_MMR_TIMER_CLKSEL_VAL (0x0) /* HFOSC0_CLKOUT */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how about r50_1? Do we need to have separate the handling for it?
also the question here is, the parent is same for all timers, i think timer source macro can be irrespective of config.
because there is same set of parents for all timers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

how about r50_1? Do we need to have separate the handling for it?

When R50_1 support will be added, we will have a common option for all cores - something along the lines of CONFIG_SOC_AM2434_R5F, which would apply for all cores. That can be used here then.

also the question here is, the parent is same for all timers

The parent is same but the register offset for every timer is different, which is why we are getting data from DT to see which timer instance is being used.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Understood, i think i was worried about so many custom conf macros to handle combinations, this is fine for now, may be a path ahead to use a syscon driver.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It might be a good time to add the other R5F cores for AM243x, just to make sure we are not making any bad assumptions that only apply to R5F0_0 (even if that might not be the case this time). AM64x has all the R5F cores, no reason to not have them for AM243x.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is true, will do in another patchset

aliases {
led0 = &ld26;
adc0 = &main_adc0;
system-timer = &main_timer8;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The way the system timer is selected currently is by being the 0th enabled timer instance. So as ugly as it would be you could also match this logic by doing DT_INST(inst, ti_am654_timer) to find the timer instance used as the system timer without adding this alias.

That said, we need to fix how we select the system timer, and it was probably going to be by adding an alias like this above. So this is fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi, apologies, I was on vacation - yes, we can also use instance 0 to get the selected timer, and I 100% agree that this is ugly. As a note, we need two things in the future -

  1. A syscon mechanism that can be used for modifying control partitions and get rid of this file. Pinmuxing would also utilize this very driver.
  2. A set_parent clock API in the driver subsystem

As for the alias name I thought system-timer would fit. If there are any other suggestions, please tell.

@nashif
Copy link
Copy Markdown
Member

nashif commented Mar 19, 2026

can you rebase please?

@natto1784
Copy link
Copy Markdown
Contributor Author

can you rebase please?

Hi, apologies, but I will be closing this in favor of a solution based on - #103330

Thanks

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

Labels

area: Boards/SoCs platform: TI K3 Texas Instruments Keystone 3 Processors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants