bast-irq.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /* linux/arch/arm/mach-s3c2410/bast-irq.c
  2. *
  3. * Copyright (c) 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/ptrace.h>
  26. #include <linux/sysdev.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/hardware.h>
  29. #include <asm/irq.h>
  30. #include <asm/io.h>
  31. #include <asm/mach/irq.h>
  32. #include <asm/arch/regs-irq.h>
  33. #include <asm/arch/bast-map.h>
  34. #include <asm/arch/bast-irq.h>
  35. #include <asm/plat-s3c24xx/irq.h>
  36. #if 0
  37. #include <asm/debug-ll.h>
  38. #endif
  39. #define irqdbf(x...)
  40. #define irqdbf2(x...)
  41. /* handle PC104 ISA interrupts from the system CPLD */
  42. /* table of ISA irq nos to the relevant mask... zero means
  43. * the irq is not implemented
  44. */
  45. static unsigned char bast_pc104_irqmasks[] = {
  46. 0, /* 0 */
  47. 0, /* 1 */
  48. 0, /* 2 */
  49. 1, /* 3 */
  50. 0, /* 4 */
  51. 2, /* 5 */
  52. 0, /* 6 */
  53. 4, /* 7 */
  54. 0, /* 8 */
  55. 0, /* 9 */
  56. 8, /* 10 */
  57. 0, /* 11 */
  58. 0, /* 12 */
  59. 0, /* 13 */
  60. 0, /* 14 */
  61. 0, /* 15 */
  62. };
  63. static unsigned char bast_pc104_irqs[] = { 3, 5, 7, 10 };
  64. static void
  65. bast_pc104_mask(unsigned int irqno)
  66. {
  67. unsigned long temp;
  68. temp = __raw_readb(BAST_VA_PC104_IRQMASK);
  69. temp &= ~bast_pc104_irqmasks[irqno];
  70. __raw_writeb(temp, BAST_VA_PC104_IRQMASK);
  71. }
  72. static void
  73. bast_pc104_maskack(unsigned int irqno)
  74. {
  75. struct irq_desc *desc = irq_desc + IRQ_ISA;
  76. bast_pc104_mask(irqno);
  77. desc->chip->ack(IRQ_ISA);
  78. }
  79. static void
  80. bast_pc104_unmask(unsigned int irqno)
  81. {
  82. unsigned long temp;
  83. temp = __raw_readb(BAST_VA_PC104_IRQMASK);
  84. temp |= bast_pc104_irqmasks[irqno];
  85. __raw_writeb(temp, BAST_VA_PC104_IRQMASK);
  86. }
  87. static struct irq_chip bast_pc104_chip = {
  88. .mask = bast_pc104_mask,
  89. .unmask = bast_pc104_unmask,
  90. .ack = bast_pc104_maskack
  91. };
  92. static void
  93. bast_irq_pc104_demux(unsigned int irq,
  94. struct irq_desc *desc)
  95. {
  96. unsigned int stat;
  97. unsigned int irqno;
  98. int i;
  99. stat = __raw_readb(BAST_VA_PC104_IRQREQ) & 0xf;
  100. if (unlikely(stat == 0)) {
  101. /* ack if we get an irq with nothing (ie, startup) */
  102. desc = irq_desc + IRQ_ISA;
  103. desc->chip->ack(IRQ_ISA);
  104. } else {
  105. /* handle the IRQ */
  106. for (i = 0; stat != 0; i++, stat >>= 1) {
  107. if (stat & 1) {
  108. irqno = bast_pc104_irqs[i];
  109. desc = irq_desc + irqno;
  110. desc_handle_irq(irqno, desc);
  111. }
  112. }
  113. }
  114. }
  115. static __init int bast_irq_init(void)
  116. {
  117. unsigned int i;
  118. if (machine_is_bast()) {
  119. printk(KERN_INFO "BAST PC104 IRQ routing, (c) 2005 Simtec Electronics\n");
  120. /* zap all the IRQs */
  121. __raw_writeb(0x0, BAST_VA_PC104_IRQMASK);
  122. set_irq_chained_handler(IRQ_ISA, bast_irq_pc104_demux);
  123. /* register our IRQs */
  124. for (i = 0; i < 4; i++) {
  125. unsigned int irqno = bast_pc104_irqs[i];
  126. set_irq_chip(irqno, &bast_pc104_chip);
  127. set_irq_handler(irqno, handle_level_irq);
  128. set_irq_flags(irqno, IRQF_VALID);
  129. }
  130. }
  131. return 0;
  132. }
  133. arch_initcall(bast_irq_init);