1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * linux/arch/alpha/kernel/irq_pyxis.c 41da177e4SLinus Torvalds * 51da177e4SLinus Torvalds * Based on code written by David A Rusling (david.rusling@reo.mts.dec.com). 61da177e4SLinus Torvalds * 71da177e4SLinus Torvalds * IRQ Code common to all PYXIS core logic chips. 81da177e4SLinus Torvalds */ 91da177e4SLinus Torvalds 101da177e4SLinus Torvalds #include <linux/init.h> 111da177e4SLinus Torvalds #include <linux/sched.h> 121da177e4SLinus Torvalds #include <linux/irq.h> 131da177e4SLinus Torvalds 141da177e4SLinus Torvalds #include <asm/io.h> 151da177e4SLinus Torvalds #include <asm/core_cia.h> 161da177e4SLinus Torvalds 171da177e4SLinus Torvalds #include "proto.h" 181da177e4SLinus Torvalds #include "irq_impl.h" 191da177e4SLinus Torvalds 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds /* Note mask bit is true for ENABLED irqs. */ 221da177e4SLinus Torvalds static unsigned long cached_irq_mask; 231da177e4SLinus Torvalds 241da177e4SLinus Torvalds static inline void 251da177e4SLinus Torvalds pyxis_update_irq_hw(unsigned long mask) 261da177e4SLinus Torvalds { 271da177e4SLinus Torvalds *(vulp)PYXIS_INT_MASK = mask; 281da177e4SLinus Torvalds mb(); 291da177e4SLinus Torvalds *(vulp)PYXIS_INT_MASK; 301da177e4SLinus Torvalds } 311da177e4SLinus Torvalds 321da177e4SLinus Torvalds static inline void 33592924c7SThomas Gleixner pyxis_enable_irq(struct irq_data *d) 341da177e4SLinus Torvalds { 35592924c7SThomas Gleixner pyxis_update_irq_hw(cached_irq_mask |= 1UL << (d->irq - 16)); 361da177e4SLinus Torvalds } 371da177e4SLinus Torvalds 381da177e4SLinus Torvalds static void 39592924c7SThomas Gleixner pyxis_disable_irq(struct irq_data *d) 401da177e4SLinus Torvalds { 41592924c7SThomas Gleixner pyxis_update_irq_hw(cached_irq_mask &= ~(1UL << (d->irq - 16))); 421da177e4SLinus Torvalds } 431da177e4SLinus Torvalds 441da177e4SLinus Torvalds static void 45592924c7SThomas Gleixner pyxis_mask_and_ack_irq(struct irq_data *d) 461da177e4SLinus Torvalds { 47592924c7SThomas Gleixner unsigned long bit = 1UL << (d->irq - 16); 481da177e4SLinus Torvalds unsigned long mask = cached_irq_mask &= ~bit; 491da177e4SLinus Torvalds 501da177e4SLinus Torvalds /* Disable the interrupt. */ 511da177e4SLinus Torvalds *(vulp)PYXIS_INT_MASK = mask; 521da177e4SLinus Torvalds wmb(); 531da177e4SLinus Torvalds /* Ack PYXIS PCI interrupt. */ 541da177e4SLinus Torvalds *(vulp)PYXIS_INT_REQ = bit; 551da177e4SLinus Torvalds mb(); 561da177e4SLinus Torvalds /* Re-read to force both writes. */ 571da177e4SLinus Torvalds *(vulp)PYXIS_INT_MASK; 581da177e4SLinus Torvalds } 591da177e4SLinus Torvalds 6044377f62SThomas Gleixner static struct irq_chip pyxis_irq_type = { 618ab1221cSThomas Gleixner .name = "PYXIS", 62592924c7SThomas Gleixner .irq_mask_ack = pyxis_mask_and_ack_irq, 63592924c7SThomas Gleixner .irq_mask = pyxis_disable_irq, 64592924c7SThomas Gleixner .irq_unmask = pyxis_enable_irq, 651da177e4SLinus Torvalds }; 661da177e4SLinus Torvalds 671da177e4SLinus Torvalds void 687ca56053SAl Viro pyxis_device_interrupt(unsigned long vector) 691da177e4SLinus Torvalds { 701da177e4SLinus Torvalds unsigned long pld; 711da177e4SLinus Torvalds unsigned int i; 721da177e4SLinus Torvalds 731da177e4SLinus Torvalds /* Read the interrupt summary register of PYXIS */ 741da177e4SLinus Torvalds pld = *(vulp)PYXIS_INT_REQ; 751da177e4SLinus Torvalds pld &= cached_irq_mask; 761da177e4SLinus Torvalds 771da177e4SLinus Torvalds /* 781da177e4SLinus Torvalds * Now for every possible bit set, work through them and call 791da177e4SLinus Torvalds * the appropriate interrupt handler. 801da177e4SLinus Torvalds */ 811da177e4SLinus Torvalds while (pld) { 821da177e4SLinus Torvalds i = ffz(~pld); 831da177e4SLinus Torvalds pld &= pld - 1; /* clear least bit set */ 841da177e4SLinus Torvalds if (i == 7) 857ca56053SAl Viro isa_device_interrupt(vector); 861da177e4SLinus Torvalds else 873dbb8c62SAl Viro handle_irq(16+i); 881da177e4SLinus Torvalds } 891da177e4SLinus Torvalds } 901da177e4SLinus Torvalds 911da177e4SLinus Torvalds void __init 921da177e4SLinus Torvalds init_pyxis_irqs(unsigned long ignore_mask) 931da177e4SLinus Torvalds { 941da177e4SLinus Torvalds long i; 951da177e4SLinus Torvalds 961da177e4SLinus Torvalds *(vulp)PYXIS_INT_MASK = 0; /* disable all */ 971da177e4SLinus Torvalds *(vulp)PYXIS_INT_REQ = -1; /* flush all */ 981da177e4SLinus Torvalds mb(); 991da177e4SLinus Torvalds 1001da177e4SLinus Torvalds /* Send -INTA pulses to clear any pending interrupts ...*/ 1011da177e4SLinus Torvalds *(vuip) CIA_IACK_SC; 1021da177e4SLinus Torvalds 1031da177e4SLinus Torvalds for (i = 16; i < 48; ++i) { 1041da177e4SLinus Torvalds if ((ignore_mask >> i) & 1) 1051da177e4SLinus Torvalds continue; 106a9eb076bSThomas Gleixner irq_set_chip_and_handler(i, &pyxis_irq_type, handle_level_irq); 107592924c7SThomas Gleixner irq_set_status_flags(i, IRQ_LEVEL); 1081da177e4SLinus Torvalds } 1091da177e4SLinus Torvalds 110*82c849ebSafzal mohammed if (request_irq(16 + 7, no_action, 0, "isa-cascade", NULL)) 111*82c849ebSafzal mohammed pr_err("Failed to register isa-cascade interrupt\n"); 1121da177e4SLinus Torvalds } 113