blob: 3a63941d43beceea7a022c5c928ad3caa459afde [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/mach-footbridge/dc21285-timer.c
3 *
4 * Copyright (C) 1998 Russell King.
5 * Copyright (C) 1998 Phil Blundell
6 */
7#include <linux/init.h>
8#include <linux/interrupt.h>
Thomas Gleixner55e86982006-07-01 22:32:17 +01009#include <linux/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
11#include <asm/irq.h>
12
13#include <asm/hardware/dec21285.h>
14#include <asm/mach/time.h>
15
16#include "common.h"
17
18/*
19 * Footbridge timer 1 support.
20 */
21static unsigned long timer1_latch;
22
23static unsigned long timer1_gettimeoffset (void)
24{
25 unsigned long value = timer1_latch - *CSR_TIMER1_VALUE;
26
27 return ((tick_nsec / 1000) * value) / timer1_latch;
28}
29
30static irqreturn_t
Linus Torvalds0cd61b62006-10-06 10:53:39 -070031timer1_interrupt(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070032{
33 write_seqlock(&xtime_lock);
34
35 *CSR_TIMER1_CLR = 0;
36
Linus Torvalds0cd61b62006-10-06 10:53:39 -070037 timer_tick();
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
39 write_sequnlock(&xtime_lock);
40
41 return IRQ_HANDLED;
42}
43
44static struct irqaction footbridge_timer_irq = {
45 .name = "Timer1 timer tick",
46 .handler = timer1_interrupt,
Bernhard Walleb30faba2007-05-08 00:35:39 -070047 .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070048};
49
50/*
51 * Set up timer interrupt.
52 */
53static void __init footbridge_timer_init(void)
54{
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
56
57 *CSR_TIMER1_CLR = 0;
58 *CSR_TIMER1_LOAD = timer1_latch;
59 *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;
60
61 setup_irq(IRQ_TIMER1, &footbridge_timer_irq);
Russell King336eb022005-04-17 15:36:55 +010062
63 isa_rtc_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -070064}
65
66struct sys_timer footbridge_timer = {
67 .init = footbridge_timer_init,
68 .offset = timer1_gettimeoffset,
69};