irq_markeins.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * arch/mips/emma2rh/markeins/irq_markeins.c
  3. * This file defines the irq handler for Mark-eins.
  4. *
  5. * Copyright (C) NEC Electronics Corporation 2004-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. #include <linux/interrupt.h>
  26. #include <linux/irq.h>
  27. #include <linux/types.h>
  28. #include <linux/ptrace.h>
  29. #include <asm/debug.h>
  30. #include <asm/emma2rh/emma2rh.h>
  31. static int emma2rh_sw_irq_base = -1;
  32. static int emma2rh_gpio_irq_base = -1;
  33. void ll_emma2rh_sw_irq_enable(int reg);
  34. void ll_emma2rh_sw_irq_disable(int reg);
  35. void ll_emma2rh_gpio_irq_enable(int reg);
  36. void ll_emma2rh_gpio_irq_disable(int reg);
  37. static void emma2rh_sw_irq_enable(unsigned int irq)
  38. {
  39. ll_emma2rh_sw_irq_enable(irq - emma2rh_sw_irq_base);
  40. }
  41. static void emma2rh_sw_irq_disable(unsigned int irq)
  42. {
  43. ll_emma2rh_sw_irq_disable(irq - emma2rh_sw_irq_base);
  44. }
  45. static unsigned int emma2rh_sw_irq_startup(unsigned int irq)
  46. {
  47. emma2rh_sw_irq_enable(irq);
  48. return 0;
  49. }
  50. #define emma2rh_sw_irq_shutdown emma2rh_sw_irq_disable
  51. static void emma2rh_sw_irq_ack(unsigned int irq)
  52. {
  53. ll_emma2rh_sw_irq_disable(irq - emma2rh_sw_irq_base);
  54. }
  55. static void emma2rh_sw_irq_end(unsigned int irq)
  56. {
  57. if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
  58. ll_emma2rh_sw_irq_enable(irq - emma2rh_sw_irq_base);
  59. }
  60. struct irq_chip emma2rh_sw_irq_controller = {
  61. .typename = "emma2rh_sw_irq",
  62. .startup = emma2rh_sw_irq_startup,
  63. .shutdown = emma2rh_sw_irq_shutdown,
  64. .enable = emma2rh_sw_irq_enable,
  65. .disable = emma2rh_sw_irq_disable,
  66. .ack = emma2rh_sw_irq_ack,
  67. .end = emma2rh_sw_irq_end,
  68. .set_affinity = NULL,
  69. };
  70. void emma2rh_sw_irq_init(u32 irq_base)
  71. {
  72. u32 i;
  73. for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ_SW; i++) {
  74. irq_desc[i].status = IRQ_DISABLED;
  75. irq_desc[i].action = NULL;
  76. irq_desc[i].depth = 2;
  77. irq_desc[i].handler = &emma2rh_sw_irq_controller;
  78. }
  79. emma2rh_sw_irq_base = irq_base;
  80. }
  81. void ll_emma2rh_sw_irq_enable(int irq)
  82. {
  83. u32 reg;
  84. db_assert(irq >= 0);
  85. db_assert(irq < NUM_EMMA2RH_IRQ_SW);
  86. reg = emma2rh_in32(EMMA2RH_BHIF_SW_INT_EN);
  87. reg |= 1 << irq;
  88. emma2rh_out32(EMMA2RH_BHIF_SW_INT_EN, reg);
  89. }
  90. void ll_emma2rh_sw_irq_disable(int irq)
  91. {
  92. u32 reg;
  93. db_assert(irq >= 0);
  94. db_assert(irq < 32);
  95. reg = emma2rh_in32(EMMA2RH_BHIF_SW_INT_EN);
  96. reg &= ~(1 << irq);
  97. emma2rh_out32(EMMA2RH_BHIF_SW_INT_EN, reg);
  98. }
  99. static void emma2rh_gpio_irq_enable(unsigned int irq)
  100. {
  101. ll_emma2rh_gpio_irq_enable(irq - emma2rh_gpio_irq_base);
  102. }
  103. static void emma2rh_gpio_irq_disable(unsigned int irq)
  104. {
  105. ll_emma2rh_gpio_irq_disable(irq - emma2rh_gpio_irq_base);
  106. }
  107. static unsigned int emma2rh_gpio_irq_startup(unsigned int irq)
  108. {
  109. emma2rh_gpio_irq_enable(irq);
  110. return 0;
  111. }
  112. #define emma2rh_gpio_irq_shutdown emma2rh_gpio_irq_disable
  113. static void emma2rh_gpio_irq_ack(unsigned int irq)
  114. {
  115. irq -= emma2rh_gpio_irq_base;
  116. emma2rh_out32(EMMA2RH_GPIO_INT_ST, ~(1 << irq));
  117. ll_emma2rh_gpio_irq_disable(irq);
  118. }
  119. static void emma2rh_gpio_irq_end(unsigned int irq)
  120. {
  121. if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
  122. ll_emma2rh_gpio_irq_enable(irq - emma2rh_gpio_irq_base);
  123. }
  124. struct irq_chip emma2rh_gpio_irq_controller = {
  125. .typename = "emma2rh_gpio_irq",
  126. .startup = emma2rh_gpio_irq_startup,
  127. .shutdown = emma2rh_gpio_irq_shutdown,
  128. .enable = emma2rh_gpio_irq_enable,
  129. .disable = emma2rh_gpio_irq_disable,
  130. .ack = emma2rh_gpio_irq_ack,
  131. .end = emma2rh_gpio_irq_end,
  132. .set_affinity = NULL,
  133. };
  134. void emma2rh_gpio_irq_init(u32 irq_base)
  135. {
  136. u32 i;
  137. for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ_GPIO; i++) {
  138. irq_desc[i].status = IRQ_DISABLED;
  139. irq_desc[i].action = NULL;
  140. irq_desc[i].depth = 2;
  141. irq_desc[i].handler = &emma2rh_gpio_irq_controller;
  142. }
  143. emma2rh_gpio_irq_base = irq_base;
  144. }
  145. void ll_emma2rh_gpio_irq_enable(int irq)
  146. {
  147. u32 reg;
  148. db_assert(irq >= 0);
  149. db_assert(irq < NUM_EMMA2RH_IRQ_GPIO);
  150. reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK);
  151. reg |= 1 << irq;
  152. emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg);
  153. }
  154. void ll_emma2rh_gpio_irq_disable(int irq)
  155. {
  156. u32 reg;
  157. db_assert(irq >= 0);
  158. db_assert(irq < NUM_EMMA2RH_IRQ_GPIO);
  159. reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK);
  160. reg &= ~(1 << irq);
  161. emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg);
  162. }