Merge branch 'for-2.6.30' into for-2.6.31
[pandora-kernel.git] / arch / arm / mach-w90x900 / time.c
1 /*
2  * linux/arch/arm/mach-w90x900/time.c
3  *
4  * Based on linux/arch/arm/plat-s3c24xx/time.c by Ben Dooks
5  *
6  * Copyright (c) 2008 Nuvoton technology corporation
7  * All rights reserved.
8  *
9  * Wan ZongShun <mcuos.com@gmail.com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  */
17
18 #include <linux/kernel.h>
19 #include <linux/sched.h>
20 #include <linux/init.h>
21 #include <linux/interrupt.h>
22 #include <linux/err.h>
23 #include <linux/clk.h>
24 #include <linux/io.h>
25 #include <linux/leds.h>
26
27 #include <asm/mach-types.h>
28 #include <asm/mach/irq.h>
29 #include <asm/mach/time.h>
30
31 #include <mach/map.h>
32 #include <mach/regs-timer.h>
33
34 static unsigned long w90x900_gettimeoffset(void)
35 {
36         return 0;
37 }
38
39 /*IRQ handler for the timer*/
40
41 static irqreturn_t
42 w90x900_timer_interrupt(int irq, void *dev_id)
43 {
44         timer_tick();
45         __raw_writel(0x01, REG_TISR); /* clear TIF0 */
46         return IRQ_HANDLED;
47 }
48
49 static struct irqaction w90x900_timer_irq = {
50         .name           = "w90x900 Timer Tick",
51         .flags          = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
52         .handler        = w90x900_timer_interrupt,
53 };
54
55 /*Set up timer reg.*/
56
57 static void w90x900_timer_setup(void)
58 {
59         __raw_writel(0, REG_TCSR0);
60         __raw_writel(0, REG_TCSR1);
61         __raw_writel(0, REG_TCSR2);
62         __raw_writel(0, REG_TCSR3);
63         __raw_writel(0, REG_TCSR4);
64         __raw_writel(0x1F, REG_TISR);
65         __raw_writel(15000000/(100 * 100), REG_TICR0);
66         __raw_writel(0x68000063, REG_TCSR0);
67 }
68
69 static void __init w90x900_timer_init(void)
70 {
71         w90x900_timer_setup();
72         setup_irq(IRQ_TIMER0, &w90x900_timer_irq);
73 }
74
75 struct sys_timer w90x900_timer = {
76         .init           = w90x900_timer_init,
77         .offset         = w90x900_gettimeoffset,
78         .resume         = w90x900_timer_setup
79 };