2 * arch/ubicom32/kernel/timer_tick.c
3 * Impelemets a perodic timer.
5 * (C) Copyright 2009, Ubicom, Inc.
6 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
8 * This file is part of the Ubicom32 Linux Kernel Port.
10 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
11 * it and/or modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation, either version 2 of the
13 * License, or (at your option) any later version.
15 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
16 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
17 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
18 * the GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with the Ubicom32 Linux Kernel Port. If not,
22 * see <http://www.gnu.org/licenses/>.
24 * Ubicom32 implementation derived from (with many thanks):
30 #include <linux/profile.h>
32 #include <asm/ip5000.h>
33 #include <asm/machdep.h>
34 #if defined(CONFIG_SMP)
38 static unsigned int timervector
;
39 static unsigned int frequency
;
43 * Kernel system timer support. Needs to keep up the real-time clock,
44 * as well as call the "do_timer()" routine every clocktick.
46 static irqreturn_t
timer_tick(int irq
, void *dummy
)
50 BUG_ON(!irqs_disabled());
51 ticks
= timer_reset(timervector
, frequency
);
53 write_seqlock(&xtime_lock
);
55 write_sequnlock(&xtime_lock
);
57 update_process_times(user_mode(get_irq_regs()));
58 profile_tick(CPU_PROFILING
);
60 #if defined(CONFIG_SMP)
67 * Data used by setup_irq for the timer.
69 static struct irqaction timer_irq
= {
71 .flags
= IRQF_DISABLED
| IRQF_TIMER
,
72 .handler
= timer_tick
,
77 * Implements a periodic timer
79 * This implementation directly calls the timer_tick() and move
80 * the Linux kernel forward. This is used when the user has not
81 * selected GENERIC_CLOCKEVENTS.
83 void timer_tick_init(void)
86 * Now allocate a timer to ourselves.
88 timervector
= timer_alloc();
89 if (timervector
== -1) {
90 printk(KERN_WARNING
"where did the timer go?\n");
94 setup_irq(timervector
, &timer_irq
);
97 * Get the frequency from the processor device tree node or use
98 * the default if not available. We will store this as the frequency
99 * of the timer to avoid future calculations.
101 frequency
= processor_frequency();
102 if (frequency
== 0) {
103 frequency
= CLOCK_TICK_RATE
;
105 frequency
/= CONFIG_HZ
;
107 printk(KERN_NOTICE
"timer will interrupt every: %d cycles\n", frequency
);
108 timer_set(timervector
, frequency
);