bast-irq.c 3.7 KB

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