| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 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 Gleixner | 55e8698 | 2006-07-01 22:32:17 +0100 | [diff] [blame] | 9 | #include <linux/irq.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 |  | 
|  | 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 | */ | 
|  | 21 | static unsigned long timer1_latch; | 
|  | 22 |  | 
|  | 23 | static 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 |  | 
|  | 30 | static irqreturn_t | 
| Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 31 | timer1_interrupt(int irq, void *dev_id) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | *CSR_TIMER1_CLR = 0; | 
|  | 34 |  | 
| Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 35 | timer_tick(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | return IRQ_HANDLED; | 
|  | 38 | } | 
|  | 39 |  | 
|  | 40 | static struct irqaction footbridge_timer_irq = { | 
|  | 41 | .name		= "Timer1 timer tick", | 
|  | 42 | .handler	= timer1_interrupt, | 
| Bernhard Walle | b30faba | 2007-05-08 00:35:39 -0700 | [diff] [blame] | 43 | .flags		= IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | }; | 
|  | 45 |  | 
|  | 46 | /* | 
|  | 47 | * Set up timer interrupt. | 
|  | 48 | */ | 
|  | 49 | static void __init footbridge_timer_init(void) | 
|  | 50 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | timer1_latch = (mem_fclk_21285 + 8 * HZ) / (16 * HZ); | 
|  | 52 |  | 
|  | 53 | *CSR_TIMER1_CLR  = 0; | 
|  | 54 | *CSR_TIMER1_LOAD = timer1_latch; | 
|  | 55 | *CSR_TIMER1_CNTL = TIMER_CNTL_ENABLE | TIMER_CNTL_AUTORELOAD | TIMER_CNTL_DIV16; | 
|  | 56 |  | 
|  | 57 | setup_irq(IRQ_TIMER1, &footbridge_timer_irq); | 
| Russell King | 336eb02 | 2005-04-17 15:36:55 +0100 | [diff] [blame] | 58 |  | 
|  | 59 | isa_rtc_init(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | } | 
|  | 61 |  | 
|  | 62 | struct sys_timer footbridge_timer = { | 
|  | 63 | .init		= footbridge_timer_init, | 
|  | 64 | .offset		= timer1_gettimeoffset, | 
|  | 65 | }; |