bast-irq.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* linux/arch/arm/mach-s3c2410/bast-irq.c
  2. *
  3. * Copyright 2003-2005 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * http://www.simtec.co.uk/products/EB2410ITX/
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/init.h>
  23. #include <linux/module.h>
  24. #include <linux/ioport.h>
  25. #include <linux/device.h>
  26. #include <linux/io.h>
  27. #include <asm/mach-types.h>
  28. #include <mach/hardware.h>
  29. #include <asm/irq.h>
  30. #include <asm/mach/irq.h>
  31. #include <mach/regs-irq.h>
  32. #include <mach/bast-map.h>
  33. #include <mach/bast-irq.h>
  34. #include <plat/irq.h>
  35. #if 0
  36. #include <asm/debug-ll.h>
  37. #endif
  38. #define irqdbf(x...)
  39. #define irqdbf2(x...)
  40. /* handle PC104 ISA interrupts from the system CPLD */
  41. /* table of ISA irq nos to the relevant mask... zero means
  42. * the irq is not implemented
  43. */
  44. static unsigned char bast_pc104_irqmasks[] = {
  45. 0, /* 0 */
  46. 0, /* 1 */
  47. 0, /* 2 */
  48. 1, /* 3 */
  49. 0, /* 4 */
  50. 2, /* 5 */
  51. 0, /* 6 */
  52. 4, /* 7 */
  53. 0, /* 8 */
  54. 0, /* 9 */
  55. 8, /* 10 */
  56. 0, /* 11 */
  57. 0, /* 12 */
  58. 0, /* 13 */
  59. 0, /* 14 */
  60. 0, /* 15 */
  61. };
  62. static unsigned char bast_pc104_irqs[] = { 3, 5, 7, 10 };
  63. static void
  64. bast_pc104_mask(struct irq_data *data)
  65. {
  66. unsigned long temp;
  67. temp = __raw_readb(BAST_VA_PC104_IRQMASK);
  68. temp &= ~bast_pc104_irqmasks[data->irq];
  69. __raw_writeb(temp, BAST_VA_PC104_IRQMASK);
  70. }
  71. static void
  72. bast_pc104_maskack(struct irq_data *data)
  73. {
  74. struct irq_desc *desc = irq_desc + IRQ_ISA;
  75. bast_pc104_mask(data);
  76. desc->irq_data.chip->irq_ack(&desc->irq_data);
  77. }
  78. static void
  79. bast_pc104_unmask(struct irq_data *data)
  80. {
  81. unsigned long temp;
  82. temp = __raw_readb(BAST_VA_PC104_IRQMASK);
  83. temp |= bast_pc104_irqmasks[data->irq];
  84. __raw_writeb(temp, BAST_VA_PC104_IRQMASK);
  85. }
  86. static struct irq_chip bast_pc104_chip = {
  87. .irq_mask = bast_pc104_mask,
  88. .irq_unmask = bast_pc104_unmask,
  89. .irq_ack = bast_pc104_maskack
  90. };
  91. static void
  92. bast_irq_pc104_demux(unsigned int irq,
  93. struct irq_desc *desc)
  94. {
  95. unsigned int stat;
  96. unsigned int irqno;
  97. int i;
  98. stat = __raw_readb(BAST_VA_PC104_IRQREQ) & 0xf;
  99. if (unlikely(stat == 0)) {
  100. /* ack if we get an irq with nothing (ie, startup) */
  101. desc = irq_desc + IRQ_ISA;
  102. desc->irq_data.chip->irq_ack(&desc->irq_data);
  103. } else {
  104. /* handle the IRQ */
  105. for (i = 0; stat != 0; i++, stat >>= 1) {
  106. if (stat & 1) {
  107. irqno = bast_pc104_irqs[i];
  108. generic_handle_irq(irqno);
  109. }
  110. }
  111. }
  112. }
  113. static __init int bast_irq_init(void)
  114. {
  115. unsigned int i;
  116. if (machine_is_bast()) {
  117. printk(KERN_INFO "BAST PC104 IRQ routing, Copyright 2005 Simtec Electronics\n");
  118. /* zap all the IRQs */
  119. __raw_writeb(0x0, BAST_VA_PC104_IRQMASK);
  120. irq_set_chained_handler(IRQ_ISA, bast_irq_pc104_demux);
  121. /* register our IRQs */
  122. for (i = 0; i < 4; i++) {
  123. unsigned int irqno = bast_pc104_irqs[i];
  124. irq_set_chip_and_handler(irqno, &bast_pc104_chip,
  125. handle_level_irq);
  126. set_irq_flags(irqno, IRQF_VALID);
  127. }
  128. }
  129. return 0;
  130. }
  131. arch_initcall(bast_irq_init);