]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (C) 2003 Ralf Baechle | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License as published by the | |
6 | * Free Software Foundation; either version 2 of the License, or (at your | |
7 | * option) any later version. | |
8 | * | |
9 | * Handler for RM9000 extended interrupts. These are a non-standard | |
10 | * feature so we handle them separately from standard interrupts. | |
11 | */ | |
12 | #include <linux/init.h> | |
13 | #include <linux/interrupt.h> | |
ca4d3e67 | 14 | #include <linux/irq.h> |
1da177e4 LT |
15 | #include <linux/kernel.h> |
16 | #include <linux/module.h> | |
17 | ||
18 | #include <asm/irq_cpu.h> | |
19 | #include <asm/mipsregs.h> | |
20 | #include <asm/system.h> | |
21 | ||
5b3a3741 | 22 | static inline void unmask_rm9k_irq(struct irq_data *d) |
1da177e4 | 23 | { |
5b3a3741 | 24 | set_c0_intcontrol(0x1000 << (d->irq - RM9K_CPU_IRQ_BASE)); |
1da177e4 LT |
25 | } |
26 | ||
5b3a3741 | 27 | static inline void mask_rm9k_irq(struct irq_data *d) |
1da177e4 | 28 | { |
5b3a3741 | 29 | clear_c0_intcontrol(0x1000 << (d->irq - RM9K_CPU_IRQ_BASE)); |
1da177e4 LT |
30 | } |
31 | ||
5b3a3741 | 32 | static inline void rm9k_cpu_irq_enable(struct irq_data *d) |
1da177e4 LT |
33 | { |
34 | unsigned long flags; | |
35 | ||
36 | local_irq_save(flags); | |
5b3a3741 | 37 | unmask_rm9k_irq(d); |
1da177e4 LT |
38 | local_irq_restore(flags); |
39 | } | |
40 | ||
1da177e4 LT |
41 | /* |
42 | * Performance counter interrupts are global on all processors. | |
43 | */ | |
44 | static void local_rm9k_perfcounter_irq_startup(void *args) | |
45 | { | |
5b3a3741 | 46 | rm9k_cpu_irq_enable(args); |
1da177e4 LT |
47 | } |
48 | ||
5b3a3741 | 49 | static unsigned int rm9k_perfcounter_irq_startup(struct irq_data *d) |
1da177e4 | 50 | { |
5b3a3741 | 51 | on_each_cpu(local_rm9k_perfcounter_irq_startup, d, 1); |
1da177e4 LT |
52 | |
53 | return 0; | |
54 | } | |
55 | ||
56 | static void local_rm9k_perfcounter_irq_shutdown(void *args) | |
57 | { | |
1da177e4 LT |
58 | unsigned long flags; |
59 | ||
60 | local_irq_save(flags); | |
5b3a3741 | 61 | mask_rm9k_irq(args); |
1da177e4 LT |
62 | local_irq_restore(flags); |
63 | } | |
64 | ||
5b3a3741 | 65 | static void rm9k_perfcounter_irq_shutdown(struct irq_data *d) |
1da177e4 | 66 | { |
5b3a3741 | 67 | on_each_cpu(local_rm9k_perfcounter_irq_shutdown, d, 1); |
1da177e4 LT |
68 | } |
69 | ||
94dee171 | 70 | static struct irq_chip rm9k_irq_controller = { |
70d21cde | 71 | .name = "RM9000", |
5b3a3741 TG |
72 | .irq_ack = mask_rm9k_irq, |
73 | .irq_mask = mask_rm9k_irq, | |
74 | .irq_mask_ack = mask_rm9k_irq, | |
75 | .irq_unmask = unmask_rm9k_irq, | |
76 | .irq_eoi = unmask_rm9k_irq | |
1da177e4 LT |
77 | }; |
78 | ||
94dee171 | 79 | static struct irq_chip rm9k_perfcounter_irq = { |
70d21cde | 80 | .name = "RM9000", |
5b3a3741 TG |
81 | .irq_startup = rm9k_perfcounter_irq_startup, |
82 | .irq_shutdown = rm9k_perfcounter_irq_shutdown, | |
83 | .irq_ack = mask_rm9k_irq, | |
84 | .irq_mask = mask_rm9k_irq, | |
85 | .irq_mask_ack = mask_rm9k_irq, | |
86 | .irq_unmask = unmask_rm9k_irq, | |
1da177e4 LT |
87 | }; |
88 | ||
89 | unsigned int rm9000_perfcount_irq; | |
90 | ||
91 | EXPORT_SYMBOL(rm9000_perfcount_irq); | |
92 | ||
97dcb82d | 93 | void __init rm9k_cpu_irq_init(void) |
1da177e4 | 94 | { |
97dcb82d | 95 | int base = RM9K_CPU_IRQ_BASE; |
1da177e4 LT |
96 | int i; |
97 | ||
98 | clear_c0_intcontrol(0x0000f000); /* Mask all */ | |
99 | ||
1603b5ac | 100 | for (i = base; i < base + 4; i++) |
1417836e AN |
101 | set_irq_chip_and_handler(i, &rm9k_irq_controller, |
102 | handle_level_irq); | |
1da177e4 LT |
103 | |
104 | rm9000_perfcount_irq = base + 1; | |
1417836e | 105 | set_irq_chip_and_handler(rm9000_perfcount_irq, &rm9k_perfcounter_irq, |
30e748a5 | 106 | handle_percpu_irq); |
1da177e4 | 107 | } |