irq.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * BRIEF MODULE DESCRIPTION
  3. * Code to handle irqs on GT64120A boards
  4. * Derived from mips/orion and Cort <cort@fsmlabs.com>
  5. *
  6. * Copyright (C) 2000 RidgeRun, Inc.
  7. * Author: RidgeRun, Inc.
  8. * glonnon@ridgerun.com, skranz@ridgerun.com, stevej@ridgerun.com
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at your
  13. * option) any later version.
  14. *
  15. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  16. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  18. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  19. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  20. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  21. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  22. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  24. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *
  26. * You should have received a copy of the GNU General Public License along
  27. * with this program; if not, write to the Free Software Foundation, Inc.,
  28. * 675 Mass Ave, Cambridge, MA 02139, USA.
  29. */
  30. #include <linux/errno.h>
  31. #include <linux/init.h>
  32. #include <linux/kernel_stat.h>
  33. #include <linux/module.h>
  34. #include <linux/signal.h>
  35. #include <linux/sched.h>
  36. #include <linux/types.h>
  37. #include <linux/interrupt.h>
  38. #include <linux/ioport.h>
  39. #include <linux/timex.h>
  40. #include <linux/slab.h>
  41. #include <linux/random.h>
  42. #include <linux/bitops.h>
  43. #include <asm/bootinfo.h>
  44. #include <asm/io.h>
  45. #include <asm/mipsregs.h>
  46. #include <asm/system.h>
  47. #include <asm/gt64120.h>
  48. asmlinkage inline void pci_intA(struct pt_regs *regs)
  49. {
  50. do_IRQ(GT_INTA, regs);
  51. }
  52. asmlinkage inline void pci_intD(struct pt_regs *regs)
  53. {
  54. do_IRQ(GT_INTD, regs);
  55. }
  56. static void disable_ev64120_irq(unsigned int irq_nr)
  57. {
  58. unsigned long flags;
  59. local_irq_save(flags);
  60. if (irq_nr >= 8) { // All PCI interrupts are on line 5 or 2
  61. clear_c0_status(9 << 10);
  62. } else {
  63. clear_c0_status(1 << (irq_nr + 8));
  64. }
  65. local_irq_restore(flags);
  66. }
  67. static void enable_ev64120_irq(unsigned int irq_nr)
  68. {
  69. unsigned long flags;
  70. local_irq_save(flags);
  71. if (irq_nr >= 8) // All PCI interrupts are on line 5 or 2
  72. set_c0_status(9 << 10);
  73. else
  74. set_c0_status(1 << (irq_nr + 8));
  75. local_irq_restore(flags);
  76. }
  77. static unsigned int startup_ev64120_irq(unsigned int irq)
  78. {
  79. enable_ev64120_irq(irq);
  80. return 0; /* Never anything pending */
  81. }
  82. #define shutdown_ev64120_irq disable_ev64120_irq
  83. #define mask_and_ack_ev64120_irq disable_ev64120_irq
  84. static void end_ev64120_irq(unsigned int irq)
  85. {
  86. if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
  87. enable_ev64120_irq(irq);
  88. }
  89. static struct hw_interrupt_type ev64120_irq_type = {
  90. .typename = "EV64120",
  91. .startup = startup_ev64120_irq,
  92. .shutdown = shutdown_ev64120_irq,
  93. .enable = enable_ev64120_irq,
  94. .disable = disable_ev64120_irq,
  95. .ack = mask_and_ack_ev64120_irq,
  96. .end = end_ev64120_irq,
  97. .set_affinity = NULL
  98. };
  99. void gt64120_irq_setup(void)
  100. {
  101. extern asmlinkage void galileo_handle_int(void);
  102. /*
  103. * Clear all of the interrupts while we change the able around a bit.
  104. */
  105. clear_c0_status(ST0_IM);
  106. /* Sets the exception_handler array. */
  107. set_except_vector(0, galileo_handle_int);
  108. local_irq_disable();
  109. /*
  110. * Enable timer. Other interrupts will be enabled as they are
  111. * registered.
  112. */
  113. set_c0_status(IE_IRQ2);
  114. }
  115. void __init arch_init_irq(void)
  116. {
  117. int i;
  118. /* Let's initialize our IRQ descriptors */
  119. for (i = 0; i < NR_IRQS; i++) {
  120. irq_desc[i].status = 0;
  121. irq_desc[i].handler = &no_irq_type;
  122. irq_desc[i].action = NULL;
  123. irq_desc[i].depth = 0;
  124. spin_lock_init(&irq_desc[i].lock);
  125. }
  126. gt64120_irq_setup();
  127. }