irq-msc01.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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_veic)
  69. MSCIC_WRITE(MSC01_IC_EOI, 0);
  70. #ifdef CONFIG_MIPS_MT_SMTC
  71. /* This actually needs to be a call into platform code */
  72. if (irq_hwmask[irq] & ST0_IM)
  73. set_c0_status(irq_hwmask[irq] & ST0_IM);
  74. #endif /* CONFIG_MIPS_MT_SMTC */
  75. }
  76. /*
  77. * Masks and ACKs an IRQ
  78. */
  79. static void edge_mask_and_ack_msc_irq(unsigned int irq)
  80. {
  81. mask_msc_irq(irq);
  82. if (!cpu_has_veic)
  83. MSCIC_WRITE(MSC01_IC_EOI, 0);
  84. else {
  85. u32 r;
  86. MSCIC_READ(MSC01_IC_SUP+irq*8, r);
  87. MSCIC_WRITE(MSC01_IC_SUP+irq*8, r | ~MSC01_IC_SUP_EDGE_BIT);
  88. MSCIC_WRITE(MSC01_IC_SUP+irq*8, r);
  89. }
  90. #ifdef CONFIG_MIPS_MT_SMTC
  91. if (irq_hwmask[irq] & ST0_IM)
  92. set_c0_status(irq_hwmask[irq] & ST0_IM);
  93. #endif /* CONFIG_MIPS_MT_SMTC */
  94. }
  95. /*
  96. * End IRQ processing
  97. */
  98. static void end_msc_irq(unsigned int irq)
  99. {
  100. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  101. unmask_msc_irq(irq);
  102. }
  103. /*
  104. * Interrupt handler for interrupts coming from SOC-it.
  105. */
  106. void ll_msc_irq(struct pt_regs *regs)
  107. {
  108. unsigned int irq;
  109. /* read the interrupt vector register */
  110. MSCIC_READ(MSC01_IC_VEC, irq);
  111. if (irq < 64)
  112. do_IRQ(irq + irq_base, regs);
  113. else {
  114. /* Ignore spurious interrupt */
  115. }
  116. }
  117. void
  118. msc_bind_eic_interrupt (unsigned int irq, unsigned int set)
  119. {
  120. MSCIC_WRITE(MSC01_IC_RAMW,
  121. (irq<<MSC01_IC_RAMW_ADDR_SHF) | (set<<MSC01_IC_RAMW_DATA_SHF));
  122. }
  123. #define shutdown_msc_irq disable_msc_irq
  124. struct hw_interrupt_type msc_levelirq_type = {
  125. .typename = "SOC-it-Level",
  126. .startup = startup_msc_irq,
  127. .shutdown = shutdown_msc_irq,
  128. .enable = enable_msc_irq,
  129. .disable = disable_msc_irq,
  130. .ack = level_mask_and_ack_msc_irq,
  131. .end = end_msc_irq,
  132. };
  133. struct hw_interrupt_type msc_edgeirq_type = {
  134. .typename = "SOC-it-Edge",
  135. .startup =startup_msc_irq,
  136. .shutdown = shutdown_msc_irq,
  137. .enable = enable_msc_irq,
  138. .disable = disable_msc_irq,
  139. .ack = edge_mask_and_ack_msc_irq,
  140. .end = end_msc_irq,
  141. };
  142. void __init init_msc_irqs(unsigned int base, msc_irqmap_t *imp, int nirq)
  143. {
  144. extern void (*board_bind_eic_interrupt)(unsigned int irq, unsigned int regset);
  145. _icctrl_msc = (unsigned long) ioremap (MIPS_MSC01_IC_REG_BASE, 0x40000);
  146. /* Reset interrupt controller - initialises all registers to 0 */
  147. MSCIC_WRITE(MSC01_IC_RST, MSC01_IC_RST_RST_BIT);
  148. board_bind_eic_interrupt = &msc_bind_eic_interrupt;
  149. for (; nirq >= 0; nirq--, imp++) {
  150. int n = imp->im_irq;
  151. switch (imp->im_type) {
  152. case MSC01_IRQ_EDGE:
  153. irq_desc[base+n].handler = &msc_edgeirq_type;
  154. if (cpu_has_veic)
  155. MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT);
  156. else
  157. MSCIC_WRITE(MSC01_IC_SUP+n*8, MSC01_IC_SUP_EDGE_BIT | imp->im_lvl);
  158. break;
  159. case MSC01_IRQ_LEVEL:
  160. irq_desc[base+n].handler = &msc_levelirq_type;
  161. if (cpu_has_veic)
  162. MSCIC_WRITE(MSC01_IC_SUP+n*8, 0);
  163. else
  164. MSCIC_WRITE(MSC01_IC_SUP+n*8, imp->im_lvl);
  165. }
  166. }
  167. irq_base = base;
  168. MSCIC_WRITE(MSC01_IC_GENA, MSC01_IC_GENA_GENA_BIT); /* Enable interrupt generation */
  169. }