/* * BRIEF MODULE DESCRIPTION * Au1000 interrupt routines. * * Copyright 2001 MontaVista Software Inc. * Author: MontaVista Software, Inc. * ppopov@mvista.com or source@mvista.com * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined(CONFIG_MIPS_PB1000) #include #elif defined(CONFIG_MIPS_PB1500) #include #else #error unsupported alchemy board #endif #undef DEBUG_IRQ #ifdef DEBUG_IRQ /* note: prints function name for you */ #define DPRINTK(fmt, args...) printk("%s: " fmt, __FUNCTION__ , ## args) #else #define DPRINTK(fmt, args...) #endif #define EXT_INTC0_REQ0 2 /* IP 2 */ #define EXT_INTC0_REQ1 3 /* IP 3 */ #define EXT_INTC1_REQ0 4 /* IP 4 */ #define EXT_INTC1_REQ1 5 /* IP 5 */ #define MIPS_TIMER_IP 7 /* IP 7 */ #ifdef CONFIG_REMOTE_DEBUG extern void breakpoint(void); #endif extern asmlinkage void au1000_IRQ(void); extern void set_debug_traps(void); extern irq_cpustat_t irq_stat [NR_CPUS]; unsigned int local_bh_count[NR_CPUS]; unsigned int local_irq_count[NR_CPUS]; static void setup_local_irq(unsigned int irq, int type, int int_req); static unsigned int startup_irq(unsigned int irq); static void end_irq(unsigned int irq_nr); static inline void mask_and_ack_level_irq(unsigned int irq_nr); static inline void mask_and_ack_rise_edge_irq(unsigned int irq_nr); static inline void mask_and_ack_fall_edge_irq(unsigned int irq_nr); inline void local_enable_irq(unsigned int irq_nr); inline void local_disable_irq(unsigned int irq_nr); extern unsigned int do_IRQ(int irq, struct pt_regs *regs); extern void __init init_generic_irq(void); #ifdef CONFIG_PM extern void counter0_irq(int irq, void *dev_id, struct pt_regs *regs); #endif static void setup_local_irq(unsigned int irq_nr, int type, int int_req) { if (irq_nr > AU1000_MAX_INTR) return; /* Config2[n], Config1[n], Config0[n] */ if (irq_nr > AU1000_LAST_INTC0_INT) { switch (type) { case INTC_INT_RISE_EDGE: /* 0:0:1 */ outl(1<<(irq_nr-32), IC1_CFG2CLR); outl(1<<(irq_nr-32), IC1_CFG1CLR); outl(1<<(irq_nr-32), IC1_CFG0SET); break; case INTC_INT_FALL_EDGE: /* 0:1:0 */ outl(1<<(irq_nr-32), IC1_CFG2CLR); outl(1<<(irq_nr-32), IC1_CFG1SET); outl(1<<(irq_nr-32), IC1_CFG0CLR); break; case INTC_INT_HIGH_LEVEL: /* 1:0:1 */ outl(1<<(irq_nr-32), IC1_CFG2SET); outl(1<<(irq_nr-32), IC1_CFG1CLR); outl(1<<(irq_nr-32), IC1_CFG0SET); break; case INTC_INT_LOW_LEVEL: /* 1:1:0 */ outl(1<<(irq_nr-32), IC1_CFG2SET); outl(1<<(irq_nr-32), IC1_CFG1SET); outl(1<<(irq_nr-32), IC1_CFG0CLR); break; case INTC_INT_DISABLED: /* 0:0:0 */ outl(1<<(irq_nr-32), IC1_CFG0CLR); outl(1<<(irq_nr-32), IC1_CFG1CLR); outl(1<<(irq_nr-32), IC1_CFG2CLR); break; default: /* disable the interrupt */ printk("unexpected int type %d (irq %d)\n", type, irq_nr); outl(1<<(irq_nr-32), IC1_CFG0CLR); outl(1<<(irq_nr-32), IC1_CFG1CLR); outl(1<<(irq_nr-32), IC1_CFG2CLR); return; } if (int_req) /* assign to interrupt request 1 */ outl(1<<(irq_nr-32), IC1_ASSIGNCLR); else /* assign to interrupt request 0 */ outl(1<<(irq_nr-32), IC1_ASSIGNSET); outl(1<<(irq_nr-32), IC1_SRCSET); outl(1<<(irq_nr-32), IC1_MASKCLR); outl(1<<(irq_nr-32), IC1_WAKECLR); } else { switch (type) { case INTC_INT_RISE_EDGE: /* 0:0:1 */ outl(1< AU1000_LAST_INTC0_INT) { outl(1<<(irq_nr-32), IC1_MASKSET); outl(1<<(irq_nr-32), IC1_WAKESET); } else { outl(1< AU1000_LAST_INTC0_INT) { outl(1<<(irq_nr-32), IC1_MASKCLR); outl(1<<(irq_nr-32), IC1_WAKECLR); } else { outl(1< AU1000_LAST_INTC0_INT) { outl(1<<(irq_nr-32), IC1_RISINGCLR); outl(1<<(irq_nr-32), IC1_MASKCLR); } else { outl(1< AU1000_LAST_INTC0_INT) { outl(1<<(irq_nr-32), IC1_FALLINGCLR); outl(1<<(irq_nr-32), IC1_MASKCLR); } else { outl(1<