irq_markeins.c 3.8 KB

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