2 * arch/ubicom32/kernel/timer_broadcast.c
3 * Implements a dummy clock event for each cpu.
5 * Copyright (C) 2008 Paul Mundt
6 * (C) Copyright 2009, Ubicom, Inc.
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):
31 #include <linux/init.h>
32 #include <linux/kernel.h>
33 #include <linux/delay.h>
34 #include <linux/device.h>
35 #include <linux/smp.h>
36 #include <linux/jiffies.h>
37 #include <linux/percpu.h>
38 #include <linux/clockchips.h>
39 #include <linux/irq.h>
41 static DEFINE_PER_CPU(struct clock_event_device, local_clockevent);
44 * The broadcast trick only works when the timer will be used in a periodic mode.
45 * If the user has configured either NO_HZ or HIGH_RES_TIMERS they must have
48 #if defined(CONFIG_NO_HZ) || defined(CONFIG_HIGH_RES_TIMERS)
49 #error "Tickless and High Resolution Timers require per-CPU local timers: CONFIG_LOCAL_TIMERS"
53 * local_timer_interrupt()
54 * Used on SMP for local timer interrupt sent via an IPI.
56 void local_timer_interrupt(void)
58 struct clock_event_device *dev = &__get_cpu_var(local_clockevent);
60 dev->event_handler(dev);
64 * dummy_timer_set_next_event()
65 * Cause the timer to go off "cycles" from now.
67 static int dummy_timer_set_next_event(unsigned long cycles, struct clock_event_device *dev)
73 * dummy_timer_set_mode()
76 static void dummy_timer_set_mode(enum clock_event_mode mode,
77 struct clock_event_device *clk)
83 * Adds a clock event for the specified cpu.
85 int __cpuinit local_timer_setup(unsigned int cpu)
87 struct clock_event_device *dev = &per_cpu(local_clockevent, cpu);
89 dev->name = "timer-dummy";
90 dev->features = CLOCK_EVT_FEAT_DUMMY;
93 dev->set_mode = dummy_timer_set_mode;
94 dev->set_next_event = dummy_timer_set_next_event;
95 dev->broadcast = smp_timer_broadcast;
96 dev->cpumask = cpumask_of_cpu(cpu);
98 printk(KERN_NOTICE "timer[%d]: %s - created\n", dev->irq, dev->name);
100 clockevents_register_device(dev);