irq.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* irq.c: FRV IRQ handling
  2. *
  3. * Copyright (C) 2003, 2004, 2006 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/ptrace.h>
  12. #include <linux/errno.h>
  13. #include <linux/signal.h>
  14. #include <linux/sched.h>
  15. #include <linux/ioport.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/timex.h>
  18. #include <linux/slab.h>
  19. #include <linux/random.h>
  20. #include <linux/smp_lock.h>
  21. #include <linux/init.h>
  22. #include <linux/kernel_stat.h>
  23. #include <linux/irq.h>
  24. #include <linux/proc_fs.h>
  25. #include <linux/seq_file.h>
  26. #include <linux/module.h>
  27. #include <asm/atomic.h>
  28. #include <asm/io.h>
  29. #include <asm/smp.h>
  30. #include <asm/system.h>
  31. #include <asm/bitops.h>
  32. #include <asm/uaccess.h>
  33. #include <asm/pgalloc.h>
  34. #include <asm/delay.h>
  35. #include <asm/irq.h>
  36. #include <asm/irc-regs.h>
  37. #include <asm/gdb-stub.h>
  38. #define set_IRR(N,A,B,C,D) __set_IRR(N, (A << 28) | (B << 24) | (C << 20) | (D << 16))
  39. extern void __init fpga_init(void);
  40. #ifdef CONFIG_FUJITSU_MB93493
  41. extern void __init mb93493_init(void);
  42. #endif
  43. #define __reg16(ADDR) (*(volatile unsigned short *)(ADDR))
  44. atomic_t irq_err_count;
  45. /*
  46. * Generic, controller-independent functions:
  47. */
  48. int show_interrupts(struct seq_file *p, void *v)
  49. {
  50. int i = *(loff_t *) v, cpu;
  51. struct irqaction * action;
  52. unsigned long flags;
  53. if (i == 0) {
  54. char cpuname[12];
  55. seq_printf(p, " ");
  56. for_each_present_cpu(cpu) {
  57. sprintf(cpuname, "CPU%d", cpu);
  58. seq_printf(p, " %10s", cpuname);
  59. }
  60. seq_putc(p, '\n');
  61. }
  62. if (i < NR_IRQS) {
  63. spin_lock_irqsave(&irq_desc[i].lock, flags);
  64. action = irq_desc[i].action;
  65. if (action) {
  66. seq_printf(p, "%3d: ", i);
  67. for_each_present_cpu(cpu)
  68. seq_printf(p, "%10u ", kstat_cpu(cpu).irqs[i]);
  69. seq_printf(p, " %10s", irq_desc[i].chip->name ? : "-");
  70. seq_printf(p, " %s", action->name);
  71. for (action = action->next;
  72. action;
  73. action = action->next)
  74. seq_printf(p, ", %s", action->name);
  75. seq_putc(p, '\n');
  76. }
  77. spin_unlock_irqrestore(&irq_desc[i].lock, flags);
  78. } else if (i == NR_IRQS) {
  79. seq_printf(p, "Err: %10u\n", atomic_read(&irq_err_count));
  80. }
  81. return 0;
  82. }
  83. /*
  84. * on-CPU PIC operations
  85. */
  86. static void frv_cpupic_ack(unsigned int irqlevel)
  87. {
  88. __clr_RC(irqlevel);
  89. __clr_IRL();
  90. }
  91. static void frv_cpupic_mask(unsigned int irqlevel)
  92. {
  93. __set_MASK(irqlevel);
  94. }
  95. static void frv_cpupic_mask_ack(unsigned int irqlevel)
  96. {
  97. __set_MASK(irqlevel);
  98. __clr_RC(irqlevel);
  99. __clr_IRL();
  100. }
  101. static void frv_cpupic_unmask(unsigned int irqlevel)
  102. {
  103. __clr_MASK(irqlevel);
  104. }
  105. static void frv_cpupic_end(unsigned int irqlevel)
  106. {
  107. __clr_MASK(irqlevel);
  108. }
  109. static struct irq_chip frv_cpu_pic = {
  110. .name = "cpu",
  111. .ack = frv_cpupic_ack,
  112. .mask = frv_cpupic_mask,
  113. .mask_ack = frv_cpupic_mask_ack,
  114. .unmask = frv_cpupic_unmask,
  115. .end = frv_cpupic_end,
  116. };
  117. /*
  118. * handles all normal device IRQ's
  119. * - registers are referred to by the __frame variable (GR28)
  120. * - IRQ distribution is complicated in this arch because of the many PICs, the
  121. * way they work and the way they cascade
  122. */
  123. asmlinkage void do_IRQ(void)
  124. {
  125. irq_enter();
  126. generic_handle_irq(__get_IRL());
  127. irq_exit();
  128. }
  129. /*
  130. * handles all NMIs when not co-opted by the debugger
  131. * - registers are referred to by the __frame variable (GR28)
  132. */
  133. asmlinkage void do_NMI(void)
  134. {
  135. }
  136. /*
  137. * initialise the interrupt system
  138. */
  139. void __init init_IRQ(void)
  140. {
  141. int level;
  142. for (level = 1; level <= 14; level++)
  143. set_irq_chip_and_handler(level, &frv_cpu_pic,
  144. handle_level_irq);
  145. set_irq_handler(IRQ_CPU_TIMER0, handle_edge_irq);
  146. /* set the trigger levels for internal interrupt sources
  147. * - timers all falling-edge
  148. * - ERR0 is rising-edge
  149. * - all others are high-level
  150. */
  151. __set_IITMR(0, 0x003f0000); /* DMA0-3, TIMER0-2 */
  152. __set_IITMR(1, 0x20000000); /* ERR0-1, UART0-1, DMA4-7 */
  153. /* route internal interrupts */
  154. set_IRR(4, IRQ_DMA3_LEVEL, IRQ_DMA2_LEVEL, IRQ_DMA1_LEVEL,
  155. IRQ_DMA0_LEVEL);
  156. set_IRR(5, 0, IRQ_TIMER2_LEVEL, IRQ_TIMER1_LEVEL, IRQ_TIMER0_LEVEL);
  157. set_IRR(6, IRQ_GDBSTUB_LEVEL, IRQ_GDBSTUB_LEVEL,
  158. IRQ_UART1_LEVEL, IRQ_UART0_LEVEL);
  159. set_IRR(7, IRQ_DMA7_LEVEL, IRQ_DMA6_LEVEL, IRQ_DMA5_LEVEL,
  160. IRQ_DMA4_LEVEL);
  161. /* route external interrupts */
  162. set_IRR(2, IRQ_XIRQ7_LEVEL, IRQ_XIRQ6_LEVEL, IRQ_XIRQ5_LEVEL,
  163. IRQ_XIRQ4_LEVEL);
  164. set_IRR(3, IRQ_XIRQ3_LEVEL, IRQ_XIRQ2_LEVEL, IRQ_XIRQ1_LEVEL,
  165. IRQ_XIRQ0_LEVEL);
  166. #if defined(CONFIG_MB93091_VDK)
  167. __set_TM1(0x55550000); /* XIRQ7-0 all active low */
  168. #elif defined(CONFIG_MB93093_PDK)
  169. __set_TM1(0x15550000); /* XIRQ7 active high, 6-0 all active low */
  170. #else
  171. #error dont know external IRQ trigger levels for this setup
  172. #endif
  173. fpga_init();
  174. #ifdef CONFIG_FUJITSU_MB93493
  175. mb93493_init();
  176. #endif
  177. }