| Adrian Bunk | 88278ca | 2008-05-19 16:53:02 -0700 | [diff] [blame] | 1 | /* | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 2 | * Interrupt request handling routines. On the | 
|  | 3 | * Sparc the IRQs are basically 'cast in stone' | 
|  | 4 | * and you are supposed to probe the prom's device | 
|  | 5 | * node trees to find out who's got which IRQ. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * | 
|  | 7 | *  Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) | 
|  | 8 | *  Copyright (C) 1995 Miguel de Icaza (miguel@nuclecu.unam.mx) | 
|  | 9 | *  Copyright (C) 1995,2002 Pete A. Zaitcev (zaitcev@yahoo.com) | 
|  | 10 | *  Copyright (C) 1996 Dave Redman (djhr@tadpole.co.uk) | 
|  | 11 | *  Copyright (C) 1998-2000 Anton Blanchard (anton@samba.org) | 
|  | 12 | */ | 
|  | 13 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/kernel_stat.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | #include <linux/seq_file.h> | 
|  | 16 |  | 
| Sam Ravnborg | a2a211c | 2011-02-25 22:59:20 -0800 | [diff] [blame] | 17 | #include <asm/cacheflush.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm/pcic.h> | 
| Konrad Eisele | 0fd7ef1 | 2009-08-17 00:13:31 +0000 | [diff] [blame] | 19 | #include <asm/leon.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 |  | 
| Sam Ravnborg | 81265fd | 2008-12-08 01:08:24 -0800 | [diff] [blame] | 21 | #include "kernel.h" | 
| Al Viro | 32231a6 | 2007-07-21 19:18:57 -0700 | [diff] [blame] | 22 | #include "irq.h" | 
|  | 23 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #ifdef CONFIG_SMP | 
|  | 25 | #define SMP_NOP2 "nop; nop;\n\t" | 
|  | 26 | #define SMP_NOP3 "nop; nop; nop;\n\t" | 
|  | 27 | #else | 
|  | 28 | #define SMP_NOP2 | 
|  | 29 | #define SMP_NOP3 | 
|  | 30 | #endif /* SMP */ | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 31 |  | 
| Sam Ravnborg | bbdc266 | 2011-02-25 23:00:19 -0800 | [diff] [blame] | 32 | /* platform specific irq setup */ | 
|  | 33 | struct sparc_irq_config sparc_irq_config; | 
|  | 34 |  | 
| David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 35 | unsigned long arch_local_irq_save(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | { | 
|  | 37 | unsigned long retval; | 
|  | 38 | unsigned long tmp; | 
|  | 39 |  | 
|  | 40 | __asm__ __volatile__( | 
|  | 41 | "rd	%%psr, %0\n\t" | 
|  | 42 | SMP_NOP3	/* Sun4m + Cypress + SMP bug */ | 
|  | 43 | "or	%0, %2, %1\n\t" | 
|  | 44 | "wr	%1, 0, %%psr\n\t" | 
|  | 45 | "nop; nop; nop\n" | 
|  | 46 | : "=&r" (retval), "=r" (tmp) | 
|  | 47 | : "i" (PSR_PIL) | 
|  | 48 | : "memory"); | 
|  | 49 |  | 
|  | 50 | return retval; | 
|  | 51 | } | 
| David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 52 | EXPORT_SYMBOL(arch_local_irq_save); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 |  | 
| David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 54 | void arch_local_irq_enable(void) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | { | 
|  | 56 | unsigned long tmp; | 
|  | 57 |  | 
|  | 58 | __asm__ __volatile__( | 
|  | 59 | "rd	%%psr, %0\n\t" | 
|  | 60 | SMP_NOP3	/* Sun4m + Cypress + SMP bug */ | 
|  | 61 | "andn	%0, %1, %0\n\t" | 
|  | 62 | "wr	%0, 0, %%psr\n\t" | 
|  | 63 | "nop; nop; nop\n" | 
|  | 64 | : "=&r" (tmp) | 
|  | 65 | : "i" (PSR_PIL) | 
|  | 66 | : "memory"); | 
|  | 67 | } | 
| David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 68 | EXPORT_SYMBOL(arch_local_irq_enable); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 |  | 
| David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 70 | void arch_local_irq_restore(unsigned long old_psr) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { | 
|  | 72 | unsigned long tmp; | 
|  | 73 |  | 
|  | 74 | __asm__ __volatile__( | 
|  | 75 | "rd	%%psr, %0\n\t" | 
|  | 76 | "and	%2, %1, %2\n\t" | 
|  | 77 | SMP_NOP2	/* Sun4m + Cypress + SMP bug */ | 
|  | 78 | "andn	%0, %1, %0\n\t" | 
|  | 79 | "wr	%0, %2, %%psr\n\t" | 
|  | 80 | "nop; nop; nop\n" | 
|  | 81 | : "=&r" (tmp) | 
|  | 82 | : "i" (PSR_PIL), "r" (old_psr) | 
|  | 83 | : "memory"); | 
|  | 84 | } | 
| David Howells | df9ee29 | 2010-10-07 14:08:55 +0100 | [diff] [blame] | 85 | EXPORT_SYMBOL(arch_local_irq_restore); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 |  | 
|  | 87 | /* | 
|  | 88 | * Dave Redman (djhr@tadpole.co.uk) | 
|  | 89 | * | 
|  | 90 | * IRQ numbers.. These are no longer restricted to 15.. | 
|  | 91 | * | 
|  | 92 | * this is done to enable SBUS cards and onboard IO to be masked | 
|  | 93 | * correctly. using the interrupt level isn't good enough. | 
|  | 94 | * | 
|  | 95 | * For example: | 
|  | 96 | *   A device interrupting at sbus level6 and the Floppy both come in | 
|  | 97 | *   at IRQ11, but enabling and disabling them requires writing to | 
|  | 98 | *   different bits in the SLAVIO/SEC. | 
|  | 99 | * | 
|  | 100 | * As a result of these changes sun4m machines could now support | 
|  | 101 | * directed CPU interrupts using the existing enable/disable irq code | 
|  | 102 | * with tweaks. | 
|  | 103 | * | 
|  | 104 | */ | 
|  | 105 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 |  | 
|  | 108 | /* | 
|  | 109 | * Dave Redman (djhr@tadpole.co.uk) | 
|  | 110 | * | 
|  | 111 | * There used to be extern calls and hard coded values here.. very sucky! | 
|  | 112 | * instead, because some of the devices attach very early, I do something | 
|  | 113 | * equally sucky but at least we'll never try to free statically allocated | 
|  | 114 | * space or call kmalloc before kmalloc_init :(. | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 115 | * | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | * In fact it's the timer10 that attaches first.. then timer14 | 
|  | 117 | * then kmalloc_init is called.. then the tty interrupts attach. | 
|  | 118 | * hmmm.... | 
|  | 119 | * | 
|  | 120 | */ | 
|  | 121 | #define MAX_STATIC_ALLOC	4 | 
|  | 122 | struct irqaction static_irqaction[MAX_STATIC_ALLOC]; | 
|  | 123 | int static_irq_count; | 
|  | 124 |  | 
| Adrian Bunk | c61c65c | 2008-06-05 11:40:58 -0700 | [diff] [blame] | 125 | static struct { | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 126 | struct irqaction *action; | 
|  | 127 | int flags; | 
|  | 128 | } sparc_irq[NR_IRQS]; | 
|  | 129 | #define SPARC_IRQ_INPROGRESS 1 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 |  | 
|  | 131 | /* Used to protect the IRQ action lists */ | 
|  | 132 | DEFINE_SPINLOCK(irq_action_lock); | 
|  | 133 |  | 
|  | 134 | int show_interrupts(struct seq_file *p, void *v) | 
|  | 135 | { | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 136 | int i = *(loff_t *)v; | 
|  | 137 | struct irqaction *action; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | unsigned long flags; | 
|  | 139 | #ifdef CONFIG_SMP | 
|  | 140 | int j; | 
|  | 141 | #endif | 
|  | 142 |  | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 143 | if (sparc_cpu_model == sun4d) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | return show_sun4d_interrupts(p, v); | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 145 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | spin_lock_irqsave(&irq_action_lock, flags); | 
|  | 147 | if (i < NR_IRQS) { | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 148 | action = sparc_irq[i].action; | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 149 | if (!action) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | goto out_unlock; | 
|  | 151 | seq_printf(p, "%3d: ", i); | 
|  | 152 | #ifndef CONFIG_SMP | 
|  | 153 | seq_printf(p, "%10u ", kstat_irqs(i)); | 
|  | 154 | #else | 
| Andrew Morton | 394e390 | 2006-03-23 03:01:05 -0800 | [diff] [blame] | 155 | for_each_online_cpu(j) { | 
|  | 156 | seq_printf(p, "%10u ", | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 157 | kstat_cpu(j).irqs[i]); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | } | 
|  | 159 | #endif | 
|  | 160 | seq_printf(p, " %c %s", | 
| Thomas Gleixner | 6741320 | 2006-07-01 19:29:26 -0700 | [diff] [blame] | 161 | (action->flags & IRQF_DISABLED) ? '+' : ' ', | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | action->name); | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 163 | for (action = action->next; action; action = action->next) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | seq_printf(p, ",%s %s", | 
| Thomas Gleixner | 6741320 | 2006-07-01 19:29:26 -0700 | [diff] [blame] | 165 | (action->flags & IRQF_DISABLED) ? " +" : "", | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | action->name); | 
|  | 167 | } | 
|  | 168 | seq_putc(p, '\n'); | 
|  | 169 | } | 
|  | 170 | out_unlock: | 
|  | 171 | spin_unlock_irqrestore(&irq_action_lock, flags); | 
|  | 172 | return 0; | 
|  | 173 | } | 
|  | 174 |  | 
|  | 175 | void free_irq(unsigned int irq, void *dev_id) | 
|  | 176 | { | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 177 | struct irqaction *action; | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 178 | struct irqaction **actionp; | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 179 | unsigned long flags; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | unsigned int cpu_irq; | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 181 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | if (sparc_cpu_model == sun4d) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | sun4d_free_irq(irq, dev_id); | 
|  | 184 | return; | 
|  | 185 | } | 
|  | 186 | cpu_irq = irq & (NR_IRQS - 1); | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 187 | if (cpu_irq > 14) {  /* 14 irq levels on the sparc */ | 
|  | 188 | printk(KERN_ERR "Trying to free bogus IRQ %d\n", irq); | 
|  | 189 | return; | 
|  | 190 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 |  | 
|  | 192 | spin_lock_irqsave(&irq_action_lock, flags); | 
|  | 193 |  | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 194 | actionp = &sparc_irq[cpu_irq].action; | 
|  | 195 | action = *actionp; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 |  | 
|  | 197 | if (!action->handler) { | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 198 | printk(KERN_ERR "Trying to free free IRQ%d\n", irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | goto out_unlock; | 
|  | 200 | } | 
|  | 201 | if (dev_id) { | 
|  | 202 | for (; action; action = action->next) { | 
|  | 203 | if (action->dev_id == dev_id) | 
|  | 204 | break; | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 205 | actionp = &action->next; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | } | 
|  | 207 | if (!action) { | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 208 | printk(KERN_ERR "Trying to free free shared IRQ%d\n", | 
|  | 209 | irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | goto out_unlock; | 
|  | 211 | } | 
| Thomas Gleixner | 6741320 | 2006-07-01 19:29:26 -0700 | [diff] [blame] | 212 | } else if (action->flags & IRQF_SHARED) { | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 213 | printk(KERN_ERR "Trying to free shared IRQ%d with NULL device ID\n", | 
|  | 214 | irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | goto out_unlock; | 
|  | 216 | } | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 217 | if (action->flags & SA_STATIC_ALLOC) { | 
|  | 218 | /* | 
|  | 219 | * This interrupt is marked as specially allocated | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | * so it is a bad idea to free it. | 
|  | 221 | */ | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 222 | printk(KERN_ERR "Attempt to free statically allocated IRQ%d (%s)\n", | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | irq, action->name); | 
|  | 224 | goto out_unlock; | 
|  | 225 | } | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 226 |  | 
|  | 227 | *actionp = action->next; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 |  | 
|  | 229 | spin_unlock_irqrestore(&irq_action_lock, flags); | 
|  | 230 |  | 
|  | 231 | synchronize_irq(irq); | 
|  | 232 |  | 
|  | 233 | spin_lock_irqsave(&irq_action_lock, flags); | 
|  | 234 |  | 
|  | 235 | kfree(action); | 
|  | 236 |  | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 237 | if (!sparc_irq[cpu_irq].action) | 
| Al Viro | 0f51681 | 2007-07-21 19:19:38 -0700 | [diff] [blame] | 238 | __disable_irq(irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 |  | 
|  | 240 | out_unlock: | 
|  | 241 | spin_unlock_irqrestore(&irq_action_lock, flags); | 
|  | 242 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | EXPORT_SYMBOL(free_irq); | 
|  | 244 |  | 
|  | 245 | /* | 
|  | 246 | * This is called when we want to synchronize with | 
|  | 247 | * interrupts. We may for example tell a device to | 
|  | 248 | * stop sending interrupts: but to make sure there | 
|  | 249 | * are no interrupts that are executing on another | 
|  | 250 | * CPU we need to call this function. | 
|  | 251 | */ | 
|  | 252 | #ifdef CONFIG_SMP | 
|  | 253 | void synchronize_irq(unsigned int irq) | 
|  | 254 | { | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 255 | unsigned int cpu_irq; | 
|  | 256 |  | 
|  | 257 | cpu_irq = irq & (NR_IRQS - 1); | 
|  | 258 | while (sparc_irq[cpu_irq].flags & SPARC_IRQ_INPROGRESS) | 
|  | 259 | cpu_relax(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | } | 
| Sam Ravnborg | 6943f3d | 2009-01-08 16:58:05 -0800 | [diff] [blame] | 261 | EXPORT_SYMBOL(synchronize_irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | #endif /* SMP */ | 
|  | 263 |  | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 264 | void unexpected_irq(int irq, void *dev_id, struct pt_regs *regs) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | { | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 266 | int i; | 
|  | 267 | struct irqaction *action; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 268 | unsigned int cpu_irq; | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 269 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | cpu_irq = irq & (NR_IRQS - 1); | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 271 | action = sparc_irq[cpu_irq].action; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 |  | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 273 | printk(KERN_ERR "IO device interrupt, irq = %d\n", irq); | 
|  | 274 | printk(KERN_ERR "PC = %08lx NPC = %08lx FP=%08lx\n", regs->pc, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | regs->npc, regs->u_regs[14]); | 
|  | 276 | if (action) { | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 277 | printk(KERN_ERR "Expecting: "); | 
|  | 278 | for (i = 0; i < 16; i++) | 
|  | 279 | if (action->handler) | 
|  | 280 | printk(KERN_CONT "[%s:%d:0x%x] ", action->name, | 
|  | 281 | i, (unsigned int)action->handler); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | } | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 283 | printk(KERN_ERR "AIEEE\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | panic("bogus interrupt received"); | 
|  | 285 | } | 
|  | 286 |  | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 287 | void handler_irq(int pil, struct pt_regs *regs) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | { | 
| Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 289 | struct pt_regs *old_regs; | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 290 | struct irqaction *action; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | int cpu = smp_processor_id(); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 |  | 
| Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 293 | old_regs = set_irq_regs(regs); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | irq_enter(); | 
| Sam Ravnborg | d4d1ec4 | 2011-01-22 11:32:15 +0000 | [diff] [blame] | 295 | disable_pil_irq(pil); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | #ifdef CONFIG_SMP | 
| Simon Arlott | d1a78c3 | 2007-05-11 13:51:23 -0700 | [diff] [blame] | 297 | /* Only rotate on lower priority IRQs (scsi, ethernet, etc.). */ | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 298 | if ((sparc_cpu_model==sun4m) && (pil < 10)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | smp4m_irq_rotate(cpu); | 
|  | 300 | #endif | 
| Sam Ravnborg | d4d1ec4 | 2011-01-22 11:32:15 +0000 | [diff] [blame] | 301 | action = sparc_irq[pil].action; | 
|  | 302 | sparc_irq[pil].flags |= SPARC_IRQ_INPROGRESS; | 
|  | 303 | kstat_cpu(cpu).irqs[pil]++; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | do { | 
|  | 305 | if (!action || !action->handler) | 
| Sam Ravnborg | d4d1ec4 | 2011-01-22 11:32:15 +0000 | [diff] [blame] | 306 | unexpected_irq(pil, NULL, regs); | 
|  | 307 | action->handler(pil, action->dev_id); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | action = action->next; | 
|  | 309 | } while (action); | 
| Sam Ravnborg | d4d1ec4 | 2011-01-22 11:32:15 +0000 | [diff] [blame] | 310 | sparc_irq[pil].flags &= ~SPARC_IRQ_INPROGRESS; | 
|  | 311 | enable_pil_irq(pil); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | irq_exit(); | 
| Al Viro | 0d84438 | 2006-10-08 14:30:44 +0100 | [diff] [blame] | 313 | set_irq_regs(old_regs); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | } | 
|  | 315 |  | 
| David S. Miller | 0a808a3 | 2007-08-02 00:19:14 -0700 | [diff] [blame] | 316 | #if defined(CONFIG_BLK_DEV_FD) || defined(CONFIG_BLK_DEV_FD_MODULE) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 |  | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 318 | /* | 
|  | 319 | * Fast IRQs on the Sparc can only have one routine attached to them, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | * thus no sharing possible. | 
|  | 321 | */ | 
| David S. Miller | 0a808a3 | 2007-08-02 00:19:14 -0700 | [diff] [blame] | 322 | static int request_fast_irq(unsigned int irq, | 
|  | 323 | void (*handler)(void), | 
|  | 324 | unsigned long irqflags, const char *devname) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | { | 
|  | 326 | struct irqaction *action; | 
|  | 327 | unsigned long flags; | 
|  | 328 | unsigned int cpu_irq; | 
|  | 329 | int ret; | 
| Namhyung Kim | 5167232 | 2010-10-25 05:52:38 +0000 | [diff] [blame] | 330 | #if defined CONFIG_SMP && !defined CONFIG_SPARC_LEON | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | struct tt_entry *trap_table; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | #endif | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | cpu_irq = irq & (NR_IRQS - 1); | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 334 | if (cpu_irq > 14) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | ret = -EINVAL; | 
|  | 336 | goto out; | 
|  | 337 | } | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 338 | if (!handler) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | ret = -EINVAL; | 
|  | 340 | goto out; | 
|  | 341 | } | 
|  | 342 |  | 
|  | 343 | spin_lock_irqsave(&irq_action_lock, flags); | 
|  | 344 |  | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 345 | action = sparc_irq[cpu_irq].action; | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 346 | if (action) { | 
|  | 347 | if (action->flags & IRQF_SHARED) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | panic("Trying to register fast irq when already shared.\n"); | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 349 | if (irqflags & IRQF_SHARED) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | panic("Trying to register fast irq as shared.\n"); | 
|  | 351 |  | 
|  | 352 | /* Anyway, someone already owns it so cannot be made fast. */ | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 353 | printk(KERN_ERR "request_fast_irq: Trying to register yet already owned.\n"); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | ret = -EBUSY; | 
|  | 355 | goto out_unlock; | 
|  | 356 | } | 
|  | 357 |  | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 358 | /* | 
|  | 359 | * If this is flagged as statically allocated then we use our | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | * private struct which is never freed. | 
|  | 361 | */ | 
|  | 362 | if (irqflags & SA_STATIC_ALLOC) { | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 363 | if (static_irq_count < MAX_STATIC_ALLOC) | 
|  | 364 | action = &static_irqaction[static_irq_count++]; | 
|  | 365 | else | 
|  | 366 | printk(KERN_ERR "Fast IRQ%d (%s) SA_STATIC_ALLOC failed using kmalloc\n", | 
|  | 367 | irq, devname); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | } | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 369 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | if (action == NULL) | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 371 | action = kmalloc(sizeof(struct irqaction), GFP_ATOMIC); | 
|  | 372 | if (!action) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | ret = -ENOMEM; | 
|  | 374 | goto out_unlock; | 
|  | 375 | } | 
|  | 376 |  | 
|  | 377 | /* Dork with trap table if we get this far. */ | 
|  | 378 | #define INSTANTIATE(table) \ | 
|  | 379 | table[SP_TRAP_IRQ1+(cpu_irq-1)].inst_one = SPARC_RD_PSR_L0; \ | 
|  | 380 | table[SP_TRAP_IRQ1+(cpu_irq-1)].inst_two = \ | 
|  | 381 | SPARC_BRANCH((unsigned long) handler, \ | 
|  | 382 | (unsigned long) &table[SP_TRAP_IRQ1+(cpu_irq-1)].inst_two);\ | 
|  | 383 | table[SP_TRAP_IRQ1+(cpu_irq-1)].inst_three = SPARC_RD_WIM_L3; \ | 
|  | 384 | table[SP_TRAP_IRQ1+(cpu_irq-1)].inst_four = SPARC_NOP; | 
|  | 385 |  | 
|  | 386 | INSTANTIATE(sparc_ttable) | 
| Namhyung Kim | 5167232 | 2010-10-25 05:52:38 +0000 | [diff] [blame] | 387 | #if defined CONFIG_SMP && !defined CONFIG_SPARC_LEON | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 388 | trap_table = &trapbase_cpu1; | 
|  | 389 | INSTANTIATE(trap_table) | 
|  | 390 | trap_table = &trapbase_cpu2; | 
|  | 391 | INSTANTIATE(trap_table) | 
|  | 392 | trap_table = &trapbase_cpu3; | 
|  | 393 | INSTANTIATE(trap_table) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | #endif | 
|  | 395 | #undef INSTANTIATE | 
|  | 396 | /* | 
|  | 397 | * XXX Correct thing whould be to flush only I- and D-cache lines | 
|  | 398 | * which contain the handler in question. But as of time of the | 
|  | 399 | * writing we have no CPU-neutral interface to fine-grained flushes. | 
|  | 400 | */ | 
|  | 401 | flush_cache_all(); | 
|  | 402 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | action->flags = irqflags; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | action->name = devname; | 
|  | 405 | action->dev_id = NULL; | 
|  | 406 | action->next = NULL; | 
|  | 407 |  | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 408 | sparc_irq[cpu_irq].action = action; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 |  | 
| Al Viro | 0f51681 | 2007-07-21 19:19:38 -0700 | [diff] [blame] | 410 | __enable_irq(irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 |  | 
|  | 412 | ret = 0; | 
|  | 413 | out_unlock: | 
|  | 414 | spin_unlock_irqrestore(&irq_action_lock, flags); | 
|  | 415 | out: | 
|  | 416 | return ret; | 
|  | 417 | } | 
|  | 418 |  | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 419 | /* | 
|  | 420 | * These variables are used to access state from the assembler | 
| David S. Miller | 0a808a3 | 2007-08-02 00:19:14 -0700 | [diff] [blame] | 421 | * interrupt handler, floppy_hardint, so we cannot put these in | 
|  | 422 | * the floppy driver image because that would not work in the | 
|  | 423 | * modular case. | 
|  | 424 | */ | 
|  | 425 | volatile unsigned char *fdc_status; | 
|  | 426 | EXPORT_SYMBOL(fdc_status); | 
|  | 427 |  | 
|  | 428 | char *pdma_vaddr; | 
|  | 429 | EXPORT_SYMBOL(pdma_vaddr); | 
|  | 430 |  | 
|  | 431 | unsigned long pdma_size; | 
|  | 432 | EXPORT_SYMBOL(pdma_size); | 
|  | 433 |  | 
|  | 434 | volatile int doing_pdma; | 
|  | 435 | EXPORT_SYMBOL(doing_pdma); | 
|  | 436 |  | 
|  | 437 | char *pdma_base; | 
|  | 438 | EXPORT_SYMBOL(pdma_base); | 
|  | 439 |  | 
|  | 440 | unsigned long pdma_areasize; | 
|  | 441 | EXPORT_SYMBOL(pdma_areasize); | 
|  | 442 |  | 
| Jeff Garzik | 7c23997 | 2007-10-19 03:12:20 -0400 | [diff] [blame] | 443 | static irq_handler_t floppy_irq_handler; | 
| David S. Miller | 0a808a3 | 2007-08-02 00:19:14 -0700 | [diff] [blame] | 444 |  | 
|  | 445 | void sparc_floppy_irq(int irq, void *dev_id, struct pt_regs *regs) | 
|  | 446 | { | 
|  | 447 | struct pt_regs *old_regs; | 
|  | 448 | int cpu = smp_processor_id(); | 
|  | 449 |  | 
|  | 450 | old_regs = set_irq_regs(regs); | 
|  | 451 | disable_pil_irq(irq); | 
|  | 452 | irq_enter(); | 
|  | 453 | kstat_cpu(cpu).irqs[irq]++; | 
|  | 454 | floppy_irq_handler(irq, dev_id); | 
|  | 455 | irq_exit(); | 
|  | 456 | enable_pil_irq(irq); | 
|  | 457 | set_irq_regs(old_regs); | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 458 | /* | 
|  | 459 | * XXX Eek, it's totally changed with preempt_count() and such | 
|  | 460 | * if (softirq_pending(cpu)) | 
|  | 461 | *	do_softirq(); | 
|  | 462 | */ | 
| David S. Miller | 0a808a3 | 2007-08-02 00:19:14 -0700 | [diff] [blame] | 463 | } | 
|  | 464 |  | 
|  | 465 | int sparc_floppy_request_irq(int irq, unsigned long flags, | 
| Jeff Garzik | 7c23997 | 2007-10-19 03:12:20 -0400 | [diff] [blame] | 466 | irq_handler_t irq_handler) | 
| David S. Miller | 0a808a3 | 2007-08-02 00:19:14 -0700 | [diff] [blame] | 467 | { | 
|  | 468 | floppy_irq_handler = irq_handler; | 
|  | 469 | return request_fast_irq(irq, floppy_hardint, flags, "floppy"); | 
|  | 470 | } | 
|  | 471 | EXPORT_SYMBOL(sparc_floppy_request_irq); | 
|  | 472 |  | 
|  | 473 | #endif | 
|  | 474 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | int request_irq(unsigned int irq, | 
| David Howells | 40220c1 | 2006-10-09 12:19:47 +0100 | [diff] [blame] | 476 | irq_handler_t handler, | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 477 | unsigned long irqflags, const char *devname, void *dev_id) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | { | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 479 | struct irqaction *action, **actionp; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | unsigned long flags; | 
|  | 481 | unsigned int cpu_irq; | 
|  | 482 | int ret; | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 483 |  | 
|  | 484 | if (sparc_cpu_model == sun4d) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | return sun4d_request_irq(irq, handler, irqflags, devname, dev_id); | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 486 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 487 | cpu_irq = irq & (NR_IRQS - 1); | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 488 | if (cpu_irq > 14) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | ret = -EINVAL; | 
|  | 490 | goto out; | 
|  | 491 | } | 
|  | 492 | if (!handler) { | 
|  | 493 | ret = -EINVAL; | 
|  | 494 | goto out; | 
|  | 495 | } | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 496 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 497 | spin_lock_irqsave(&irq_action_lock, flags); | 
|  | 498 |  | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 499 | actionp = &sparc_irq[cpu_irq].action; | 
|  | 500 | action = *actionp; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | if (action) { | 
| Thomas Gleixner | 6741320 | 2006-07-01 19:29:26 -0700 | [diff] [blame] | 502 | if (!(action->flags & IRQF_SHARED) || !(irqflags & IRQF_SHARED)) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | ret = -EBUSY; | 
|  | 504 | goto out_unlock; | 
|  | 505 | } | 
| Thomas Gleixner | 6741320 | 2006-07-01 19:29:26 -0700 | [diff] [blame] | 506 | if ((action->flags & IRQF_DISABLED) != (irqflags & IRQF_DISABLED)) { | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 507 | printk(KERN_ERR "Attempt to mix fast and slow interrupts on IRQ%d denied\n", | 
|  | 508 | irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | ret = -EBUSY; | 
|  | 510 | goto out_unlock; | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 511 | } | 
|  | 512 | for ( ; action; action = *actionp) | 
|  | 513 | actionp = &action->next; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 514 | } | 
|  | 515 |  | 
|  | 516 | /* If this is flagged as statically allocated then we use our | 
|  | 517 | * private struct which is never freed. | 
|  | 518 | */ | 
|  | 519 | if (irqflags & SA_STATIC_ALLOC) { | 
|  | 520 | if (static_irq_count < MAX_STATIC_ALLOC) | 
|  | 521 | action = &static_irqaction[static_irq_count++]; | 
|  | 522 | else | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 523 | printk(KERN_ERR "Request for IRQ%d (%s) SA_STATIC_ALLOC failed using kmalloc\n", | 
|  | 524 | irq, devname); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | if (action == NULL) | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 527 | action = kmalloc(sizeof(struct irqaction), GFP_ATOMIC); | 
|  | 528 | if (!action) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | ret = -ENOMEM; | 
|  | 530 | goto out_unlock; | 
|  | 531 | } | 
|  | 532 |  | 
|  | 533 | action->handler = handler; | 
|  | 534 | action->flags = irqflags; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | action->name = devname; | 
|  | 536 | action->next = NULL; | 
|  | 537 | action->dev_id = dev_id; | 
|  | 538 |  | 
| Bob Breuer | a54123e | 2006-03-23 22:36:19 -0800 | [diff] [blame] | 539 | *actionp = action; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 |  | 
| Al Viro | 0f51681 | 2007-07-21 19:19:38 -0700 | [diff] [blame] | 541 | __enable_irq(irq); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 |  | 
|  | 543 | ret = 0; | 
|  | 544 | out_unlock: | 
|  | 545 | spin_unlock_irqrestore(&irq_action_lock, flags); | 
|  | 546 | out: | 
|  | 547 | return ret; | 
|  | 548 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | EXPORT_SYMBOL(request_irq); | 
|  | 550 |  | 
| Al Viro | 0f51681 | 2007-07-21 19:19:38 -0700 | [diff] [blame] | 551 | void disable_irq_nosync(unsigned int irq) | 
|  | 552 | { | 
| Sam Ravnborg | 81265fd | 2008-12-08 01:08:24 -0800 | [diff] [blame] | 553 | __disable_irq(irq); | 
| Al Viro | 0f51681 | 2007-07-21 19:19:38 -0700 | [diff] [blame] | 554 | } | 
|  | 555 | EXPORT_SYMBOL(disable_irq_nosync); | 
|  | 556 |  | 
|  | 557 | void disable_irq(unsigned int irq) | 
|  | 558 | { | 
| Sam Ravnborg | 81265fd | 2008-12-08 01:08:24 -0800 | [diff] [blame] | 559 | __disable_irq(irq); | 
| Al Viro | 0f51681 | 2007-07-21 19:19:38 -0700 | [diff] [blame] | 560 | } | 
|  | 561 | EXPORT_SYMBOL(disable_irq); | 
|  | 562 |  | 
|  | 563 | void enable_irq(unsigned int irq) | 
|  | 564 | { | 
| Sam Ravnborg | 81265fd | 2008-12-08 01:08:24 -0800 | [diff] [blame] | 565 | __enable_irq(irq); | 
| Al Viro | 0f51681 | 2007-07-21 19:19:38 -0700 | [diff] [blame] | 566 | } | 
| Al Viro | 0f51681 | 2007-07-21 19:19:38 -0700 | [diff] [blame] | 567 | EXPORT_SYMBOL(enable_irq); | 
|  | 568 |  | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 569 | /* | 
|  | 570 | * We really don't need these at all on the Sparc.  We only have | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | * stubs here because they are exported to modules. | 
|  | 572 | */ | 
|  | 573 | unsigned long probe_irq_on(void) | 
|  | 574 | { | 
|  | 575 | return 0; | 
|  | 576 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | EXPORT_SYMBOL(probe_irq_on); | 
|  | 578 |  | 
|  | 579 | int probe_irq_off(unsigned long mask) | 
|  | 580 | { | 
|  | 581 | return 0; | 
|  | 582 | } | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | EXPORT_SYMBOL(probe_irq_off); | 
|  | 584 |  | 
| Sam Ravnborg | 1d05995 | 2011-02-25 23:01:19 -0800 | [diff] [blame] | 585 | static unsigned int build_device_irq(struct platform_device *op, | 
|  | 586 | unsigned int real_irq) | 
|  | 587 | { | 
|  | 588 | return real_irq; | 
|  | 589 | } | 
|  | 590 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | /* djhr | 
|  | 592 | * This could probably be made indirect too and assigned in the CPU | 
|  | 593 | * bits of the code. That would be much nicer I think and would also | 
|  | 594 | * fit in with the idea of being able to tune your kernel for your machine | 
|  | 595 | * by removing unrequired machine and device support. | 
|  | 596 | * | 
|  | 597 | */ | 
|  | 598 |  | 
|  | 599 | void __init init_IRQ(void) | 
|  | 600 | { | 
| Sam Ravnborg | 1d05995 | 2011-02-25 23:01:19 -0800 | [diff] [blame] | 601 | sparc_irq_config.build_device_irq = build_device_irq; | 
|  | 602 |  | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 603 | switch (sparc_cpu_model) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | case sun4c: | 
|  | 605 | case sun4: | 
|  | 606 | sun4c_init_IRQ(); | 
|  | 607 | break; | 
|  | 608 |  | 
|  | 609 | case sun4m: | 
|  | 610 | #ifdef CONFIG_PCI | 
|  | 611 | pcic_probe(); | 
|  | 612 | if (pcic_present()) { | 
|  | 613 | sun4m_pci_init_IRQ(); | 
|  | 614 | break; | 
|  | 615 | } | 
|  | 616 | #endif | 
|  | 617 | sun4m_init_IRQ(); | 
|  | 618 | break; | 
| Sam Ravnborg | fd49bf4 | 2011-01-28 22:08:24 +0000 | [diff] [blame] | 619 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | case sun4d: | 
|  | 621 | sun4d_init_IRQ(); | 
|  | 622 | break; | 
|  | 623 |  | 
| Konrad Eisele | 0fd7ef1 | 2009-08-17 00:13:31 +0000 | [diff] [blame] | 624 | case sparc_leon: | 
|  | 625 | leon_init_IRQ(); | 
|  | 626 | break; | 
|  | 627 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | default: | 
| Simon Arlott | d1a78c3 | 2007-05-11 13:51:23 -0700 | [diff] [blame] | 629 | prom_printf("Cannot initialize IRQs on this Sun machine..."); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | break; | 
|  | 631 | } | 
|  | 632 | btfixup(); | 
|  | 633 | } | 
|  | 634 |  | 
| Julian Calaby | 4696b64 | 2009-01-05 18:13:49 -0800 | [diff] [blame] | 635 | #ifdef CONFIG_PROC_FS | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | void init_irq_proc(void) | 
|  | 637 | { | 
|  | 638 | /* For now, nothing... */ | 
|  | 639 | } | 
| Julian Calaby | 4696b64 | 2009-01-05 18:13:49 -0800 | [diff] [blame] | 640 | #endif /* CONFIG_PROC_FS */ |