irq.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (C) 2000 RidgeRun, Inc.
  3. * Author: RidgeRun, Inc.
  4. * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
  5. *
  6. * Copyright 2001 MontaVista Software Inc.
  7. * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
  8. * Copyright (C) 2000, 2001 Ralf Baechle (ralf@gnu.org)
  9. *
  10. * Copyright 2004 PMC-Sierra
  11. * Author: Manish Lachwani (lachwani@pmc-sierra.com)
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License as published by the
  15. * Free Software Foundation; either version 2 of the License, or (at your
  16. * option) any later version.
  17. *
  18. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  19. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  20. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  21. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  22. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  23. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  24. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  25. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  27. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * You should have received a copy of the GNU General Public License along
  30. * with this program; if not, write to the Free Software Foundation, Inc.,
  31. * 675 Mass Ave, Cambridge, MA 02139, USA.
  32. *
  33. * Copyright (C) 2004 MontaVista Software Inc.
  34. * Author: Manish Lachwani, mlachwani@mvista.com
  35. *
  36. */
  37. #include <linux/errno.h>
  38. #include <linux/init.h>
  39. #include <linux/kernel_stat.h>
  40. #include <linux/module.h>
  41. #include <linux/signal.h>
  42. #include <linux/sched.h>
  43. #include <linux/types.h>
  44. #include <linux/interrupt.h>
  45. #include <linux/ioport.h>
  46. #include <linux/timex.h>
  47. #include <linux/slab.h>
  48. #include <linux/random.h>
  49. #include <asm/bitops.h>
  50. #include <asm/bootinfo.h>
  51. #include <asm/io.h>
  52. #include <asm/irq.h>
  53. #include <asm/mipsregs.h>
  54. #include <asm/system.h>
  55. static struct irqaction cascade_mv64340 = {
  56. no_action, IRQF_DISABLED, CPU_MASK_NONE, "MV64340-Cascade", NULL, NULL
  57. };
  58. void __init arch_init_irq(void)
  59. {
  60. /*
  61. * Clear all of the interrupts while we change the able around a bit.
  62. * int-handler is not on bootstrap
  63. */
  64. clear_c0_status(ST0_IM | ST0_BEV);
  65. rm7k_cpu_irq_init(8);
  66. /* set up the cascading interrupts */
  67. setup_irq(8, &cascade_mv64340); /* unmask intControl IM8, IRQ 9 */
  68. mv64340_irq_init(16);
  69. set_c0_status(ST0_IM); /* IE in the status register */
  70. }
  71. asmlinkage void plat_irq_dispatch(void)
  72. {
  73. unsigned int pending = read_c0_cause() & read_c0_status();
  74. if (pending & STATUSF_IP0)
  75. do_IRQ(0);
  76. else if (pending & STATUSF_IP1)
  77. do_IRQ(1);
  78. else if (pending & STATUSF_IP2)
  79. do_IRQ(2);
  80. else if (pending & STATUSF_IP3)
  81. do_IRQ(3);
  82. else if (pending & STATUSF_IP4)
  83. do_IRQ(4);
  84. else if (pending & STATUSF_IP5)
  85. do_IRQ(5);
  86. else if (pending & STATUSF_IP6)
  87. do_IRQ(6);
  88. else if (pending & STATUSF_IP7)
  89. do_IRQ(7);
  90. else {
  91. /*
  92. * Now look at the extended interrupts
  93. */
  94. pending = (read_c0_cause() & (read_c0_intcontrol() << 8)) >> 16;
  95. if (pending & STATUSF_IP8)
  96. ll_mv64340_irq();
  97. else
  98. spurious_interrupt();
  99. }
  100. }