excite_irq.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Copyright (C) by Basler Vision Technologies AG
  3. * Author: Thomas Koeller <thomas.koeller@baslereb.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/errno.h>
  20. #include <linux/init.h>
  21. #include <linux/kernel_stat.h>
  22. #include <linux/module.h>
  23. #include <linux/signal.h>
  24. #include <linux/sched.h>
  25. #include <linux/types.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/ioport.h>
  28. #include <linux/timex.h>
  29. #include <linux/slab.h>
  30. #include <linux/random.h>
  31. #include <asm/bitops.h>
  32. #include <asm/bootinfo.h>
  33. #include <asm/io.h>
  34. #include <asm/irq.h>
  35. #include <asm/irq_cpu.h>
  36. #include <asm/mipsregs.h>
  37. #include <asm/system.h>
  38. #include <asm/rm9k-ocd.h>
  39. #include <excite.h>
  40. extern asmlinkage void excite_handle_int(void);
  41. /*
  42. * Initialize the interrupt handler
  43. */
  44. void __init arch_init_irq(void)
  45. {
  46. mips_cpu_irq_init();
  47. rm7k_cpu_irq_init();
  48. rm9k_cpu_irq_init();
  49. #ifdef CONFIG_KGDB
  50. excite_kgdb_init();
  51. #endif
  52. }
  53. asmlinkage void plat_irq_dispatch(void)
  54. {
  55. const u32
  56. interrupts = read_c0_cause() >> 8,
  57. mask = ((read_c0_status() >> 8) & 0x000000ff) |
  58. (read_c0_intcontrol() & 0x0000ff00),
  59. pending = interrupts & mask;
  60. u32 msgintflags, msgintmask, msgint;
  61. /* process timer interrupt */
  62. if (pending & (1 << TIMER_IRQ)) {
  63. do_IRQ(TIMER_IRQ);
  64. return;
  65. }
  66. /* Process PCI interrupts */
  67. #if USB_IRQ < 10
  68. msgintflags = ocd_readl(INTP0Status0 + (USB_MSGINT / 0x20 * 0x10));
  69. msgintmask = ocd_readl(INTP0Mask0 + (USB_MSGINT / 0x20 * 0x10));
  70. msgint = msgintflags & msgintmask & (0x1 << (USB_MSGINT % 0x20));
  71. if ((pending & (1 << USB_IRQ)) && msgint) {
  72. #else
  73. if (pending & (1 << USB_IRQ)) {
  74. #endif
  75. do_IRQ(USB_IRQ);
  76. return;
  77. }
  78. /* Process TITAN interrupts */
  79. msgintflags = ocd_readl(INTP0Status0 + (TITAN_MSGINT / 0x20 * 0x10));
  80. msgintmask = ocd_readl(INTP0Mask0 + (TITAN_MSGINT / 0x20 * 0x10));
  81. msgint = msgintflags & msgintmask & (0x1 << (TITAN_MSGINT % 0x20));
  82. if ((pending & (1 << TITAN_IRQ)) && msgint) {
  83. ocd_writel(msgint, INTP0Clear0 + (TITAN_MSGINT / 0x20 * 0x10));
  84. #if defined(CONFIG_KGDB)
  85. excite_kgdb_inthdl();
  86. #endif
  87. do_IRQ(TITAN_IRQ);
  88. return;
  89. }
  90. /* Process FPGA line #0 interrupts */
  91. msgintflags = ocd_readl(INTP0Status0 + (FPGA0_MSGINT / 0x20 * 0x10));
  92. msgintmask = ocd_readl(INTP0Mask0 + (FPGA0_MSGINT / 0x20 * 0x10));
  93. msgint = msgintflags & msgintmask & (0x1 << (FPGA0_MSGINT % 0x20));
  94. if ((pending & (1 << FPGA0_IRQ)) && msgint) {
  95. do_IRQ(FPGA0_IRQ);
  96. return;
  97. }
  98. /* Process FPGA line #1 interrupts */
  99. msgintflags = ocd_readl(INTP0Status0 + (FPGA1_MSGINT / 0x20 * 0x10));
  100. msgintmask = ocd_readl(INTP0Mask0 + (FPGA1_MSGINT / 0x20 * 0x10));
  101. msgint = msgintflags & msgintmask & (0x1 << (FPGA1_MSGINT % 0x20));
  102. if ((pending & (1 << FPGA1_IRQ)) && msgint) {
  103. do_IRQ(FPGA1_IRQ);
  104. return;
  105. }
  106. /* Process PHY interrupts */
  107. msgintflags = ocd_readl(INTP0Status0 + (PHY_MSGINT / 0x20 * 0x10));
  108. msgintmask = ocd_readl(INTP0Mask0 + (PHY_MSGINT / 0x20 * 0x10));
  109. msgint = msgintflags & msgintmask & (0x1 << (PHY_MSGINT % 0x20));
  110. if ((pending & (1 << PHY_IRQ)) && msgint) {
  111. do_IRQ(PHY_IRQ);
  112. return;
  113. }
  114. /* Process spurious interrupts */
  115. spurious_interrupt();
  116. }