MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / arch / arm / mach-s3c3410 / time.c
blob48da59af615231e5456a9376e0815f5fc9d2f6f7
1 /*
2 * linux/arch/armnommu/mach-s3c3410/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>
26 #include <asm/leds.h>
27 #include <asm/mach-types.h>
29 #include <asm/io.h>
30 #include <asm/irq.h>
31 #include <asm/hardware.h>
32 #include <asm/mach/time.h>
33 #include <asm/arch/time.h>
36 extern void s3c3410_unmask_irq(unsigned int irq);
38 unsigned long s3c3410_gettimeoffset (void)
40 return (inw(S3C3410X_TCNT0) / CLOCKS_PER_USEC);
43 static irqreturn_t
44 s3c3410_timer_interrupt(int irq, void *dev_id)
46 timer_tick();
48 return IRQ_HANDLED;
51 static struct irqaction s3c3410_timer_irq = {
52 .name = "S3C3410 Timer Tick",
53 .flags = IRQF_DISABLED | IRQF_TIMER,
54 .handler = s3c3410_timer_interrupt
58 * Set up timer interrupt, and return the current time in seconds.
61 void __init s3c3410_time_init (void)
63 u_int8_t tmod;
64 u_int16_t period;
67 * disable and clear timer 0, set to
68 * internal clock and interval mode
70 tmod = S3C3410X_T16_OMS_INTRV | S3C3410X_T16_CL;
71 outb(tmod, S3C3410X_TCON0);
73 /* initialize the timer period and prescaler */
74 period = (CONFIG_ARM_CLK/S3C3410X_TIMER0_PRESCALER)/HZ;
75 outw(period, S3C3410X_TDAT0);
76 outb(S3C3410X_TIMER0_PRESCALER-1, S3C3410X_TPRE0);
79 * @todo do those really need to be function pointers ?
81 gettimeoffset = s3c3410_gettimeoffset;
82 s3c3410_timer_irq.handler = s3c3410_timer_interrupt;
84 /* set up the interrupt vevtor for timer 0 match */
85 setup_irq(S3C3410X_INTERRUPT_TMC0, &s3c3410_timer_irq);
87 /* enable the timer IRQ */
88 s3c3410_unmask_irq(S3C3410X_INTERRUPT_TMC0);
90 /* let timer 0 run... */
91 tmod |= S3C3410X_T16_TEN;
92 tmod &= ~S3C3410X_T16_CL;
93 outb(tmod, S3C3410X_TCON0);