irq_markeins.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 void emma2rh_sw_irq_end(unsigned int irq)
  46. {
  47. if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
  48. ll_emma2rh_sw_irq_enable(irq - emma2rh_sw_irq_base);
  49. }
  50. struct irq_chip emma2rh_sw_irq_controller = {
  51. .typename = "emma2rh_sw_irq",
  52. .ack = emma2rh_sw_irq_disable,
  53. .mask = emma2rh_sw_irq_disable,
  54. .mask_ack = emma2rh_sw_irq_disable,
  55. .unmask = emma2rh_sw_irq_enable,
  56. .end = emma2rh_sw_irq_end,
  57. };
  58. void emma2rh_sw_irq_init(u32 irq_base)
  59. {
  60. u32 i;
  61. for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ_SW; i++)
  62. set_irq_chip_and_handler(i, &emma2rh_sw_irq_controller,
  63. handle_level_irq);
  64. emma2rh_sw_irq_base = irq_base;
  65. }
  66. void ll_emma2rh_sw_irq_enable(int irq)
  67. {
  68. u32 reg;
  69. db_assert(irq >= 0);
  70. db_assert(irq < NUM_EMMA2RH_IRQ_SW);
  71. reg = emma2rh_in32(EMMA2RH_BHIF_SW_INT_EN);
  72. reg |= 1 << irq;
  73. emma2rh_out32(EMMA2RH_BHIF_SW_INT_EN, reg);
  74. }
  75. void ll_emma2rh_sw_irq_disable(int irq)
  76. {
  77. u32 reg;
  78. db_assert(irq >= 0);
  79. db_assert(irq < 32);
  80. reg = emma2rh_in32(EMMA2RH_BHIF_SW_INT_EN);
  81. reg &= ~(1 << irq);
  82. emma2rh_out32(EMMA2RH_BHIF_SW_INT_EN, reg);
  83. }
  84. static void emma2rh_gpio_irq_enable(unsigned int irq)
  85. {
  86. ll_emma2rh_gpio_irq_enable(irq - emma2rh_gpio_irq_base);
  87. }
  88. static void emma2rh_gpio_irq_disable(unsigned int irq)
  89. {
  90. ll_emma2rh_gpio_irq_disable(irq - emma2rh_gpio_irq_base);
  91. }
  92. static void emma2rh_gpio_irq_ack(unsigned int irq)
  93. {
  94. irq -= emma2rh_gpio_irq_base;
  95. emma2rh_out32(EMMA2RH_GPIO_INT_ST, ~(1 << irq));
  96. ll_emma2rh_gpio_irq_disable(irq);
  97. }
  98. static void emma2rh_gpio_irq_end(unsigned int irq)
  99. {
  100. if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
  101. ll_emma2rh_gpio_irq_enable(irq - emma2rh_gpio_irq_base);
  102. }
  103. struct irq_chip emma2rh_gpio_irq_controller = {
  104. .typename = "emma2rh_gpio_irq",
  105. .ack = emma2rh_gpio_irq_ack,
  106. .mask = emma2rh_gpio_irq_disable,
  107. .mask_ack = emma2rh_gpio_irq_ack,
  108. .unmask = emma2rh_gpio_irq_enable,
  109. .end = emma2rh_gpio_irq_end,
  110. };
  111. void emma2rh_gpio_irq_init(u32 irq_base)
  112. {
  113. u32 i;
  114. for (i = irq_base; i < irq_base + NUM_EMMA2RH_IRQ_GPIO; i++)
  115. set_irq_chip(i, &emma2rh_gpio_irq_controller);
  116. emma2rh_gpio_irq_base = irq_base;
  117. }
  118. void ll_emma2rh_gpio_irq_enable(int irq)
  119. {
  120. u32 reg;
  121. db_assert(irq >= 0);
  122. db_assert(irq < NUM_EMMA2RH_IRQ_GPIO);
  123. reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK);
  124. reg |= 1 << irq;
  125. emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg);
  126. }
  127. void ll_emma2rh_gpio_irq_disable(int irq)
  128. {
  129. u32 reg;
  130. db_assert(irq >= 0);
  131. db_assert(irq < NUM_EMMA2RH_IRQ_GPIO);
  132. reg = emma2rh_in32(EMMA2RH_GPIO_INT_MASK);
  133. reg &= ~(1 << irq);
  134. emma2rh_out32(EMMA2RH_GPIO_INT_MASK, reg);
  135. }