irqmap.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * BRIEF MODULE DESCRIPTION
  3. * Au1xxx irq map table
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. *
  10. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  11. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  12. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  13. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  14. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  15. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  16. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  17. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  18. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  19. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20. *
  21. * You should have received a copy of the GNU General Public License along
  22. * with this program; if not, write to the Free Software Foundation, Inc.,
  23. * 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. #include <linux/config.h>
  26. #include <linux/errno.h>
  27. #include <linux/init.h>
  28. #include <linux/irq.h>
  29. #include <linux/kernel_stat.h>
  30. #include <linux/module.h>
  31. #include <linux/signal.h>
  32. #include <linux/sched.h>
  33. #include <linux/types.h>
  34. #include <linux/interrupt.h>
  35. #include <linux/ioport.h>
  36. #include <linux/timex.h>
  37. #include <linux/slab.h>
  38. #include <linux/random.h>
  39. #include <linux/delay.h>
  40. #include <asm/bitops.h>
  41. #include <asm/bootinfo.h>
  42. #include <asm/io.h>
  43. #include <asm/mipsregs.h>
  44. #include <asm/system.h>
  45. #include <asm/mach-au1x00/au1000.h>
  46. #ifdef CONFIG_MIPS_PB1200
  47. #include <asm/mach-pb1x00/pb1200.h>
  48. #endif
  49. #ifdef CONFIG_MIPS_DB1200
  50. #include <asm/mach-db1x00/db1200.h>
  51. #define PB1200_INT_BEGIN DB1200_INT_BEGIN
  52. #define PB1200_INT_END DB1200_INT_END
  53. #endif
  54. au1xxx_irq_map_t au1xxx_irq_map[] = {
  55. { AU1000_GPIO_7, INTC_INT_LOW_LEVEL, 0 }, // This is exteranl interrupt cascade
  56. };
  57. int au1xxx_nr_irqs = sizeof(au1xxx_irq_map)/sizeof(au1xxx_irq_map_t);
  58. /*
  59. * Support for External interrupts on the PbAu1200 Development platform.
  60. */
  61. static volatile int pb1200_cascade_en=0;
  62. irqreturn_t pb1200_cascade_handler( int irq, void *dev_id, struct pt_regs *regs)
  63. {
  64. unsigned short bisr = bcsr->int_status;
  65. int extirq_nr = 0;
  66. /* Clear all the edge interrupts. This has no effect on level */
  67. bcsr->int_status = bisr;
  68. for( ; bisr; bisr &= (bisr-1) )
  69. {
  70. extirq_nr = (PB1200_INT_BEGIN-1) + au_ffs(bisr);
  71. /* Ack and dispatch IRQ */
  72. do_IRQ(extirq_nr,regs);
  73. }
  74. return IRQ_RETVAL(1);
  75. }
  76. inline void pb1200_enable_irq(unsigned int irq_nr)
  77. {
  78. bcsr->intset_mask = 1<<(irq_nr - PB1200_INT_BEGIN);
  79. bcsr->intset = 1<<(irq_nr - PB1200_INT_BEGIN);
  80. }
  81. inline void pb1200_disable_irq(unsigned int irq_nr)
  82. {
  83. bcsr->intclr_mask = 1<<(irq_nr - PB1200_INT_BEGIN);
  84. bcsr->intclr = 1<<(irq_nr - PB1200_INT_BEGIN);
  85. }
  86. static unsigned int pb1200_startup_irq( unsigned int irq_nr )
  87. {
  88. if (++pb1200_cascade_en == 1)
  89. {
  90. request_irq(AU1000_GPIO_7, &pb1200_cascade_handler,
  91. 0, "Pb1200 Cascade", (void *)&pb1200_cascade_handler );
  92. #ifdef CONFIG_MIPS_PB1200
  93. /* We have a problem with CPLD rev3. Enable a workaround */
  94. if( ((bcsr->whoami & BCSR_WHOAMI_CPLD)>>4) <= 3)
  95. {
  96. printk("\nWARNING!!!\n");
  97. printk("\nWARNING!!!\n");
  98. printk("\nWARNING!!!\n");
  99. printk("\nWARNING!!!\n");
  100. printk("\nWARNING!!!\n");
  101. printk("\nWARNING!!!\n");
  102. printk("Pb1200 must be at CPLD rev4. Please have Pb1200\n");
  103. printk("updated to latest revision. This software will not\n");
  104. printk("work on anything less than CPLD rev4\n");
  105. printk("\nWARNING!!!\n");
  106. printk("\nWARNING!!!\n");
  107. printk("\nWARNING!!!\n");
  108. printk("\nWARNING!!!\n");
  109. printk("\nWARNING!!!\n");
  110. printk("\nWARNING!!!\n");
  111. while(1);
  112. }
  113. #endif
  114. }
  115. pb1200_enable_irq(irq_nr);
  116. return 0;
  117. }
  118. static void pb1200_shutdown_irq( unsigned int irq_nr )
  119. {
  120. pb1200_disable_irq(irq_nr);
  121. if (--pb1200_cascade_en == 0)
  122. {
  123. free_irq(AU1000_GPIO_7,&pb1200_cascade_handler );
  124. }
  125. return;
  126. }
  127. static inline void pb1200_mask_and_ack_irq(unsigned int irq_nr)
  128. {
  129. pb1200_disable_irq( irq_nr );
  130. }
  131. static void pb1200_end_irq(unsigned int irq_nr)
  132. {
  133. if (!(irq_desc[irq_nr].status & (IRQ_DISABLED|IRQ_INPROGRESS))) {
  134. pb1200_enable_irq(irq_nr);
  135. }
  136. }
  137. static struct hw_interrupt_type external_irq_type =
  138. {
  139. #ifdef CONFIG_MIPS_PB1200
  140. "Pb1200 Ext",
  141. #endif
  142. #ifdef CONFIG_MIPS_DB1200
  143. "Db1200 Ext",
  144. #endif
  145. pb1200_startup_irq,
  146. pb1200_shutdown_irq,
  147. pb1200_enable_irq,
  148. pb1200_disable_irq,
  149. pb1200_mask_and_ack_irq,
  150. pb1200_end_irq,
  151. NULL
  152. };
  153. void _board_init_irq(void)
  154. {
  155. int irq_nr;
  156. for (irq_nr = PB1200_INT_BEGIN; irq_nr <= PB1200_INT_END; irq_nr++)
  157. {
  158. irq_desc[irq_nr].handler = &external_irq_type;
  159. pb1200_disable_irq(irq_nr);
  160. }
  161. /* GPIO_7 can not be hooked here, so it is hooked upon first
  162. request of any source attached to the cascade */
  163. }