blob: 7107d2f0625db13e1968defbcc736fcc68100a44 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* tick14.c
2 * linux/arch/sparc/kernel/tick14.c
3 *
4 * Copyright (C) 1996 David Redman (djhr@tadpole.co.uk)
5 *
6 * This file handles the Sparc specific level14 ticker
7 * This is really useful for profiling OBP uses it for keyboard
8 * aborts and other stuff.
9 *
10 *
11 */
12#include <linux/errno.h>
13#include <linux/sched.h>
14#include <linux/kernel.h>
15#include <linux/param.h>
16#include <linux/string.h>
17#include <linux/mm.h>
18#include <linux/timex.h>
19#include <linux/interrupt.h>
20
21#include <asm/oplib.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <asm/timer.h>
23#include <asm/mostek.h>
24#include <asm/system.h>
25#include <asm/irq.h>
26#include <asm/io.h>
27
28extern unsigned long lvl14_save[5];
29static unsigned long *linux_lvl14 = NULL;
30static unsigned long obp_lvl14[4];
31
32/*
33 * Call with timer IRQ closed.
34 * First time we do it with disable_irq, later prom code uses spin_lock_irq().
35 */
36void install_linux_ticker(void)
37{
38
39 if (!linux_lvl14)
40 return;
41 linux_lvl14[0] = lvl14_save[0];
42 linux_lvl14[1] = lvl14_save[1];
43 linux_lvl14[2] = lvl14_save[2];
44 linux_lvl14[3] = lvl14_save[3];
45}
46
47void install_obp_ticker(void)
48{
49
50 if (!linux_lvl14)
51 return;
52 linux_lvl14[0] = obp_lvl14[0];
53 linux_lvl14[1] = obp_lvl14[1];
54 linux_lvl14[2] = obp_lvl14[2];
55 linux_lvl14[3] = obp_lvl14[3];
56}
57
Al Viro0d844382006-10-08 14:30:44 +010058void claim_ticker14(irqreturn_t (*handler)(int, void *),
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 int irq_nr, unsigned int timeout )
60{
61 int cpu = smp_processor_id();
62
63 /* first we copy the obp handler instructions
64 */
65 disable_irq(irq_nr);
66 if (!handler)
67 return;
68
69 linux_lvl14 = (unsigned long *)lvl14_save[4];
70 obp_lvl14[0] = linux_lvl14[0];
71 obp_lvl14[1] = linux_lvl14[1];
72 obp_lvl14[2] = linux_lvl14[2];
73 obp_lvl14[3] = linux_lvl14[3];
74
75 if (!request_irq(irq_nr,
76 handler,
Thomas Gleixner67413202006-07-01 19:29:26 -070077 (IRQF_DISABLED | SA_STATIC_ALLOC),
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 "counter14",
79 NULL)) {
80 install_linux_ticker();
81 load_profile_irq(cpu, timeout);
82 enable_irq(irq_nr);
83 }
84}