malta_int.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:4k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * Carsten Langgaard, carstenl@mips.com
  3.  * Copyright (C) 2000, 2001 MIPS Technologies, Inc.
  4.  * Copyright (C) 2001 Ralf Baechle
  5.  *
  6.  *  This program is free software; you can distribute it and/or modify it
  7.  *  under the terms of the GNU General Public License (Version 2) as
  8.  *  published by the Free Software Foundation.
  9.  *
  10.  *  This program is distributed in the hope it will be useful, but WITHOUT
  11.  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12.  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13.  *  for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License along
  16.  *  with this program; if not, write to the Free Software Foundation, Inc.,
  17.  *  59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  18.  *
  19.  * Routines for generic manipulation of the interrupts found on the MIPS
  20.  * Malta board.
  21.  * The interrupt controller is located in the South Bridge a PIIX4 device
  22.  * with two internal 82C95 interrupt controllers.
  23.  */
  24. #include <linux/config.h>
  25. #include <linux/init.h>
  26. #include <linux/sched.h>
  27. #include <linux/slab.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/kernel_stat.h>
  30. #include <linux/random.h>
  31. #include <asm/irq.h>
  32. #include <asm/io.h>
  33. #include <asm/mips-boards/malta.h>
  34. #include <asm/mips-boards/maltaint.h>
  35. #include <asm/mips-boards/piix4.h>
  36. #include <asm/gt64120.h>
  37. #include <asm/mips-boards/generic.h>
  38. #include <asm/mips-boards/msc01_pci.h>
  39. extern asmlinkage void mipsIRQ(void);
  40. extern asmlinkage void do_IRQ(int irq, struct pt_regs *regs);
  41. extern void init_i8259_irqs (void);
  42. extern int mips_pcibios_iack(void);
  43. static spinlock_t mips_irq_lock = SPIN_LOCK_UNLOCKED;
  44. static inline int get_int(int *irq)
  45. {
  46. unsigned long flags;
  47. spin_lock_irqsave(&mips_irq_lock, flags);
  48. *irq = mips_pcibios_iack();
  49. /*
  50.  * IRQ7 is used to detect spurious interrupts.
  51.  * The interrupt acknowledge cycle returns IRQ7, if no
  52.  * interrupts is requested.
  53.  * We can differentiate between this situation and a
  54.  * "Normal" IRQ7 by reading the ISR.
  55.  */
  56. if (*irq == 7)
  57. {
  58. outb(PIIX4_OCW3_SEL | PIIX4_OCW3_ISR,
  59.      PIIX4_ICTLR1_OCW3);
  60. if (!(inb(PIIX4_ICTLR1_OCW3) & (1 << 7))) {
  61. spin_unlock_irqrestore(&mips_irq_lock, flags);
  62. printk("We got a spurious interrupt from PIIX4.n");
  63. atomic_inc(&irq_err_count);
  64. return -1;    /* Spurious interrupt. */
  65. }
  66. }
  67. spin_unlock_irqrestore(&mips_irq_lock, flags);
  68. return 0;
  69. }
  70. void malta_hw0_irqdispatch(struct pt_regs *regs)
  71. {
  72. int irq;
  73. if (get_int(&irq))
  74.         return;  /* interrupt has already been cleared */
  75. do_IRQ(irq, regs);
  76. }
  77. void corehi_irqdispatch(struct pt_regs *regs)
  78. {
  79.         unsigned int data,datahi;
  80.         printk("CoreHI interrupt, shouldn't happen, so we die here!!!n");
  81.         printk("epc   : %08lxnStatus: %08lxnCause : %08lxnbadVaddr : %08lxn"
  82. , regs->cp0_epc, regs->cp0_status, regs->cp0_cause, regs->cp0_badvaddr);
  83.         switch(mips_revision_corid) {
  84.         case MIPS_REVISION_CORID_CORE_MSC:
  85.                 break;
  86.         case MIPS_REVISION_CORID_QED_RM5261:
  87.         case MIPS_REVISION_CORID_CORE_LV:
  88.         case MIPS_REVISION_CORID_CORE_FPGA:
  89.                 GT_READ(GT_INTRCAUSE_OFS, data);
  90.                 printk("GT_INTRCAUSE = %08xn", data);
  91.                 GT_READ(0x70, data);
  92.                 GT_READ(0x78, datahi);
  93.                 printk("GT_CPU_ERR_ADDR = %0x2%08xn", datahi,data);
  94.                 break;
  95.         case MIPS_REVISION_CORID_BONITO64:
  96.         case MIPS_REVISION_CORID_CORE_20K:
  97.                 data = BONITO_INTISR;
  98.                 printk("BONITO_INTISR = %08xn", data);
  99.                 data = BONITO_INTEN;
  100.                 printk("BONITO_INTEN = %08xn", data);
  101.                 data = BONITO_INTPOL;
  102.                 printk("BONITO_INTPOL = %08xn", data);
  103.                 data = BONITO_INTEDGE;
  104.                 printk("BONITO_INTEDGE = %08xn", data);
  105.                 data = BONITO_INTSTEER;
  106.                 printk("BONITO_INTSTEER = %08xn", data);
  107.                 data = BONITO_PCICMD;
  108.                 printk("BONITO_PCICMD = %08xn", data);
  109.                 break;
  110.         }
  111.         /* We die here*/
  112.         die("CoreHi interrupt", regs);
  113.         while (1) ;
  114. }
  115. void __init init_IRQ(void)
  116. {
  117. set_except_vector(0, mipsIRQ);
  118. init_generic_irq();
  119. init_i8259_irqs();
  120. #ifdef CONFIG_REMOTE_DEBUG
  121. if (remote_debug) {
  122. set_debug_traps();
  123. breakpoint();
  124. }
  125. #endif
  126. }