📄 ip32-irq.c
字号:
/* * Code to handle IP32 IRQs * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 2000 Harald Koerfgen * Copyright (C) 2001 Keith M Wesolowski */#include <linux/init.h>#include <linux/kernel_stat.h>#include <linux/types.h>#include <linux/interrupt.h>#include <linux/irq.h>#include <linux/bitops.h>#include <linux/kernel.h>#include <linux/slab.h>#include <linux/mm.h>#include <linux/random.h>#include <linux/sched.h>#include <asm/mipsregs.h>#include <asm/signal.h>#include <asm/system.h>#include <asm/time.h>#include <asm/ip32/crime.h>#include <asm/ip32/mace.h>#include <asm/ip32/ip32_ints.h>/* issue a PIO read to make sure no PIO writes are pending */static void inline flush_crime_bus(void){ crime->control;}static void inline flush_mace_bus(void){ mace->perif.ctrl.misc;}#undef DEBUG_IRQ#ifdef DEBUG_IRQ#define DBG(x...) printk(x)#else#define DBG(x...)#endif/* O2 irq map * * IP0 -> software (ignored) * IP1 -> software (ignored) * IP2 -> (irq0) C crime 1.1 all interrupts; crime 1.5 ??? * IP3 -> (irq1) X unknown * IP4 -> (irq2) X unknown * IP5 -> (irq3) X unknown * IP6 -> (irq4) X unknown * IP7 -> (irq5) 0 CPU count/compare timer (system timer) * * crime: (C) * * CRIME_INT_STAT 31:0: * * 0 -> 1 Video in 1 * 1 -> 2 Video in 2 * 2 -> 3 Video out * 3 -> 4 Mace ethernet * 4 -> S SuperIO sub-interrupt * 5 -> M Miscellaneous sub-interrupt * 6 -> A Audio sub-interrupt * 7 -> 8 PCI bridge errors * 8 -> 9 PCI SCSI aic7xxx 0 * 9 -> 10 PCI SCSI aic7xxx 1 * 10 -> 11 PCI slot 0 * 11 -> 12 unused (PCI slot 1) * 12 -> 13 unused (PCI slot 2) * 13 -> 14 unused (PCI shared 0) * 14 -> 15 unused (PCI shared 1) * 15 -> 16 unused (PCI shared 2) * 16 -> 17 GBE0 (E) * 17 -> 18 GBE1 (E) * 18 -> 19 GBE2 (E) * 19 -> 20 GBE3 (E) * 20 -> 21 CPU errors * 21 -> 22 Memory errors * 22 -> 23 RE empty edge (E) * 23 -> 24 RE full edge (E) * 24 -> 25 RE idle edge (E) * 25 -> 26 RE empty level * 26 -> 27 RE full level * 27 -> 28 RE idle level * 28 -> 29 unused (software 0) (E) * 29 -> 30 unused (software 1) (E) * 30 -> 31 unused (software 2) - crime 1.5 CPU SysCorError (E) * 31 -> 32 VICE * * S, M, A: Use the MACE ISA interrupt register * MACE_ISA_INT_STAT 31:0 * * 0-7 -> 33-40 Audio * 8 -> 41 RTC * 9 -> 42 Keyboard * 10 -> X Keyboard polled * 11 -> 44 Mouse * 12 -> X Mouse polled * 13-15 -> 46-48 Count/compare timers * 16-19 -> 49-52 Parallel (16 E) * 20-25 -> 53-58 Serial 1 (22 E) * 26-31 -> 59-64 Serial 2 (28 E) * * Note that this means IRQs 5-7, 43, and 45 do not exist. This is a * different IRQ map than IRIX uses, but that's OK as Linux irq handling * is quite different anyway. *//* * IRQ spinlock - Ralf says not to disable CPU interrupts, * and I think he knows better. */static DEFINE_SPINLOCK(ip32_irq_lock);/* Some initial interrupts to set up */extern irqreturn_t crime_memerr_intr (int irq, void *dev_id, struct pt_regs *regs);extern irqreturn_t crime_cpuerr_intr (int irq, void *dev_id, struct pt_regs *regs);struct irqaction memerr_irq = { crime_memerr_intr, SA_INTERRUPT, CPU_MASK_NONE, "CRIME memory error", NULL, NULL };struct irqaction cpuerr_irq = { crime_cpuerr_intr, SA_INTERRUPT, CPU_MASK_NONE, "CRIME CPU error", NULL, NULL };/* * For interrupts wired from a single device to the CPU. Only the clock * uses this it seems, which is IRQ 0 and IP7. */static void enable_cpu_irq(unsigned int irq){ set_c0_status(STATUSF_IP7);}static unsigned int startup_cpu_irq(unsigned int irq){ enable_cpu_irq(irq); return 0;}static void disable_cpu_irq(unsigned int irq){ clear_c0_status(STATUSF_IP7);}static void end_cpu_irq(unsigned int irq){ if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) enable_cpu_irq (irq);}#define shutdown_cpu_irq disable_cpu_irq#define mask_and_ack_cpu_irq disable_cpu_irqstatic struct hw_interrupt_type ip32_cpu_interrupt = { .typename = "IP32 CPU", .startup = startup_cpu_irq, .shutdown = shutdown_cpu_irq, .enable = enable_cpu_irq, .disable = disable_cpu_irq, .ack = mask_and_ack_cpu_irq, .end = end_cpu_irq,};/* * This is for pure CRIME interrupts - ie not MACE. The advantage? * We get to split the register in half and do faster lookups. */static uint64_t crime_mask;static void enable_crime_irq(unsigned int irq){ unsigned long flags; spin_lock_irqsave(&ip32_irq_lock, flags); crime_mask |= 1 << (irq - 1); crime->imask = crime_mask; spin_unlock_irqrestore(&ip32_irq_lock, flags);}static unsigned int startup_crime_irq(unsigned int irq){ enable_crime_irq(irq); return 0; /* This is probably not right; we could have pending irqs */}static void disable_crime_irq(unsigned int irq){ unsigned long flags; spin_lock_irqsave(&ip32_irq_lock, flags); crime_mask &= ~(1 << (irq - 1)); crime->imask = crime_mask; flush_crime_bus(); spin_unlock_irqrestore(&ip32_irq_lock, flags);}static void mask_and_ack_crime_irq(unsigned int irq){ unsigned long flags; /* Edge triggered interrupts must be cleared. */ if ((irq >= CRIME_GBE0_IRQ && irq <= CRIME_GBE3_IRQ) || (irq >= CRIME_RE_EMPTY_E_IRQ && irq <= CRIME_RE_IDLE_E_IRQ) || (irq >= CRIME_SOFT0_IRQ && irq <= CRIME_SOFT2_IRQ)) { uint64_t crime_int; spin_lock_irqsave(&ip32_irq_lock, flags); crime_int = crime->hard_int; crime_int &= ~(1 << (irq - 1)); crime->hard_int = crime_int; spin_unlock_irqrestore(&ip32_irq_lock, flags); } disable_crime_irq(irq);}static void end_crime_irq(unsigned int irq){ if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) enable_crime_irq(irq);}#define shutdown_crime_irq disable_crime_irqstatic struct hw_interrupt_type ip32_crime_interrupt = { .typename = "IP32 CRIME", .startup = startup_crime_irq, .shutdown = shutdown_crime_irq, .enable = enable_crime_irq, .disable = disable_crime_irq, .ack = mask_and_ack_crime_irq, .end = end_crime_irq,};/* * This is for MACE PCI interrupts. We can decrease bus traffic by masking * as close to the source as possible. This also means we can take the * next chunk of the CRIME register in one piece. */static unsigned long macepci_mask;static void enable_macepci_irq(unsigned int irq){ unsigned long flags; spin_lock_irqsave(&ip32_irq_lock, flags); macepci_mask |= MACEPCI_CONTROL_INT(irq - 9); mace->pci.control = macepci_mask; crime_mask |= 1 << (irq - 1); crime->imask = crime_mask; spin_unlock_irqrestore(&ip32_irq_lock, flags);}static unsigned int startup_macepci_irq(unsigned int irq){ enable_macepci_irq (irq); return 0;}static void disable_macepci_irq(unsigned int irq){ unsigned long flags; spin_lock_irqsave(&ip32_irq_lock, flags); crime_mask &= ~(1 << (irq - 1)); crime->imask = crime_mask; flush_crime_bus(); macepci_mask &= ~MACEPCI_CONTROL_INT(irq - 9); mace->pci.control = macepci_mask; flush_mace_bus(); spin_unlock_irqrestore(&ip32_irq_lock, flags);}static void end_macepci_irq(unsigned int irq){ if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) enable_macepci_irq(irq);}#define shutdown_macepci_irq disable_macepci_irq#define mask_and_ack_macepci_irq disable_macepci_irqstatic struct hw_interrupt_type ip32_macepci_interrupt = { .typename = "IP32 MACE PCI", .startup = startup_macepci_irq, .shutdown = shutdown_macepci_irq, .enable = enable_macepci_irq, .disable = disable_macepci_irq, .ack = mask_and_ack_macepci_irq, .end = end_macepci_irq,};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -