bast-irq.c 3.4 KB

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