Skip to contentSkip to conversation

clocksource: clocksource/clockevent driver for Synopsys dw_apb_timer

PATCH In review Jamie Iles 3 participants 6 messages Mar 31, 2011

Subsystems (2)
lore
Share & tools
lore

Jamie Iles

author
#0 lore raw

PATCH 1/1 clocksource: clocksource/clockevent driver for Synopsys dw_apb_timer

This patch adds a driver for the Synopsys DesignWare APB timer block found in some ARM systems. This uses the timers with an IRQ as a clockevents device and a timer without an IRQ as a clocksource device.

Cc John Stultz <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/arm/Kconfig             |    3 +
 drivers/clocksource/Makefile |    1 +
 drivers/clocksource/dw_apb.c |  298 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 302 insertions(+), 0 deletions(-)
 create mode 100644 drivers/clocksource/dw_apb.c
arch/arm/Kconfig +3 -0
index 7c0effb..8988034 100644
@@ -1316,6 +1316,9 @@ menu "Kernel Features"
 
 source "kernel/time/Kconfig"
 
+config DWAPB_TIMER
+	bool
+
 config SMP
 	bool "Symmetric Multi-Processing (EXPERIMENTAL)"
 	depends on EXPERIMENTAL
drivers/clocksource/Makefile +1 -0
index be61ece..5961052 100644
@@ -6,3 +6,4 @@ obj-$(CONFIG_CS5535_CLOCK_EVENT_SRC)	+= cs5535-clockevt.o
 obj-$(CONFIG_SH_TIMER_CMT)	+= sh_cmt.o
 obj-$(CONFIG_SH_TIMER_MTU2)	+= sh_mtu2.o
 obj-$(CONFIG_SH_TIMER_TMU)	+= sh_tmu.o
+obj-$(CONFIG_DWAPB_TIMER)	+= dw_apb.o
drivers/clocksource/dw_apb.c new file +298 -0

298 lines not on this page · raw message

Signature · 1 line
1.7.4
#1 lore raw
Quoted 4 lines · Jamie Iles

This patch adds a driver for the Synopsys DesignWare APB timer block found in some ARM systems. This uses the timers with an IRQ as a clockevents device and a timer without an IRQ as a clocksource device.

Interesting. That's probably the same thing as:

     arch/x86/kernel/apb_timer.c

So if we merge that thing, then we should make sure, that we can replace the x86 one with it.

Thanks,

tglx

#2 lore raw
Quoted 7 lines · On Thu, 31 Mar 2011 17:33:12 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 4 lines · Jamie Iles

This patch adds a driver for the Synopsys DesignWare APB timer block found in some ARM systems. This uses the timers with an IRQ as a clockevents device and a timer without an IRQ as a clocksource device.

Quoted 7 lines

Interesting. That's probably the same thing as:

     arch/x86/kernel/apb_timer.c

So if we merge that thing, then we should make sure, that we can replace the x86 one with it.

It seems we have room to consolidate, here is my 2c:
1. need to support multiple timer channels
2. support percpu clockevent, need to deal with cpu online/offline
3. early boot needs. I don't know if abp timer is needed for booting on ARM platforms. But for Moorestown, we need timer before platform bus running. So I guess we cannot enumerate the timer as platform device.

Signature · 3 lines
Thanks

Jacob
#3 lore raw
Quoted 17 lines · jacob pan
Quoted 7 lines · On Thu, 31 Mar 2011 17:33:12 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 4 lines · Jamie Iles

This patch adds a driver for the Synopsys DesignWare APB timer block found in some ARM systems. This uses the timers with an IRQ as a clockevents device and a timer without an IRQ as a clocksource device.

Quoted 7 lines

Interesting. That's probably the same thing as:

     arch/x86/kernel/apb_timer.c

So if we merge that thing, then we should make sure, that we can replace the x86 one with it.

Quoted 6 lines

It seems we have room to consolidate, here is my 2c:
1. need to support multiple timer channels
2. support percpu clockevent, need to deal with cpu online/offline
3. early boot needs. I don't know if abp timer is needed for booting on ARM platforms. But for Moorestown, we need timer before platform bus running. So I guess we cannot enumerate the timer as platform device.

That's a solvable problem. I just don't want to see two incarnations of the same thing in the kernel. Can you folks hash that out together what it needs to work everywhere please ?

Thanks,

tglx

author
#4 lore raw
In reply to jacob pan
Quoted 17 lines · jacob pan
Quoted 7 lines · On Thu, 31 Mar 2011 17:33:12 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 4 lines · Jamie Iles

This patch adds a driver for the Synopsys DesignWare APB timer block found in some ARM systems. This uses the timers with an IRQ as a clockevents device and a timer without an IRQ as a clocksource device.

Quoted 7 lines

Interesting. That's probably the same thing as:

     arch/x86/kernel/apb_timer.c

So if we merge that thing, then we should make sure, that we can replace the x86 one with it.

Quoted 6 lines

It seems we have room to consolidate, here is my 2c:
1. need to support multiple timer channels
2. support percpu clockevent, need to deal with cpu online/offline
3. early boot needs. I don't know if abp timer is needed for booting on ARM platforms. But for Moorestown, we need timer before platform bus running. So I guess we cannot enumerate the timer as platform device.

ARM does need it quite early to calibrate the delay loop but I've been registering it early by creating an early_platform_device. The other difference is that x86 doesn't support the clk API.

How about factoring out the clockevent and clocksource operations (.set_next_event, .set_mode, .read etc) and the bits that actually drive the hardware into an apb_timer.c then have stuff that does platform device registration or langwell specific stuff in a higher layer?

It looks like arch/x86/kernel/apb_timer.c would still need some lower level access to the timers for doing things like the calibration in apbt_quick_calibrate() before registering the clocksource.

Jamie

#5 lore raw
Quoted 30 lines · On Thu, 31 Mar 2011 18:42:47 +0100 Jamie Iles <[email protected]> wrote:
Quoted 17 lines · jacob pan
Quoted 7 lines · On Thu, 31 Mar 2011 17:33:12 +0200 (CEST) Thomas Gleixner <[email protected]>…
Quoted 4 lines · Jamie Iles

This patch adds a driver for the Synopsys DesignWare APB timer block found in some ARM systems. This uses the timers with an IRQ as a clockevents device and a timer without an IRQ as a clocksource device.

Quoted 7 lines

Interesting. That's probably the same thing as:

     arch/x86/kernel/apb_timer.c

So if we merge that thing, then we should make sure, that we can replace the x86 one with it.

Quoted 7 lines

It seems we have room to consolidate, here is my 2c:
1. need to support multiple timer channels
2. support percpu clockevent, need to deal with cpu online/offline
3. early boot needs. I don't know if abp timer is needed for booting on ARM platforms. But for Moorestown, we need timer before platform bus running. So I guess we cannot enumerate the timer as platform device.

ARM does need it quite early to calibrate the delay loop but I've been registering it early by creating an early_platform_device. The other difference is that x86 doesn't support the clk API.

Quoted 6 lines

How about factoring out the clockevent and clocksource operations (.set_next_event, .set_mode, .read etc) and the bits that actually drive the hardware into an apb_timer.c then have stuff that does platform device registration or langwell specific stuff in a higher layer?

I agree to extract out hardware access bits. how about also include a common allocation/reservation mechanism for apbt timer channels. i guess we have to stay with device specific bits. e.g.

struct apbt_dev {
	int irq;
	__iomem *base;
	int channel_id;
	unsigned int flags; /* for possible platform quirks */
};

The allocation should also allow hints or specific request a specific timer. Our platform has hardcoded usage of timer channels.

Can you be more specific about "higher layer"?, my guess is that you meant platform code or drivers that uses apb timer. So arch specific timer code can alloc apb timer and combine with things that is appropriate for their platform. e.g. clk api.

Quoted 3 lines

It looks like arch/x86/kernel/apb_timer.c would still need some lower level access to the timers for doing things like the calibration in apbt_quick_calibrate() before registering the clocksource.

yeah, we still need some early access. perhaps by-pass the clocksource as an exception. I don't have a better idea at the moment.