Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Handle interrupts from the SRM, assuming no additional weirdness. |
| 4 | */ |
| 5 | |
| 6 | #include <linux/init.h> |
| 7 | #include <linux/sched.h> |
| 8 | #include <linux/irq.h> |
| 9 | |
| 10 | #include "proto.h" |
| 11 | #include "irq_impl.h" |
| 12 | |
| 13 | |
| 14 | /* |
| 15 | * Is the palcode SMP safe? In other words: can we call cserve_ena/dis |
| 16 | * at the same time in multiple CPUs? To be safe I added a spinlock |
| 17 | * but it can be removed trivially if the palcode is robust against smp. |
| 18 | */ |
| 19 | DEFINE_SPINLOCK(srm_irq_lock); |
| 20 | |
| 21 | static inline void |
Thomas Gleixner | 3525225 | 2011-02-06 14:32:26 +0000 | [diff] [blame] | 22 | srm_enable_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | { |
| 24 | spin_lock(&srm_irq_lock); |
Thomas Gleixner | 3525225 | 2011-02-06 14:32:26 +0000 | [diff] [blame] | 25 | cserve_ena(d->irq - 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | spin_unlock(&srm_irq_lock); |
| 27 | } |
| 28 | |
| 29 | static void |
Thomas Gleixner | 3525225 | 2011-02-06 14:32:26 +0000 | [diff] [blame] | 30 | srm_disable_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | { |
| 32 | spin_lock(&srm_irq_lock); |
Thomas Gleixner | 3525225 | 2011-02-06 14:32:26 +0000 | [diff] [blame] | 33 | cserve_dis(d->irq - 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | spin_unlock(&srm_irq_lock); |
| 35 | } |
| 36 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | /* Handle interrupts from the SRM, assuming no additional weirdness. */ |
Thomas Gleixner | 44377f6 | 2009-06-16 15:33:25 -0700 | [diff] [blame] | 38 | static struct irq_chip srm_irq_type = { |
Thomas Gleixner | 8ab1221 | 2009-11-30 22:51:31 -0500 | [diff] [blame] | 39 | .name = "SRM", |
Thomas Gleixner | 3525225 | 2011-02-06 14:32:26 +0000 | [diff] [blame] | 40 | .irq_unmask = srm_enable_irq, |
| 41 | .irq_mask = srm_disable_irq, |
| 42 | .irq_mask_ack = srm_disable_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | void __init |
| 46 | init_srm_irqs(long max, unsigned long ignore_mask) |
| 47 | { |
| 48 | long i; |
| 49 | |
Ivan Kokshaysky | 70b66cbf | 2009-01-15 13:51:17 -0800 | [diff] [blame] | 50 | if (NR_IRQS <= 16) |
| 51 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | for (i = 16; i < max; ++i) { |
| 53 | if (i < 64 && ((ignore_mask >> i) & 1)) |
| 54 | continue; |
Thomas Gleixner | a9eb076 | 2011-03-25 22:17:31 +0100 | [diff] [blame] | 55 | irq_set_chip_and_handler(i, &srm_irq_type, handle_level_irq); |
Thomas Gleixner | 3525225 | 2011-02-06 14:32:26 +0000 | [diff] [blame] | 56 | irq_set_status_flags(i, IRQ_LEVEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | } |
| 58 | } |
| 59 | |
| 60 | void |
Al Viro | 7ca56053 | 2006-10-08 14:36:08 +0100 | [diff] [blame] | 61 | srm_device_interrupt(unsigned long vector) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | { |
| 63 | int irq = (vector - 0x800) >> 4; |
Al Viro | 3dbb8c6 | 2006-10-08 14:37:32 +0100 | [diff] [blame] | 64 | handle_irq(irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | } |