diff options
Diffstat (limited to 'arch/arm/mach-netx/time.c')
-rw-r--r-- | arch/arm/mach-netx/time.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/arch/arm/mach-netx/time.c b/arch/arm/mach-netx/time.c new file mode 100644 index 000000000000..edfbdf40c600 --- /dev/null +++ b/arch/arm/mach-netx/time.c | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-netx/time.c | ||
3 | * | ||
4 | * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/init.h> | ||
21 | #include <linux/interrupt.h> | ||
22 | |||
23 | #include <asm/hardware.h> | ||
24 | #include <asm/io.h> | ||
25 | #include <asm/mach/time.h> | ||
26 | #include <asm/arch/netx-regs.h> | ||
27 | |||
28 | /* | ||
29 | * Returns number of us since last clock interrupt. Note that interrupts | ||
30 | * will have been disabled by do_gettimeoffset() | ||
31 | */ | ||
32 | static unsigned long netx_gettimeoffset(void) | ||
33 | { | ||
34 | return readl(NETX_GPIO_COUNTER_CURRENT(0)) / 100; | ||
35 | } | ||
36 | |||
37 | /* | ||
38 | * IRQ handler for the timer | ||
39 | */ | ||
40 | static irqreturn_t | ||
41 | netx_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) | ||
42 | { | ||
43 | write_seqlock(&xtime_lock); | ||
44 | |||
45 | timer_tick(regs); | ||
46 | write_sequnlock(&xtime_lock); | ||
47 | |||
48 | /* acknowledge interrupt */ | ||
49 | writel(COUNTER_BIT(0), NETX_GPIO_IRQ); | ||
50 | |||
51 | return IRQ_HANDLED; | ||
52 | } | ||
53 | |||
54 | |||
55 | static struct irqaction netx_timer_irq = { | ||
56 | .name = "NetX Timer Tick", | ||
57 | .flags = SA_INTERRUPT | SA_TIMER, | ||
58 | .handler = netx_timer_interrupt, | ||
59 | }; | ||
60 | |||
61 | /* | ||
62 | * Set up timer interrupt | ||
63 | */ | ||
64 | static void __init netx_timer_init(void) | ||
65 | { | ||
66 | /* disable timer initially */ | ||
67 | writel(0, NETX_GPIO_COUNTER_CTRL(0)); | ||
68 | |||
69 | /* Reset the timer value to zero */ | ||
70 | writel(0, NETX_GPIO_COUNTER_CURRENT(0)); | ||
71 | |||
72 | writel(LATCH, NETX_GPIO_COUNTER_MAX(0)); | ||
73 | |||
74 | /* acknowledge interrupt */ | ||
75 | writel(COUNTER_BIT(0), NETX_GPIO_IRQ); | ||
76 | |||
77 | /* Enable the interrupt in the specific timer register and start timer */ | ||
78 | writel(COUNTER_BIT(0), NETX_GPIO_IRQ_ENABLE); | ||
79 | writel(NETX_GPIO_COUNTER_CTRL_IRQ_EN | NETX_GPIO_COUNTER_CTRL_RUN, | ||
80 | NETX_GPIO_COUNTER_CTRL(0)); | ||
81 | |||
82 | setup_irq(NETX_IRQ_TIMER0, &netx_timer_irq); | ||
83 | } | ||
84 | |||
85 | struct sys_timer netx_timer = { | ||
86 | .init = netx_timer_init, | ||
87 | .offset = netx_gettimeoffset, | ||
88 | }; | ||