irq-msc01.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * Copyright (c) 2004 MIPS Inc
  3. * Author: chris@mips.com
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/kernel.h>
  13. #include <asm/ptrace.h>
  14. #include <linux/sched.h>
  15. #include <linux/kernel_stat.h>
  16. #include <asm/io.h>
  17. #include <asm/irq.h>
  18. #include <asm/msc01_ic.h>
  19. static unsigned long _icctrl_msc;
  20. #define MSC01_IC_REG_BASE _icctrl_msc
  21. #define MSCIC_WRITE(reg, data) do { *(volatile u32 *)(reg) = data; } while (0)
  22. #define MSCIC_READ(reg, data) do { data = *(volatile u32 *)(reg); } while (0)
  23. static unsigned int irq_base;
  24. /* mask off an interrupt */
  25. static inline void mask_msc_irq(unsigned int irq)
  26. {
  27. if (irq < (irq_base + 32))
  28. MSCIC_WRITE(MSC01_IC_DISL, 1<<(irq - irq_base));
  29. else
  30. MSCIC_WRITE(MSC01_IC_DISH, 1<<(irq - irq_base - 32));
  31. }
  32. /* unmask an interrupt */
  33. static inline void unmask_msc_irq(unsigned int irq)
  34. {
  35. if (irq < (irq_base + 32))
  36. MSCIC_WRITE(MSC01_IC_ENAL, 1<<(irq - irq_base));
  37. else
  38. MSCIC_WRITE(MSC01_IC_ENAH, 1<<(irq - irq_base - 32));
  39. }
  40. /*
  41. * Enables the IRQ on SOC-it
  42. */
  43. static void enable_msc_irq(unsigned int irq)
  44. {
  45. unmask_msc_irq(irq);
  46. }
  47. /*
  48. * Initialize the IRQ on SOC-it
  49. */
  50. static unsigned int startup_msc_irq(unsigned int irq)
  51. {
  52. unmask_msc_irq(irq);
  53. return 0;
  54. }
  55. /*
  56. * Disables the IRQ on SOC-it
  57. */
  58. static void disable_msc_irq(unsigned int irq)
  59. {
  60. mask_msc_irq(irq);
  61. }
  62. /*
  63. * Masks and ACKs an IRQ
  64. */
  65. static void level_mask_and_ack_msc_irq(unsigned int irq)
  66. {
  67. mask_msc_irq(irq);
  68. if (!cpu_has_ei)
  69. MSCIC_WRITE(MSC01_IC_EOI, 0);
  70. }
  71. /*
  72. * Masks and ACKs an IRQ
  73. */
  74. static void edge_mask_and_ack_msc_irq(unsigned int irq)
  75. {
  76. mask_msc_irq(irq);
  77. if (!cpu_has_ei)
  78. MSCIC_WRITE(MSC01_IC_EOI, 0);
  79. else {
  80. u32 r;
  81. MSCIC_READ(MSC01_IC_SUP+irq*8, r);
  82. MSCIC_WRITE(MSC01_IC_SUP+irq*8, r | ~MSC01_IC_SUP_EDGE_BIT);
  83. MSCIC_WRITE(MSC01_IC_SUP+irq*8, r);
  84. }
  85. }
  86. /*
  87. * End IRQ processing
  88. */
  89. static void end_msc_irq(unsigned int irq)
  90. {
  91. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  92. unmask_msc_irq(irq);
  93. }
  94. /*
  95. * Interrupt handler for interrupts coming from SOC-it.
  96. */
  97. void ll_msc_irq(struct pt_regs *regs)
  98. {
  99. unsigned int irq;
  100. /* read the interrupt vector register */
  101. MSCIC_READ(MSC01_IC_VEC, irq);
  102. if (irq < 64)
  103. do_IRQ(irq + irq_base, regs);
  104. else {
  105. /* Ignore spurious interrupt */
  106. }
  107. }
  108. void
  109. msc_bind_eic_interrupt (unsigned int irq, unsigned int set)
  110. {
  111. MSCIC_WRITE(MSC01_IC_RAMW,
  112. (irq<<MSC01_IC_RAMW_ADDR_SHF) | (set<<MSC01_IC_RAMW_DATA_SHF));
  113. }
  114. #define shutdown_msc_irq disable_msc_irq
  115. struct hw_interrupt_type msc_levelirq_type = {
  116. "SOC-it-Level",
  117. startup_msc_irq,
  118. shutdown_msc_irq,
  119. enable_msc_irq,
  120. disable_msc_irq,
  121. level_mask_and_ack_msc_irq,
  122. end_msc_irq,
  123. NULL
  124. };
  125. struct hw_interrupt_type msc_edgeirq_type = {
  126. "SOC-it-Edge",
  127. startup_msc_irq,
  128. shutdown_msc_irq,
  129. enable_msc_irq,
  130. disable_msc_irq,
  131. edge_mask_and_ack_msc_irq,
  132. end_msc_irq,
  133. NULL
  134. };
  135. void __init init_msc_irqs(unsigned int base, msc_irqmap_t *imp, int nirq)
  136. {
  137. extern void (*board_bind_eic_interrupt)(unsigned int irq, unsigned int regset);
  138. _icctrl_msc = (unsigned long) ioremap (MIPS_MSC01_IC_REG_BASE, 0x40000);
  139. /* Reset interrupt controller - initialises all registers to 0 */
  140. MSCIC_WRITE(MSC01_IC_RST, MSC01_IC_RST_RST_BIT);
  141. board_bind_eic_interrupt = &msc_bind_eic_interrupt;
  142. for (; nirq >= 0; nirq--, imp++) {
  143. int n = imp->im_irq;
  144. switch (imp->im_type) {
  145. case MSC01_IRQ_EDGE:
  146. irq_desc[base+n].handler = &msc_edgeirq_type;
  147. if (cpu_has_ei)
  148. MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT);
  149. else
  150. MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT | imp->im_lvl);
  151. break;
  152. case MSC01_IRQ_LEVEL:
  153. irq_desc[base+n].handler = &msc_levelirq_type;
  154. if (cpu_has_ei)
  155. MSCIC_WRITE(MSC01_IC_SUP+n*8, 0);
  156. else
  157. MSCIC_WRITE(MSC01_IC_SUP+n*8, imp->im_lvl);
  158. }
  159. }
  160. irq_base = base;
  161. MSCIC_WRITE(MSC01_IC_GENA, MSC01_IC_GENA_GENA_BIT); /* Enable interrupt generation */
  162. }