Path: blob/master/arch/mips/pmc-sierra/msp71xx/msp_irq_per.c
15118 views
/*1* Copyright 2010 PMC-Sierra, Inc, derived from irq_cpu.c2*3* This file define the irq handler for MSP PER subsystem interrupts.4*5* This program is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License as published by the7* Free Software Foundation; either version 2 of the License, or (at your8* option) any later version.9*/1011#include <linux/init.h>12#include <linux/interrupt.h>13#include <linux/kernel.h>14#include <linux/spinlock.h>15#include <linux/bitops.h>1617#include <asm/mipsregs.h>18#include <asm/system.h>1920#include <msp_cic_int.h>21#include <msp_regs.h>222324/*25* Convenience Macro. Should be somewhere generic.26*/27#define get_current_vpe() \28((read_c0_tcbind() >> TCBIND_CURVPE_SHIFT) & TCBIND_CURVPE)2930#ifdef CONFIG_SMP31/*32* The PER registers must be protected from concurrent access.33*/3435static DEFINE_SPINLOCK(per_lock);36#endif3738/* ensure writes to per are completed */3940static inline void per_wmb(void)41{42const volatile void __iomem *per_mem = PER_INT_MSK_REG;43volatile u32 dummy_read;4445wmb();46dummy_read = __raw_readl(per_mem);47dummy_read++;48}4950static inline void unmask_per_irq(struct irq_data *d)51{52#ifdef CONFIG_SMP53unsigned long flags;54spin_lock_irqsave(&per_lock, flags);55*PER_INT_MSK_REG |= (1 << (d->irq - MSP_PER_INTBASE));56spin_unlock_irqrestore(&per_lock, flags);57#else58*PER_INT_MSK_REG |= (1 << (d->irq - MSP_PER_INTBASE));59#endif60per_wmb();61}6263static inline void mask_per_irq(struct irq_data *d)64{65#ifdef CONFIG_SMP66unsigned long flags;67spin_lock_irqsave(&per_lock, flags);68*PER_INT_MSK_REG &= ~(1 << (d->irq - MSP_PER_INTBASE));69spin_unlock_irqrestore(&per_lock, flags);70#else71*PER_INT_MSK_REG &= ~(1 << (d->irq - MSP_PER_INTBASE));72#endif73per_wmb();74}7576static inline void msp_per_irq_ack(struct irq_data *d)77{78mask_per_irq(d);79/*80* In the PER interrupt controller, only bits 11 and 1081* are write-to-clear, (SPI TX complete, SPI RX complete).82* It does nothing for any others.83*/84*PER_INT_STS_REG = (1 << (d->irq - MSP_PER_INTBASE));85}8687#ifdef CONFIG_SMP88static int msp_per_irq_set_affinity(struct irq_data *d,89const struct cpumask *affinity, bool force)90{91/* WTF is this doing ????? */92unmask_per_irq(d);93return 0;94}95#endif9697static struct irq_chip msp_per_irq_controller = {98.name = "MSP_PER",99.irq_enable = unmask_per_irq,100.irq_disable = mask_per_irq,101.irq_ack = msp_per_irq_ack,102#ifdef CONFIG_SMP103.irq_set_affinity = msp_per_irq_set_affinity,104#endif105};106107void __init msp_per_irq_init(void)108{109int i;110/* Mask/clear interrupts. */111*PER_INT_MSK_REG = 0x00000000;112*PER_INT_STS_REG = 0xFFFFFFFF;113/* initialize all the IRQ descriptors */114for (i = MSP_PER_INTBASE; i < MSP_PER_INTBASE + 32; i++) {115irq_set_chip(i, &msp_per_irq_controller);116#ifdef CONFIG_MIPS_MT_SMTC117irq_hwmask[i] = C_IRQ4;118#endif119}120}121122void msp_per_irq_dispatch(void)123{124u32 per_mask = *PER_INT_MSK_REG;125u32 per_status = *PER_INT_STS_REG;126u32 pending;127128pending = per_status & per_mask;129if (pending) {130do_IRQ(ffs(pending) + MSP_PER_INTBASE - 1);131} else {132spurious_interrupt();133}134}135136137