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 | * linux/arch/alpha/kernel/irq_pyxis.c |
| 4 | * |
| 5 | * Based on code written by David A Rusling (david.rusling@reo.mts.dec.com). |
| 6 | * |
| 7 | * IRQ Code common to all PYXIS core logic chips. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/init.h> |
| 11 | #include <linux/sched.h> |
| 12 | #include <linux/irq.h> |
| 13 | |
| 14 | #include <asm/io.h> |
| 15 | #include <asm/core_cia.h> |
| 16 | |
| 17 | #include "proto.h" |
| 18 | #include "irq_impl.h" |
| 19 | |
| 20 | |
| 21 | /* Note mask bit is true for ENABLED irqs. */ |
| 22 | static unsigned long cached_irq_mask; |
| 23 | |
| 24 | static inline void |
| 25 | pyxis_update_irq_hw(unsigned long mask) |
| 26 | { |
| 27 | *(vulp)PYXIS_INT_MASK = mask; |
| 28 | mb(); |
| 29 | *(vulp)PYXIS_INT_MASK; |
| 30 | } |
| 31 | |
| 32 | static inline void |
Thomas Gleixner | 592924c | 2011-02-06 14:32:23 +0000 | [diff] [blame] | 33 | pyxis_enable_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | { |
Thomas Gleixner | 592924c | 2011-02-06 14:32:23 +0000 | [diff] [blame] | 35 | pyxis_update_irq_hw(cached_irq_mask |= 1UL << (d->irq - 16)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | static void |
Thomas Gleixner | 592924c | 2011-02-06 14:32:23 +0000 | [diff] [blame] | 39 | pyxis_disable_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | { |
Thomas Gleixner | 592924c | 2011-02-06 14:32:23 +0000 | [diff] [blame] | 41 | pyxis_update_irq_hw(cached_irq_mask &= ~(1UL << (d->irq - 16))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | } |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | static void |
Thomas Gleixner | 592924c | 2011-02-06 14:32:23 +0000 | [diff] [blame] | 45 | pyxis_mask_and_ack_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | { |
Thomas Gleixner | 592924c | 2011-02-06 14:32:23 +0000 | [diff] [blame] | 47 | unsigned long bit = 1UL << (d->irq - 16); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | unsigned long mask = cached_irq_mask &= ~bit; |
| 49 | |
| 50 | /* Disable the interrupt. */ |
| 51 | *(vulp)PYXIS_INT_MASK = mask; |
| 52 | wmb(); |
| 53 | /* Ack PYXIS PCI interrupt. */ |
| 54 | *(vulp)PYXIS_INT_REQ = bit; |
| 55 | mb(); |
| 56 | /* Re-read to force both writes. */ |
| 57 | *(vulp)PYXIS_INT_MASK; |
| 58 | } |
| 59 | |
Thomas Gleixner | 44377f6 | 2009-06-16 15:33:25 -0700 | [diff] [blame] | 60 | static struct irq_chip pyxis_irq_type = { |
Thomas Gleixner | 8ab1221 | 2009-11-30 22:51:31 -0500 | [diff] [blame] | 61 | .name = "PYXIS", |
Thomas Gleixner | 592924c | 2011-02-06 14:32:23 +0000 | [diff] [blame] | 62 | .irq_mask_ack = pyxis_mask_and_ack_irq, |
| 63 | .irq_mask = pyxis_disable_irq, |
| 64 | .irq_unmask = pyxis_enable_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | void |
Al Viro | 7ca56053 | 2006-10-08 14:36:08 +0100 | [diff] [blame] | 68 | pyxis_device_interrupt(unsigned long vector) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | { |
| 70 | unsigned long pld; |
| 71 | unsigned int i; |
| 72 | |
| 73 | /* Read the interrupt summary register of PYXIS */ |
| 74 | pld = *(vulp)PYXIS_INT_REQ; |
| 75 | pld &= cached_irq_mask; |
| 76 | |
| 77 | /* |
| 78 | * Now for every possible bit set, work through them and call |
| 79 | * the appropriate interrupt handler. |
| 80 | */ |
| 81 | while (pld) { |
| 82 | i = ffz(~pld); |
| 83 | pld &= pld - 1; /* clear least bit set */ |
| 84 | if (i == 7) |
Al Viro | 7ca56053 | 2006-10-08 14:36:08 +0100 | [diff] [blame] | 85 | isa_device_interrupt(vector); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | else |
Al Viro | 3dbb8c6 | 2006-10-08 14:37:32 +0100 | [diff] [blame] | 87 | handle_irq(16+i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | } |
| 89 | } |
| 90 | |
| 91 | void __init |
| 92 | init_pyxis_irqs(unsigned long ignore_mask) |
| 93 | { |
| 94 | long i; |
| 95 | |
| 96 | *(vulp)PYXIS_INT_MASK = 0; /* disable all */ |
| 97 | *(vulp)PYXIS_INT_REQ = -1; /* flush all */ |
| 98 | mb(); |
| 99 | |
| 100 | /* Send -INTA pulses to clear any pending interrupts ...*/ |
| 101 | *(vuip) CIA_IACK_SC; |
| 102 | |
| 103 | for (i = 16; i < 48; ++i) { |
| 104 | if ((ignore_mask >> i) & 1) |
| 105 | continue; |
Thomas Gleixner | a9eb076 | 2011-03-25 22:17:31 +0100 | [diff] [blame] | 106 | irq_set_chip_and_handler(i, &pyxis_irq_type, handle_level_irq); |
Thomas Gleixner | 592924c | 2011-02-06 14:32:23 +0000 | [diff] [blame] | 107 | irq_set_status_flags(i, IRQ_LEVEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | } |
| 109 | |
afzal mohammed | 82c849e | 2020-03-27 21:39:01 +0530 | [diff] [blame] | 110 | if (request_irq(16 + 7, no_action, 0, "isa-cascade", NULL)) |
| 111 | pr_err("Failed to register isa-cascade interrupt\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | } |