irq_markeins.c 3.9 KB

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