2 * linux/arch/armnommu/mach-espd_4510b/time.c
4 * Copyright (C) SAMSUNG ELECTRONICS
5 * Hyok S. Choi <hyok.choi@samsung.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <linux/kernel.h>
22 #include <linux/sched.h>
23 #include <linux/init.h>
24 #include <linux/interrupt.h>
25 #include <asm/system.h>
27 #include <asm/mach-types.h>
31 #include <asm/mach/time.h>
32 #include <asm/uaccess.h>
33 #include <asm/hardware.h>
34 #include <asm/arch/timex.h>
35 #include <asm/mach/irq.h>
37 #define CLOCKS_PER_USEC (CONFIG_ARM_CLK/1000000)
39 static volatile unsigned long timer_cnt
;
41 unsigned long s3c4510b_gettimeoffset (void)
45 /* returns microseconds -- timer 1 is free running in countdown mode */
46 usec
= 0xFFFFFFFF - inl( REG_TCNT1
);
47 usec
/= CLOCKS_PER_USEC
;
53 s3c4510b_timer_interrupt(int irq
, void *dev_id
)
58 #ifdef CONFIG_ARCH_ESPD_4510B
59 if ( ! (timer_cnt
% (HZ
/4))) {
68 static struct irqaction s3c4510b_timer_irq
= {
69 .name
= "S3C4510b Timer Tick",
70 .flags
= IRQF_DISABLED
| IRQF_TIMER
,
71 .handler
= s3c4510b_timer_interrupt
76 * Set up timer interrupt
79 void __init
s3c4510b_time_init (void)
84 * disable and clear timers 0 and 1. set both timers to
88 /* clear any pending interrupts */
89 outl( 0x1FFFFF, REG_INTPEND
);
93 /* initialize the timer period */
94 period
= (CLOCK_TICK_RATE
/ HZ
);
95 outl( period
, REG_TDATA0
);
97 /* set timer1 to continually count down from FFFFFFFF */
98 outl( 0xFFFFFFFF, REG_TDATA1
);
100 // printk(KERN_INFO "time_init(): TICK_RATE: %u, HZ: %u, period: %u\n", CLOCK_TICK_RATE, HZ, period);
102 s3c4510b_timer_irq
.handler
= s3c4510b_timer_interrupt
;
104 /* set up the interrupt vevtor for timer 0 match */
105 setup_irq( INT_TIMER0
, &s3c4510b_timer_irq
);
107 /* enable the timer IRQ */
108 INT_ENABLE( INT_TIMER0
);
110 /* let timer 0 run... */
111 outl( TM0_RUN
| TM1_RUN
, REG_TMOD
);
114 struct sys_timer s3c4510b_timer
= {
115 .init
= s3c4510b_time_init
,
116 .offset
= s3c4510b_gettimeoffset
,