Skip to contentSkip to conversation

Permit reuse of APB timers on other platforms

RFC PATCH Superseded Jamie Iles 1 participant 3 messages Apr 1, 2011

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Jamie Iles

author
#0 lore raw

cover Permit reuse of APB timers on other platforms

These patches allow the APB timers to be used by platforms other than x86. The first patch moves the actual timer handling and clocksource/clock_event_device abstraction into drivers/clocksource and converts x86 to use this. The second patch adds a platform_driver to allow other systems to use them.

I've tested these on an ARM platform with NO_HZ but I don't have an x86 platform with these timers that I can test them on so that's just compile tested.

Jamie Iles (2):
x86, mrst: share APB timer code with other platforms
clocksource: platform driver for APB timers

 arch/x86/Kconfig                            |    1 +
 arch/x86/include/asm/apb_timer.h            |   22 +--
 arch/x86/kernel/apb_timer.c                 |  401 ++++-----------------------
 drivers/Kconfig                             |    2 +
 drivers/clocksource/Kconfig                 |   11 +
 drivers/clocksource/Makefile                |    2 +
 drivers/clocksource/dw_apb_timer.c          |  291 +++++++++++++++++++
 drivers/clocksource/dw_apb_timer_platform.c |  173 ++++++++++++
 include/linux/dw_apb_timer.h                |  122 ++++++++
 9 files changed, 662 insertions(+), 363 deletions(-)
 create mode 100644 drivers/clocksource/Kconfig
 create mode 100644 drivers/clocksource/dw_apb_timer.c
 create mode 100644 drivers/clocksource/dw_apb_timer_platform.c
 create mode 100644 include/linux/dw_apb_timer.h
Signature · 1 line
1.7.4
author
#1 lore raw

RFC PATCH 1/2 x86, mrst: share APB timer code with other platforms

The APB timers are an IP block from Synopsys (DesignWare APB timers) and are also found in other systems including ARM SoC's. This patch adds functions for creating clock_event_devices and clocksources from APB timers but does not do the resource allocation. This is handled in a higher layer to allow the timers to be created from multiple methods such as platform_devices.

Cc John Stultz <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
Cc Jacob Pan <[email protected]>

---

Jacob, I haven't been able to run test this on x86 and I'm not 100% confident that it will just work "out of the box" particularly with regards to the resource allocation and frequency calibration.

 arch/x86/Kconfig                   |    1 +
 arch/x86/include/asm/apb_timer.h   |   22 +--
 arch/x86/kernel/apb_timer.c        |  401 +++++------------------------------
 drivers/Kconfig                    |    2 +
 drivers/clocksource/Kconfig        |    6 +
 drivers/clocksource/Makefile       |    1 +
 drivers/clocksource/dw_apb_timer.c |  291 ++++++++++++++++++++++++++
 include/linux/dw_apb_timer.h       |  122 +++++++++++
 8 files changed, 483 insertions(+), 363 deletions(-)
 create mode 100644 drivers/clocksource/Kconfig
 create mode 100644 drivers/clocksource/dw_apb_timer.c
 create mode 100644 include/linux/dw_apb_timer.h
arch/x86/Kconfig +1 -0
index cc6c53a..4028f88 100644
@@ -623,6 +623,7 @@ config HPET_EMULATE_RTC
 config APB_TIMER
        def_bool y if MRST
        prompt "Langwell APB Timer Support" if X86_MRST
+       select DW_APB_TIMER
        help
          APB timer is the replacement for 8254, HPET on X86 MID platforms.
          The APBT provides a stable time base on SMP
arch/x86/include/asm/apb_timer.h +2 -20
index 2fefa50..230000f 100644
@@ -18,24 +18,6 @@
 
 #ifdef CONFIG_APB_TIMER
 
-/* Langwell DW APB timer registers */
-#define APBTMR_N_LOAD_COUNT    0x00
-#define APBTMR_N_CURRENT_VALUE 0x04
-#define APBTMR_N_CONTROL       0x08
-#define APBTMR_N_EOI           0x0c
-#define APBTMR_N_INT_STATUS    0x10
-
-#define APBTMRS_INT_STATUS     0xa0
-#define APBTMRS_EOI            0xa4
-#define APBTMRS_RAW_INT_STATUS 0xa8
-#define APBTMRS_COMP_VERSION   0xac
-#define APBTMRS_REG_SIZE       0x14
-
-/* register bits */
-#define APBTMR_CONTROL_ENABLE  (1<<0)
-#define APBTMR_CONTROL_MODE_PERIODIC   (1<<1) /*1: periodic 0:free running */
-#define APBTMR_CONTROL_INT     (1<<2)
-
 /* default memory mapped register base */
 #define LNW_SCU_ADDR           0xFF100000
 #define LNW_EXT_TIMER_OFFSET   0x1B800
@@ -43,8 +25,8 @@
 #define LNW_EXT_TIMER_PGOFFSET         0x800
 
 /* APBT clock speed range from PCLK to fabric base, 25-100MHz */
-#define APBT_MAX_FREQ          50
-#define APBT_MIN_FREQ          1
+#define APBT_MAX_FREQ          50000000
+#define APBT_MIN_FREQ          1000000
 #define APBT_MMAP_SIZE         1024
 
 #define APBT_DEV_USED  1
arch/x86/kernel/apb_timer.c +58 -343

602 lines not on this page · raw message

drivers/Kconfig +2 -0
index 177c7d1..07b31c4 100644
@@ -119,4 +119,6 @@ source "drivers/platform/Kconfig"
 source "drivers/clk/Kconfig"
 
 source "drivers/hwspinlock/Kconfig"
+
+source "drivers/clocksource/Kconfig"
 endmenu
drivers/clocksource/Kconfig new file +6 -0
new file mode 100644
index 0000000..09081ab
@@ -0,0 +1,6 @@
+#
+# Clocksource configuration
+#
+
+config DW_APB_TIMER
+	bool
drivers/clocksource/Makefile +1 -0
index be61ece..c3785c3 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_DW_APB_TIMER)	+= dw_apb_timer.o
drivers/clocksource/dw_apb_timer.c new file +291 -0

291 lines not on this page · raw message

include/linux/dw_apb_timer.h new file +122 -0

122 lines not on this page · raw message

Signature · 1 line
1.7.4
author
#2 lore raw

RFC PATCH 2/2 clocksource: platform driver for APB timers

In reply to Jamie Iles

Add a platform driver for the APB timers that can be used for embedded systems such as ARM SoC. This uses early_platform so that the timers can be used early in the boot sequence.

Cc John Stultz <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 drivers/clocksource/Kconfig                 |    5 +
 drivers/clocksource/Makefile                |    1 +
 drivers/clocksource/dw_apb_timer_platform.c |  173 +++++++++++++++++++++++++++
 3 files changed, 179 insertions(+), 0 deletions(-)
 create mode 100644 drivers/clocksource/dw_apb_timer_platform.c
drivers/clocksource/Kconfig +5 -0
index 09081ab..fa53da8 100644
@@ -4,3 +4,8 @@
 
 config DW_APB_TIMER
 	bool
+
+config DW_APB_TIMER_PLATFORM
+	depends on HAVE_CLK
+	select DW_APB_TIMER
+	bool
drivers/clocksource/Makefile +1 -0
index c3785c3..9e2de99 100644
@@ -7,3 +7,4 @@ 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_DW_APB_TIMER)	+= dw_apb_timer.o
+obj-$(CONFIG_DW_APB_TIMER_PLATFORM) += dw_apb_timer_platform.o
drivers/clocksource/dw_apb_timer_platform.c new file +173 -0

173 lines not on this page · raw message

Signature · 1 line
1.7.4