Skip to contentSkip to conversation

Writing clocksource driver, tips?

DISCUSSION Oleksij Rempel 2 participants 2 messages Aug 31, 2014 – Sep 1, 2014

lore
Share & tools
lore
#0 lore raw

Hello all,

currently i work on porting linux to Aplscale ASM9260,
most basic parts are done, now is the time for clocksource driver. I never did it before, so i need some beginner tips.
My current driver clocksource provide periodic events at 100Hz rate. But this hardvare can do more then it.
This SoC has 4 32bit-timer controller attached to 100MHz source. Each controller has 4 separate timer register each of them can be configure separately for scale, match and interrupt. 3 controllers can choice the tick source.
This controller looks similar to one found on NXP LPC1311, but looks like no similar hardware in drivers/clocksource.

For now i have fallowing questions:
- 1 timer can be used for clocksource other as clock_event_device, how can i use other 2 timers on same controller. and how can i use other 3 controllers?
- theoretically i can use clocksource_mmio_init to read directly timer_counter_register. Which scale should be used on it. 100MHz is probably too match.
- should clocksource provide interrupt on overflow or some kind of limit?

Signature · 2 lines
Regards,
Oleksij
#1 lore raw
Quoted 3 lines · Oleksij Rempel

- 1 timer can be used for clocksource other as clock_event_device, how can i use other 2 timers on same controller. and how can i use other 3 controllers?

All you need is two.

One for the clocksource (free running counter):

100MHz is fine, it gives the timekeeping code nice granularity. There is no need for a wrap around interrupt. The core code knows how to deal with it.

The second one is for the clock event device

Avoid a match timer if possible, it's a pain in the neck. Either a autoreloading timer for the periodic mode or a simple downcounting one for one shot mode is good enough.

The other timers are not of any value for Linux. Just leave them alone.

Thanks,

tglx