| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | #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 |  | 
| Al Viro | 32231a6 | 2007-07-21 19:18:57 -0700 | [diff] [blame] | 28 | #include "irq.h" | 
|  | 29 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | extern unsigned long lvl14_save[5]; | 
|  | 31 | static unsigned long *linux_lvl14 = NULL; | 
|  | 32 | static unsigned long obp_lvl14[4]; | 
|  | 33 |  | 
|  | 34 | /* | 
|  | 35 | * Call with timer IRQ closed. | 
|  | 36 | * First time we do it with disable_irq, later prom code uses spin_lock_irq(). | 
|  | 37 | */ | 
|  | 38 | void install_linux_ticker(void) | 
|  | 39 | { | 
|  | 40 |  | 
|  | 41 | if (!linux_lvl14) | 
|  | 42 | return; | 
|  | 43 | linux_lvl14[0] =  lvl14_save[0]; | 
|  | 44 | linux_lvl14[1] =  lvl14_save[1]; | 
|  | 45 | linux_lvl14[2] =  lvl14_save[2]; | 
|  | 46 | linux_lvl14[3] =  lvl14_save[3]; | 
|  | 47 | } | 
|  | 48 |  | 
|  | 49 | void install_obp_ticker(void) | 
|  | 50 | { | 
|  | 51 |  | 
|  | 52 | if (!linux_lvl14) | 
|  | 53 | return; | 
|  | 54 | linux_lvl14[0] =  obp_lvl14[0]; | 
|  | 55 | linux_lvl14[1] =  obp_lvl14[1]; | 
|  | 56 | linux_lvl14[2] =  obp_lvl14[2]; | 
|  | 57 | linux_lvl14[3] =  obp_lvl14[3]; | 
|  | 58 | } | 
|  | 59 |  | 
| David Howells | 40220c1 | 2006-10-09 12:19:47 +0100 | [diff] [blame] | 60 | void claim_ticker14(irq_handler_t handler, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | int irq_nr, unsigned int timeout ) | 
|  | 62 | { | 
|  | 63 | int cpu = smp_processor_id(); | 
|  | 64 |  | 
|  | 65 | /* first we copy the obp handler instructions | 
|  | 66 | */ | 
| Al Viro | 0f51681 | 2007-07-21 19:19:38 -0700 | [diff] [blame] | 67 | __disable_irq(irq_nr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | if (!handler) | 
|  | 69 | return; | 
|  | 70 |  | 
|  | 71 | linux_lvl14 = (unsigned long *)lvl14_save[4]; | 
|  | 72 | obp_lvl14[0] = linux_lvl14[0]; | 
|  | 73 | obp_lvl14[1] = linux_lvl14[1]; | 
|  | 74 | obp_lvl14[2] = linux_lvl14[2]; | 
|  | 75 | obp_lvl14[3] = linux_lvl14[3]; | 
|  | 76 |  | 
|  | 77 | if (!request_irq(irq_nr, | 
|  | 78 | handler, | 
| Thomas Gleixner | 6741320 | 2006-07-01 19:29:26 -0700 | [diff] [blame] | 79 | (IRQF_DISABLED | SA_STATIC_ALLOC), | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | "counter14", | 
|  | 81 | NULL)) { | 
|  | 82 | install_linux_ticker(); | 
|  | 83 | load_profile_irq(cpu, timeout); | 
| Al Viro | 0f51681 | 2007-07-21 19:19:38 -0700 | [diff] [blame] | 84 | __enable_irq(irq_nr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | } | 
|  | 86 | } |