diff options
author | Alexander Shiyan <shc_work@mail.ru> | 2012-10-10 11:45:27 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2012-10-25 11:22:34 -0400 |
commit | 4a8355c4c34f55aecd204604f02e179eaee15502 (patch) | |
tree | ae0a41a603544d341a7482fdfe75bb87717eb475 /arch/arm | |
parent | ddffeb8c4d0331609ef2581d84de4d763607bd37 (diff) |
ARM: clps711x: convert to clockevents
This patch converts CLPS711X-platform to use modern clockevent API.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/Kconfig | 2 | ||||
-rw-r--r-- | arch/arm/mach-clps711x/common.c | 38 |
2 files changed, 18 insertions, 22 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 73067efd4845..c989c61060ae 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -364,10 +364,10 @@ config ARCH_CNS3XXX | |||
364 | 364 | ||
365 | config ARCH_CLPS711X | 365 | config ARCH_CLPS711X |
366 | bool "Cirrus Logic CLPS711x/EP721x/EP731x-based" | 366 | bool "Cirrus Logic CLPS711x/EP721x/EP731x-based" |
367 | select ARCH_USES_GETTIMEOFFSET | ||
368 | select CLKDEV_LOOKUP | 367 | select CLKDEV_LOOKUP |
369 | select COMMON_CLK | 368 | select COMMON_CLK |
370 | select CPU_ARM720T | 369 | select CPU_ARM720T |
370 | select GENERIC_CLOCKEVENTS | ||
371 | select NEED_MACH_MEMORY_H | 371 | select NEED_MACH_MEMORY_H |
372 | help | 372 | help |
373 | Support for Cirrus Logic 711x/721x/731x based boards. | 373 | Support for Cirrus Logic 711x/721x/731x based boards. |
diff --git a/arch/arm/mach-clps711x/common.c b/arch/arm/mach-clps711x/common.c index 509243d89a32..218684f0d7b4 100644 --- a/arch/arm/mach-clps711x/common.c +++ b/arch/arm/mach-clps711x/common.c | |||
@@ -21,13 +21,14 @@ | |||
21 | */ | 21 | */ |
22 | #include <linux/io.h> | 22 | #include <linux/io.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/sizes.h> | ||
24 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
25 | #include <linux/irq.h> | 26 | #include <linux/irq.h> |
26 | #include <linux/clk.h> | 27 | #include <linux/clk.h> |
27 | #include <linux/clkdev.h> | 28 | #include <linux/clkdev.h> |
29 | #include <linux/clockchips.h> | ||
28 | #include <linux/clk-provider.h> | 30 | #include <linux/clk-provider.h> |
29 | 31 | ||
30 | #include <asm/sizes.h> | ||
31 | #include <asm/mach/map.h> | 32 | #include <asm/mach/map.h> |
32 | #include <asm/mach/time.h> | 33 | #include <asm/mach/time.h> |
33 | #include <asm/system_misc.h> | 34 | #include <asm/system_misc.h> |
@@ -36,7 +37,6 @@ | |||
36 | 37 | ||
37 | static struct clk *clk_pll, *clk_bus, *clk_uart, *clk_timerl, *clk_timerh, | 38 | static struct clk *clk_pll, *clk_bus, *clk_uart, *clk_timerl, *clk_timerh, |
38 | *clk_tint, *clk_spi; | 39 | *clk_tint, *clk_spi; |
39 | static unsigned long latch; | ||
40 | 40 | ||
41 | /* | 41 | /* |
42 | * This maps the generic CLPS711x registers | 42 | * This maps the generic CLPS711x registers |
@@ -158,32 +158,29 @@ void __init clps711x_init_irq(void) | |||
158 | clps_writel(0, KBDEOI); | 158 | clps_writel(0, KBDEOI); |
159 | } | 159 | } |
160 | 160 | ||
161 | /* | 161 | static void clps711x_clockevent_set_mode(enum clock_event_mode mode, |
162 | * gettimeoffset() returns time since last timer tick, in usecs. | 162 | struct clock_event_device *evt) |
163 | * | ||
164 | * 'LATCH' is hwclock ticks (see CLOCK_TICK_RATE in timex.h) per jiffy. | ||
165 | * 'tick' is usecs per jiffy. | ||
166 | */ | ||
167 | static unsigned long clps711x_gettimeoffset(void) | ||
168 | { | 163 | { |
169 | unsigned long hwticks; | ||
170 | hwticks = latch - (clps_readl(TC2D) & 0xffff); | ||
171 | return (hwticks * (tick_nsec / 1000)) / latch; | ||
172 | } | 164 | } |
173 | 165 | ||
174 | /* | 166 | static struct clock_event_device clockevent_clps711x = { |
175 | * IRQ handler for the timer | 167 | .name = "CLPS711x Clockevents", |
176 | */ | 168 | .rating = 300, |
177 | static irqreturn_t p720t_timer_interrupt(int irq, void *dev_id) | 169 | .features = CLOCK_EVT_FEAT_PERIODIC, |
170 | .set_mode = clps711x_clockevent_set_mode, | ||
171 | }; | ||
172 | |||
173 | static irqreturn_t clps711x_timer_interrupt(int irq, void *dev_id) | ||
178 | { | 174 | { |
179 | timer_tick(); | 175 | clockevent_clps711x.event_handler(&clockevent_clps711x); |
176 | |||
180 | return IRQ_HANDLED; | 177 | return IRQ_HANDLED; |
181 | } | 178 | } |
182 | 179 | ||
183 | static struct irqaction clps711x_timer_irq = { | 180 | static struct irqaction clps711x_timer_irq = { |
184 | .name = "CLPS711x Timer Tick", | 181 | .name = "CLPS711x Timer Tick", |
185 | .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, | 182 | .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, |
186 | .handler = p720t_timer_interrupt, | 183 | .handler = clps711x_timer_interrupt, |
187 | }; | 184 | }; |
188 | 185 | ||
189 | static void add_fixed_clk(struct clk *clk, const char *name, int rate) | 186 | static void add_fixed_clk(struct clk *clk, const char *name, int rate) |
@@ -244,20 +241,19 @@ static void __init clps711x_timer_init(void) | |||
244 | 241 | ||
245 | pr_info("CPU frequency set at %i Hz.\n", cpu); | 242 | pr_info("CPU frequency set at %i Hz.\n", cpu); |
246 | 243 | ||
247 | latch = (timh + HZ / 2) / HZ; | 244 | clps_writew(DIV_ROUND_CLOSEST(timh, HZ), TC2D); |
248 | 245 | ||
249 | tmp = clps_readl(SYSCON1); | 246 | tmp = clps_readl(SYSCON1); |
250 | tmp |= SYSCON1_TC2S | SYSCON1_TC2M; | 247 | tmp |= SYSCON1_TC2S | SYSCON1_TC2M; |
251 | clps_writel(tmp, SYSCON1); | 248 | clps_writel(tmp, SYSCON1); |
252 | 249 | ||
253 | clps_writel(latch - 1, TC2D); | 250 | clockevents_config_and_register(&clockevent_clps711x, timh, 1, 0xffff); |
254 | 251 | ||
255 | setup_irq(IRQ_TC2OI, &clps711x_timer_irq); | 252 | setup_irq(IRQ_TC2OI, &clps711x_timer_irq); |
256 | } | 253 | } |
257 | 254 | ||
258 | struct sys_timer clps711x_timer = { | 255 | struct sys_timer clps711x_timer = { |
259 | .init = clps711x_timer_init, | 256 | .init = clps711x_timer_init, |
260 | .offset = clps711x_gettimeoffset, | ||
261 | }; | 257 | }; |
262 | 258 | ||
263 | void clps711x_restart(char mode, const char *cmd) | 259 | void clps711x_restart(char mode, const char *cmd) |