2 * linux/arch/arm/mach-ks8695/time.c
4 * Copyright (C) 2002 Micrel Inc.
5 * Copyright (C) 2006 Greg Ungerer <gerg@snapgear.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
22 #include <linux/kernel.h>
23 #include <linux/interrupt.h>
24 #include <linux/init.h>
25 #include <linux/time.h>
26 #include <linux/irq.h>
27 #include <asm/system.h>
28 #include <asm/hardware.h>
31 #include <asm/mach/time.h>
35 * Cannout read back time on KS8695.
37 static unsigned long ks8695_gettimeoffset(void)
42 static irqreturn_t
ks8695_timer_interrupt(int irq
, void *dev_id
)
44 write_seqlock(&xtime_lock
);
45 __raw_writel(KS8695_INTMASK_TIMERINT1
, KS8695_REG(KS8695_INT_STATUS
));
47 write_sequnlock(&xtime_lock
);
51 static struct irqaction ks8695_timer_irq
= {
52 .name
= "KS8695 Timer Tick",
53 .flags
= IRQF_DISABLED
| IRQF_TIMER
,
54 .handler
= ks8695_timer_interrupt
,
58 * Set up timer interrupt, and return the current time in seconds.
60 static void __init
ks8695_timer_init(void)
62 unsigned long tmout
= CLOCK_TICK_RATE
/ HZ
/ 2;
64 /* Initialise to a known state (all timers off) */
65 __raw_writel(0, KS8695_REG(KS8695_TIMER_CTRL
));
67 /* enable timer 1 as HZ clock */
68 __raw_writel(tmout
, KS8695_REG(KS8695_TIMER1
));
69 __raw_writel(tmout
, KS8695_REG(KS8695_TIMER1_PCOUNT
));
70 __raw_writel(0x02, KS8695_REG(KS8695_TIMER_CTRL
));
72 setup_irq(KS8695_INT_TIMERINT1
, &ks8695_timer_irq
);
75 struct sys_timer ks8695_timer
= {
76 .init
= ks8695_timer_init
,
77 .offset
= ks8695_gettimeoffset
,