bast-irq.c 3.5 KB

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