irq_emma2rh.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * arch/mips/emma2rh/common/irq_emma2rh.c
  3. * This file defines the irq handler for EMMA2RH.
  4. *
  5. * Copyright (C) NEC Electronics Corporation 2005-2006
  6. *
  7. * This file is based on the arch/mips/ddb5xxx/ddb5477/irq_5477.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. /*
  26. * EMMA2RH defines 64 IRQs.
  27. *
  28. * This file exports one function:
  29. * emma2rh_irq_init(u32 irq_base);
  30. */
  31. #include <linux/interrupt.h>
  32. #include <linux/types.h>
  33. #include <linux/ptrace.h>
  34. #include <asm/debug.h>
  35. #include <asm/emma2rh/emma2rh.h>
  36. /* number of total irqs supported by EMMA2RH */
  37. #define NUM_EMMA2RH_IRQ 96
  38. static int emma2rh_irq_base = -1;
  39. void ll_emma2rh_irq_enable(int);
  40. void ll_emma2rh_irq_disable(int);
  41. static void emma2rh_irq_enable(unsigned int irq)
  42. {
  43. ll_emma2rh_irq_enable(irq - emma2rh_irq_base);
  44. }
  45. static void emma2rh_irq_disable(unsigned int irq)
  46. {
  47. ll_emma2rh_irq_disable(irq - emma2rh_irq_base);
  48. }
  49. static unsigned int emma2rh_irq_startup(unsigned int irq)
  50. {
  51. emma2rh_irq_enable(irq);
  52. return 0;
  53. }
  54. #define emma2rh_irq_shutdown emma2rh_irq_disable
  55. static void emma2rh_irq_ack(unsigned int irq)
  56. {
  57. /* disable interrupt - some handler will re-enable the irq
  58. * and if the interrupt is leveled, we will have infinite loop
  59. */
  60. ll_emma2rh_irq_disable(irq - emma2rh_irq_base);
  61. }
  62. static void emma2rh_irq_end(unsigned int irq)
  63. {
  64. if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
  65. ll_emma2rh_irq_enable(irq - emma2rh_irq_base);
  66. }
  67. struct irq_chip emma2rh_irq_controller = {
  68. .typename = "emma2rh_irq",
  69. .startup = emma2rh_irq_startup,
  70. .shutdown = emma2rh_irq_shutdown,
  71. .enable = emma2rh_irq_enable,
  72. .disable = emma2rh_irq_disable,
  73. .ack = emma2rh_irq_ack,
  74. .end = emma2rh_irq_end,
  75. .set_affinity = NULL /* no affinity stuff for UP */
  76. };
  77. void emma2rh_irq_init(u32 irq_base)
  78. {
  79. u32 i;
  80. for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ; i++) {
  81. irq_desc[i].status = IRQ_DISABLED;
  82. irq_desc[i].action = NULL;
  83. irq_desc[i].depth = 1;
  84. irq_desc[i].handler = &emma2rh_irq_controller;
  85. }
  86. emma2rh_irq_base = irq_base;
  87. }
  88. void ll_emma2rh_irq_enable(int emma2rh_irq)
  89. {
  90. u32 reg_value;
  91. u32 reg_bitmask;
  92. u32 reg_index;
  93. reg_index = EMMA2RH_BHIF_INT_EN_0
  94. + (EMMA2RH_BHIF_INT_EN_1 - EMMA2RH_BHIF_INT_EN_0)
  95. * (emma2rh_irq / 32);
  96. reg_value = emma2rh_in32(reg_index);
  97. reg_bitmask = 0x1 << (emma2rh_irq % 32);
  98. db_assert((reg_value & reg_bitmask) == 0);
  99. emma2rh_out32(reg_index, reg_value | reg_bitmask);
  100. }
  101. void ll_emma2rh_irq_disable(int emma2rh_irq)
  102. {
  103. u32 reg_value;
  104. u32 reg_bitmask;
  105. u32 reg_index;
  106. reg_index = EMMA2RH_BHIF_INT_EN_0
  107. + (EMMA2RH_BHIF_INT_EN_1 - EMMA2RH_BHIF_INT_EN_0)
  108. * (emma2rh_irq / 32);
  109. reg_value = emma2rh_in32(reg_index);
  110. reg_bitmask = 0x1 << (emma2rh_irq % 32);
  111. db_assert((reg_value & reg_bitmask) != 0);
  112. emma2rh_out32(reg_index, reg_value & ~reg_bitmask);
  113. }