Skip to contentSkip to conversation

sh: timer rewrite V2, cmt driver

PATCH New Magnus Damm 1 participant 1 message Nov 25, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 4/8 sh: timer rewrite V2, cmt driver

From: Magnus Damm <[email protected]>

CMT driver for the SuperH timer base code implementation V2. Both 16-bit and 32-bit CMT versions are supported, but only 32-bit is tested. This driver only contains hardware specific bits, the logic handling clock events and clock sources is performed by the timer_inc helper code.

Works fine as clock source and/or event in periodic or oneshot mode. Tested on sh7722 and sh7723, but should work with any cpu/architecture.

---

Changes since V1 include:
- Reworked private data handling - no more union in sh_timer.h
- Made spinlock static
- Use setup_irq() to request early interrupt
- Removed request_mem_region()/free_mem_region()
- Removed sysdev code

 arch/sh/Kconfig                |    7 +
 drivers/clocksource/Makefile   |    1 
 drivers/clocksource/sh_cmt.c   |  270 ++++++++++++++++++++++++++++++++++++++++
 drivers/clocksource/sh_timer.c |    3 
 include/linux/sh_timer.h       |    5 
 5 files changed, 285 insertions(+), 1 deletion(-)
arch/sh/Kconfig +7 -0
@@ -397,6 +397,13 @@ config SH_TIMER_TMU
 	help
 	  This enables build of the TMU system timer driver.
 
+config SH_TIMER_CMT
+	def_bool y
+	prompt "CMT timer support"
+	depends on SH_TIMER
+	help
+	  This enables build of the CMT system timer driver.
+
 config SH_TMU
 	def_bool y
 	prompt "TMU timer support"
drivers/clocksource/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_X86_PM_TIMER)	+= acpi_pm.o
 obj-$(CONFIG_SCx200HR_TIMER)	+= scx200_hrt.o
 obj-$(CONFIG_SH_TIMER)		+= sh_timer.o
 obj-$(CONFIG_SH_TIMER_TMU)	+= sh_tmu.o
+obj-$(CONFIG_SH_TIMER_CMT)	+= sh_cmt.o timer_inc.o
drivers/clocksource/sh_cmt.c new file +270 -0

270 lines not on this page · raw message

drivers/clocksource/sh_timer.c +3 -0
@@ -25,6 +25,9 @@ struct early_timer *sh_timers_early[] = 
 #ifdef CONFIG_SH_TIMER_TMU
 	[SH_TIMER_TYPE_TMU] = &sh_tmu,
 #endif
+#ifdef CONFIG_SH_TIMER_CMT
+	[SH_TIMER_TYPE_CMT] = &sh_cmt,
+#endif
 };
 
 static struct sh_timer_config *sh_timer_timers;
include/linux/sh_timer.h +4 -1
@@ -14,9 +14,12 @@ struct early_timer {
 	int (*setup)(void *priv, void *config);
 };
 
-enum sh_timer_type { SH_TIMER_TYPE_TMU, SH_TIMER_TYPE_NR };
+enum sh_timer_type { SH_TIMER_TYPE_TMU, SH_TIMER_TYPE_CMT, SH_TIMER_TYPE_NR };
 
 extern struct early_timer sh_tmu;
+extern struct early_timer sh_cmt;
+
+#define SH_TIMER_FLAGS_CMT_16BIT (1 << 0)
 
 struct sh_timer_config {
 	enum sh_timer_type type;