blob: bc5e83fb5819edacfc17c1315a16028b3dd4cc8c [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>
Russell King70d13e02008-12-06 08:25:16 +000010#include <linux/spinlock.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
12#include <asm/irq.h>
13
14#include <asm/hardware/dec21285.h>
15#include <asm/mach/time.h>
16
17#include "common.h"
18
19/*
20 * Footbridge timer 1 support.
21 */
22static unsigned long timer1_latch;
23
24static unsigned long timer1_gettimeoffset (void)
25{
26 unsigned long value = timer1_latch - *CSR_TIMER1_VALUE;
27
28 return ((tick_nsec / 1000) * value) / timer1_latch;
29}
30
31static irqreturn_t
Linus Torvalds0cd61b62006-10-06 10:53:39 -070032timer1_interrupt(int irq, void *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033{
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 *CSR_TIMER1_CLR = 0;
35
Linus Torvalds0cd61b62006-10-06 10:53:39 -070036 timer_tick();
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 return IRQ_HANDLED;
39}
40
41static struct irqaction footbridge_timer_irq = {
42 .name = "Timer1 timer tick",
43 .handler = timer1_interrupt,
Bernhard Walleb30faba2007-05-08 00:35:39 -070044 .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
Linus Torvalds1da177e2005-04-16 15:20:36 -070045};
46
47/*
48 * Set up timer interrupt.
49 */
50static void __init footbridge_timer_init(void)
51{
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ);
53
54 *CSR_TIMER1_CLR = 0;
55 *CSR_TIMER1_LOAD = timer1_latch;
56 *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16;
57
58 setup_irq(IRQ_TIMER1, &footbridge_timer_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059}
60
61struct sys_timer footbridge_timer = {
62 .init = footbridge_timer_init,
63 .offset = timer1_gettimeoffset,
64};