Linux 2.6.18.8
[linux-2.6/suspend2-2.6.18.git] / arch / arm / mach-omap2 / timer-gp.c
blobfe5fd6d42dea8def5e4c8a8a0e93919830263e26
1 /*
2 * linux/arch/arm/mach-omap2/timer-gp.c
4 * OMAP2 GP timer support.
6 * Copyright (C) 2005 Nokia Corporation
7 * Author: Paul Mundt <paul.mundt@nokia.com>
8 * Juha Yrjölä <juha.yrjola@nokia.com>
9 * OMAP Dual-mode timer framework support by Timo Teras
11 * Some parts based off of TI's 24xx code:
13 * Copyright (C) 2004 Texas Instruments, Inc.
15 * Roughly modelled after the OMAP1 MPU timer code.
17 * This file is subject to the terms and conditions of the GNU General Public
18 * License. See the file "COPYING" in the main directory of this archive
19 * for more details.
21 #include <linux/init.h>
22 #include <linux/time.h>
23 #include <linux/interrupt.h>
24 #include <linux/err.h>
25 #include <linux/clk.h>
26 #include <linux/delay.h>
28 #include <asm/mach/time.h>
29 #include <asm/arch/dmtimer.h>
31 static struct omap_dm_timer *gptimer;
33 static inline void omap2_gp_timer_start(unsigned long load_val)
35 omap_dm_timer_set_load(gptimer, 1, 0xffffffff - load_val);
36 omap_dm_timer_set_int_enable(gptimer, OMAP_TIMER_INT_OVERFLOW);
37 omap_dm_timer_start(gptimer);
40 static irqreturn_t omap2_gp_timer_interrupt(int irq, void *dev_id,
41 struct pt_regs *regs)
43 write_seqlock(&xtime_lock);
45 omap_dm_timer_write_status(gptimer, OMAP_TIMER_INT_OVERFLOW);
46 timer_tick(regs);
48 write_sequnlock(&xtime_lock);
50 return IRQ_HANDLED;
53 static struct irqaction omap2_gp_timer_irq = {
54 .name = "gp timer",
55 .flags = IRQF_DISABLED | IRQF_TIMER,
56 .handler = omap2_gp_timer_interrupt,
59 static void __init omap2_gp_timer_init(void)
61 u32 tick_period;
63 omap_dm_timer_init();
64 gptimer = omap_dm_timer_request_specific(1);
65 BUG_ON(gptimer == NULL);
67 omap_dm_timer_set_source(gptimer, OMAP_TIMER_SRC_SYS_CLK);
68 tick_period = clk_get_rate(omap_dm_timer_get_fclk(gptimer)) / 100;
69 tick_period -= 1;
71 setup_irq(omap_dm_timer_get_irq(gptimer), &omap2_gp_timer_irq);
72 omap2_gp_timer_start(tick_period);
75 struct sys_timer omap_timer = {
76 .init = omap2_gp_timer_init,