2 * linux/arch/arm/mach-lpc22xx/time.c
4 * Copyright (C) 2004 Philips Semiconductors
7 #include <linux/kernel.h>
8 #include <linux/sched.h>
9 #include <linux/init.h>
10 #include <linux/interrupt.h>
11 #include <asm/system.h>
13 #include <asm/mach-types.h>
17 #include <asm/hardware.h>
18 #include <asm/mach/time.h>
19 #include <asm/arch/time.h>
21 extern void lpc22xx_unmask_irq(unsigned int);
23 unsigned long lpc22xx_gettimeoffset (void)
25 return (T0TC
/CLOCKS_PER_USEC
);
29 lpc22xx_timer_interrupt(int irq
, void *dev_id
)
32 if (!(T0IR
& 0x01)) return IRQ_NONE
;
35 */ timer_tick(); /* modified 20050608 for new version */
37 T0IR
|= 0x01; /* reset interrupt */
41 static struct irqaction lpc22xx_timer_irq
= {
42 .name
= "LPC22xx Timer Tick",
43 .flags
= IRQF_DISABLED
| IRQF_TIMER
,
44 .handler
= lpc22xx_timer_interrupt
48 * Set up timer interrupt, and return the current time in seconds.
51 void __init
lpc22xx_time_init (void)
54 * disable and clear timer 0, set to
57 /* initialize the timer period and prescaler */
58 T0MR0
= MR0_INIT_VALUE
;
59 T0PR
= PRESCALE_COUNTER_INIT_VALUE
;
60 T0MCR
|= 0x03; /* generate interrupt when T0MR0 match T0TC and Reset Timer Count*/
63 * @todo do those really need to be function pointers ?
65 /* gettimeoffset = lpc22xx_gettimeoffset; */
66 lpc22xx_timer_irq
.handler
= lpc22xx_timer_interrupt
;
68 /* set up the interrupt vevtor for timer 0 match */
69 setup_irq(LPC22xx_INTERRUPT_TIMER0
, &lpc22xx_timer_irq
);
71 /* enable the timer IRQ */
72 lpc22xx_unmask_irq(LPC22xx_INTERRUPT_TIMER0
);
74 /* let timer 0 run... */
75 T0IR
= 0x01; /* reset MR0 interrupt*/
76 T0TCR
= 0x02; /* Reset timer count and prescale counter */
77 T0TCR
= 0x01; /* enablle timer counter and prescale counter */
80 struct sys_timer lpc22xx_timer
= {
81 .init
= lpc22xx_time_init
,
82 .offset
= lpc22xx_gettimeoffset
,