8000 drivers:timer:cdns zcu102 timer driver using cadence TTC device by Willmish · Pull Request #407 · au-ts/sddf · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

drivers:timer:cdns zcu102 timer driver using cadence TTC device #407

New issue 8000

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 12 commits into
base: main
Choose a base branch
from

Conversation

Willmish
Copy link
Contributor
@Willmish Willmish commented Apr 14, 2025

Adds the cadence Triple Timer Counter (TTC) based timer driver.

Caveats:

  • max timeout allowed: ~2min 51.799s (can be extended sacrificing resolution, atm uses 25MHz clock)
  • Clock source not touched, by default uses LSBUS clock, which is downscaled from IOPLL clock (which in turn is upscaled from main source clock) - will need to be changed when clock driver introduced/any clock modifications will be done.

Draft because of the following:

  • TODO: update the drivers.md doc: https://github.com/au-ts/sddf/blob/main/docs/drivers.md
  • race condition on delivering overflow IRQ when happened during timeout IRQ (see comments) (Separate to drivers:timer:jh7110: prevent potential race #403)
  • TODO: rename ZCU102_ defines to begin with ZYNQMP_ (SoC specific rather than dev board specific)
  • Done, for now assumes the IOPLL clock is untouched after boot and set to 1.5GHz, and used as source downscaled by factor of 15 for the TTC counters need to ensure Clock used for the counter is always set to 100MHz/use a different one
  • Done, downscaled freq to 25MHz (now max timeout is larger and overflowing happens every ~2min 52s) ~~add clock frequency downscaling (for lower resolution but rarer interrupts for 32-bit timer overflow, currently every ~42s)~~
  • Done clean up serial driver skeleton code

@Willmish Willmish force-pushed the zcu102 branch 3 times, most recently from 9275852 to 24bf7c4 Compare April 15, 2025 03:38
@Willmish Willmish marked this pull request as ready for review May 1, 2025 07:20
@Willmish Willmish requested a review from Ivan-Velickovic May 2, 2025 02:58
@Ivan-Velickovic
Copy link
Collaborator

I'll wait until we're both in the lab together to review this. It will be much easier/quicker to do it in person.

* the LSBUS clock in the Low Power Domain, (controlled by LPD_LSBUS_CTRL).
*/
/* TODO:
* More graceful error when user requests timeout greater than served by ZCU102_TIMER_MAX_TICKS (at 25MHz (downscaled), 32-bit counter thats ~2min 51.799s)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't the driver just handle this kind of timeout by waiting for multiple hardware-level timeouts? I thought that's how the other drivers worked.

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 was looking for how to handle this, and went for the most simple solution based on how jh7110 driver handles this case: https://github.com/au-ts/sddf/blob/main/drivers/timer/jh7110/timer.c#L132

I can rewrite it to handle longer timeouts as you've suggested for both the drivers, just some more logic will be needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay I guess I was lazy with that timer driver.

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'll add a fix for that in both then, shouldn't be too difficult.

Ivan-Velickovic and others added 12 commits June 30, 2025 14:10
build.zig zcu102

Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
Signed-off-by: Szymon Duchniewicz <s.duchniewicz@unsw.edu.au>
Signed-off-by: Szymon Duchniewicz <s.duchniewicz@unsw.edu.au>
* debugging undelivered IRQ on race condition
* update client to spam timeouts (1us)
* update print messages

Example race cond with no IRQ:
CLIENT|INFO: Now the time (in nanoseconds) is: 212911778590 i: 21000000
RACE CONDITION: get_ticks_in_ns incrementing counter_timer_elapses
boop
CLIENT|INFO: Now the time (in nanoseconds) is: 223063550190 i: 22000000

Example race cond with IRQ:
CLIENT|INFO: Now the time (in nanoseconds) is: 294058739400 i: 29000000
RACE CONDITION: get_ticks_in_ns incrementing counter_timer_elapses
boop
RACE CONDITION: counter_timer_elapses alread yincremented!
CLIENT|INFO: Now the time (in nanoseconds) is: 304214590370 i: 30000000

Signed-off-by: Szymon Duchniewicz <s.duchniewicz@unsw.edu.au>
Signed-off-by: Szymon Duchniewicz <s.duchniewicz@unsw.edu.au>
Signed-off-by: Szymon Duchniewicz <s.duchniewicz@unsw.edu.au>
Signed-off-by: Szymon Duchniewicz <s.duchniewicz@unsw.edu.au>
Signed-off-by: Szymon Duchniewicz <s.duchniewicz@unsw.edu.au>
* As no clock driver implemented yet, assumes the clock frequencies are
  untouched and left as default by u-boot (100MHz for LSBUS clock)
* Ensures prescaler is always clamped to 0xf

Signed-off-by: Szymon Duchniewicz <s.duchniewicz@unsw.edu.au>
Signed-off-by: Szymon Duchniewicz <s.duchniewicz@unsw.edu.au>
Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
Signed-off-by: Ivan-Velickovic <i.velickovic@unsw.edu.au>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0