blob: bfacd6a0619410028f384df6554d2903af450d97 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
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 */
19DEFINE_SPINLOCK(srm_irq_lock);
20
21static inline void
Thomas Gleixner35252252011-02-06 14:32:26 +000022srm_enable_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023{
24 spin_lock(&srm_irq_lock);
Thomas Gleixner35252252011-02-06 14:32:26 +000025 cserve_ena(d->irq - 16);
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 spin_unlock(&srm_irq_lock);
27}
28
29static void
Thomas Gleixner35252252011-02-06 14:32:26 +000030srm_disable_irq(struct irq_data *d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070031{
32 spin_lock(&srm_irq_lock);
Thomas Gleixner35252252011-02-06 14:32:26 +000033 cserve_dis(d->irq - 16);
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 spin_unlock(&srm_irq_lock);
35}
36
Linus Torvalds1da177e2005-04-16 15:20:36 -070037/* Handle interrupts from the SRM, assuming no additional weirdness. */
Thomas Gleixner44377f62009-06-16 15:33:25 -070038static struct irq_chip srm_irq_type = {
Thomas Gleixner8ab12212009-11-30 22:51:31 -050039 .name = "SRM",
Thomas Gleixner35252252011-02-06 14:32:26 +000040 .irq_unmask = srm_enable_irq,
41 .irq_mask = srm_disable_irq,
42 .irq_mask_ack = srm_disable_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -070043};
44
45void __init
46init_srm_irqs(long max, unsigned long ignore_mask)
47{
48 long i;
49
Ivan Kokshaysky70b66cbf2009-01-15 13:51:17 -080050 if (NR_IRQS <= 16)
51 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 for (i = 16; i < max; ++i) {
53 if (i < 64 && ((ignore_mask >> i) & 1))
54 continue;
Thomas Gleixnera9eb0762011-03-25 22:17:31 +010055 irq_set_chip_and_handler(i, &srm_irq_type, handle_level_irq);
Thomas Gleixner35252252011-02-06 14:32:26 +000056 irq_set_status_flags(i, IRQ_LEVEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 }
58}
59
60void
Al Viro7ca560532006-10-08 14:36:08 +010061srm_device_interrupt(unsigned long vector)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062{
63 int irq = (vector - 0x800) >> 4;
Al Viro3dbb8c62006-10-08 14:37:32 +010064 handle_irq(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065}