irqmap.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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/init.h>
  26. #include <linux/interrupt.h>
  27. #include <asm/mach-au1x00/au1000.h>
  28. #ifdef CONFIG_MIPS_PB1200
  29. #include <asm/mach-pb1x00/pb1200.h>
  30. #endif
  31. #ifdef CONFIG_MIPS_DB1200
  32. #include <asm/mach-db1x00/db1200.h>
  33. #define PB1200_INT_BEGIN DB1200_INT_BEGIN
  34. #define PB1200_INT_END DB1200_INT_END
  35. #endif
  36. struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
  37. /* This is external interrupt cascade */
  38. { AU1000_GPIO_7, IRQF_TRIGGER_LOW, 0 },
  39. };
  40. /*
  41. * Support for External interrupts on the Pb1200 Development platform.
  42. */
  43. static void pb1200_cascade_handler(unsigned int irq, struct irq_desc *d)
  44. {
  45. unsigned short bisr = bcsr->int_status;
  46. for ( ; bisr; bisr &= bisr - 1)
  47. generic_handle_irq(PB1200_INT_BEGIN + __ffs(bisr));
  48. }
  49. /* NOTE: both the enable and mask bits must be cleared, otherwise the
  50. * CPLD generates tons of spurious interrupts (at least on the DB1200).
  51. */
  52. static void pb1200_mask_irq(unsigned int irq_nr)
  53. {
  54. bcsr->intclr_mask = 1 << (irq_nr - PB1200_INT_BEGIN);
  55. bcsr->intclr = 1 << (irq_nr - PB1200_INT_BEGIN);
  56. au_sync();
  57. }
  58. static void pb1200_maskack_irq(unsigned int irq_nr)
  59. {
  60. bcsr->intclr_mask = 1 << (irq_nr - PB1200_INT_BEGIN);
  61. bcsr->intclr = 1 << (irq_nr - PB1200_INT_BEGIN);
  62. bcsr->int_status = 1 << (irq_nr - PB1200_INT_BEGIN); /* ack */
  63. au_sync();
  64. }
  65. static void pb1200_unmask_irq(unsigned int irq_nr)
  66. {
  67. bcsr->intset = 1 << (irq_nr - PB1200_INT_BEGIN);
  68. bcsr->intset_mask = 1 << (irq_nr - PB1200_INT_BEGIN);
  69. au_sync();
  70. }
  71. static struct irq_chip pb1200_cpld_irq_type = {
  72. #ifdef CONFIG_MIPS_PB1200
  73. .name = "Pb1200 Ext",
  74. #endif
  75. #ifdef CONFIG_MIPS_DB1200
  76. .name = "Db1200 Ext",
  77. #endif
  78. .mask = pb1200_mask_irq,
  79. .mask_ack = pb1200_maskack_irq,
  80. .unmask = pb1200_unmask_irq,
  81. };
  82. void __init board_init_irq(void)
  83. {
  84. unsigned int irq;
  85. au1xxx_setup_irqmap(au1xxx_irq_map, ARRAY_SIZE(au1xxx_irq_map));
  86. #ifdef CONFIG_MIPS_PB1200
  87. /* We have a problem with CPLD rev 3. */
  88. if (((bcsr->whoami & BCSR_WHOAMI_CPLD) >> 4) <= 3) {
  89. printk(KERN_ERR "WARNING!!!\n");
  90. printk(KERN_ERR "WARNING!!!\n");
  91. printk(KERN_ERR "WARNING!!!\n");
  92. printk(KERN_ERR "WARNING!!!\n");
  93. printk(KERN_ERR "WARNING!!!\n");
  94. printk(KERN_ERR "WARNING!!!\n");
  95. printk(KERN_ERR "Pb1200 must be at CPLD rev 4. Please have Pb1200\n");
  96. printk(KERN_ERR "updated to latest revision. This software will\n");
  97. printk(KERN_ERR "not work on anything less than CPLD rev 4.\n");
  98. printk(KERN_ERR "WARNING!!!\n");
  99. printk(KERN_ERR "WARNING!!!\n");
  100. printk(KERN_ERR "WARNING!!!\n");
  101. printk(KERN_ERR "WARNING!!!\n");
  102. printk(KERN_ERR "WARNING!!!\n");
  103. printk(KERN_ERR "WARNING!!!\n");
  104. panic("Game over. Your score is 0.");
  105. }
  106. #endif
  107. /* mask & disable & ack all */
  108. bcsr->intclr_mask = 0xffff;
  109. bcsr->intclr = 0xffff;
  110. bcsr->int_status = 0xffff;
  111. au_sync();
  112. for (irq = PB1200_INT_BEGIN; irq <= PB1200_INT_END; irq++)
  113. set_irq_chip_and_handler_name(irq, &pb1200_cpld_irq_type,
  114. handle_level_irq, "level");
  115. set_irq_chained_handler(AU1000_GPIO_7, pb1200_cascade_handler);
  116. }