sh: timer rewrite, cmt driver
Subsystems (2)
PATCH 4/8 sh: timer rewrite, cmt driver
From: Magnus Damm <[email protected]>
CMT driver for the new SuperH timer base code implementation. 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.
Signed-off-by Magnus Damm <[email protected]>
---
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 | 15 ++ 5 files changed, 295 insertions(+), 1 deletion(-)
arch/sh/Kconfig +7 -0
@@ -396,6 +396,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
@@ -29,6 +29,9 @@ struct sysdev_driver *sh_timer_drivers[]#ifdef CONFIG_SH_TIMER_TMU &sh_tmu,#endif +#ifdef CONFIG_SH_TIMER_CMT + &sh_cmt, +#endif };int sh_timer_register (struct sh_timer_config *timers,int nr_timers)
include/linux/sh_timer.h +14 -1
@@ -18,11 +18,16 @@#include <linux/clk.h> #include <linux/sysdev.h> #include <linux/clockchips.h> +#include <linux/timer_inc.h> enum sh_timer_type {SH_TIMER_TYPE_INVALID =0 , -SH_TIMER_TYPE_TMU }; +SH_TIMER_TYPE_TMU , +SH_TIMER_TYPE_CMT };extern struct sysdev_driver sh_tmu; +extern struct sysdev_driver sh_cmt; + +#define SH_TIMER_FLAGS_CMT_16BIT (1 << 0)struct sh_timer_config {enum sh_timer_type type;
@@ -44,6 +49,14 @@ struct sh_timer_config {struct clock_event_device ced;#endif } tmu; +struct { +void __iomem *mapbase; +struct clk *clk; +struct timer_inc ti; +unsigned long ch_size; +unsigned long overflow_bit; +unsigned long clear_bits; + } cmt; } priv;struct sys_device sysdev;