irq.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * arch/mips/emma2rh/common/irq.c
  3. * This file is common irq dispatcher.
  4. *
  5. * Copyright (C) NEC Electronics Corporation 2005-2006
  6. *
  7. * This file is based on the arch/mips/ddb5xxx/ddb5477/irq.c
  8. *
  9. * Copyright 2001 MontaVista Software Inc.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <linux/init.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/irq.h>
  28. #include <linux/types.h>
  29. #include <asm/system.h>
  30. #include <asm/mipsregs.h>
  31. #include <asm/debug.h>
  32. #include <asm/addrspace.h>
  33. #include <asm/bootinfo.h>
  34. #include <asm/emma2rh/emma2rh.h>
  35. /*
  36. * the first level int-handler will jump here if it is a emma2rh irq
  37. */
  38. void emma2rh_irq_dispatch(void)
  39. {
  40. u32 intStatus;
  41. u32 bitmask;
  42. u32 i;
  43. intStatus = emma2rh_in32(EMMA2RH_BHIF_INT_ST_0)
  44. & emma2rh_in32(EMMA2RH_BHIF_INT_EN_0);
  45. #ifdef EMMA2RH_SW_CASCADE
  46. if (intStatus &
  47. (1 << ((EMMA2RH_SW_CASCADE - EMMA2RH_IRQ_INT0) & (32 - 1)))) {
  48. u32 swIntStatus;
  49. swIntStatus = emma2rh_in32(EMMA2RH_BHIF_SW_INT)
  50. & emma2rh_in32(EMMA2RH_BHIF_SW_INT_EN);
  51. for (i = 0, bitmask = 1; i < 32; i++, bitmask <<= 1) {
  52. if (swIntStatus & bitmask) {
  53. do_IRQ(EMMA2RH_SW_IRQ_BASE + i);
  54. return;
  55. }
  56. }
  57. }
  58. #endif
  59. for (i = 0, bitmask = 1; i < 32; i++, bitmask <<= 1) {
  60. if (intStatus & bitmask) {
  61. do_IRQ(EMMA2RH_IRQ_BASE + i);
  62. return;
  63. }
  64. }
  65. intStatus = emma2rh_in32(EMMA2RH_BHIF_INT_ST_1)
  66. & emma2rh_in32(EMMA2RH_BHIF_INT_EN_1);
  67. #ifdef EMMA2RH_GPIO_CASCADE
  68. if (intStatus &
  69. (1 << ((EMMA2RH_GPIO_CASCADE - EMMA2RH_IRQ_INT0) & (32 - 1)))) {
  70. u32 gpioIntStatus;
  71. gpioIntStatus = emma2rh_in32(EMMA2RH_GPIO_INT_ST)
  72. & emma2rh_in32(EMMA2RH_GPIO_INT_MASK);
  73. for (i = 0, bitmask = 1; i < 32; i++, bitmask <<= 1) {
  74. if (gpioIntStatus & bitmask) {
  75. do_IRQ(EMMA2RH_GPIO_IRQ_BASE + i);
  76. return;
  77. }
  78. }
  79. }
  80. #endif
  81. for (i = 32, bitmask = 1; i < 64; i++, bitmask <<= 1) {
  82. if (intStatus & bitmask) {
  83. do_IRQ(EMMA2RH_IRQ_BASE + i);
  84. return;
  85. }
  86. }
  87. intStatus = emma2rh_in32(EMMA2RH_BHIF_INT_ST_2)
  88. & emma2rh_in32(EMMA2RH_BHIF_INT_EN_2);
  89. for (i = 64, bitmask = 1; i < 96; i++, bitmask <<= 1) {
  90. if (intStatus & bitmask) {
  91. do_IRQ(EMMA2RH_IRQ_BASE + i);
  92. return;
  93. }
  94. }
  95. }