irq_cpu.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright 2001 MontaVista Software Inc.
  3. * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net
  4. *
  5. * Copyright (C) 2001 Ralf Baechle
  6. *
  7. * This file define the irq handler for MIPS CPU interrupts.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. */
  14. /*
  15. * Almost all MIPS CPUs define 8 interrupt sources. They are typically
  16. * level triggered (i.e., cannot be cleared from CPU; must be cleared from
  17. * device). The first two are software interrupts which we don't really
  18. * use or support. The last one is usually the CPU timer interrupt if
  19. * counter register is present or, for CPUs with an external FPU, by
  20. * convention it's the FPU exception interrupt.
  21. *
  22. * Don't even think about using this on SMP. You have been warned.
  23. *
  24. * This file exports one global function:
  25. * void mips_cpu_irq_init(int irq_base);
  26. */
  27. #include <linux/init.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/kernel.h>
  30. #include <asm/irq_cpu.h>
  31. #include <asm/mipsregs.h>
  32. #include <asm/system.h>
  33. static int mips_cpu_irq_base;
  34. static inline void unmask_mips_irq(unsigned int irq)
  35. {
  36. clear_c0_cause(0x100 << (irq - mips_cpu_irq_base));
  37. set_c0_status(0x100 << (irq - mips_cpu_irq_base));
  38. }
  39. static inline void mask_mips_irq(unsigned int irq)
  40. {
  41. clear_c0_status(0x100 << (irq - mips_cpu_irq_base));
  42. }
  43. static inline void mips_cpu_irq_enable(unsigned int irq)
  44. {
  45. unsigned long flags;
  46. local_irq_save(flags);
  47. unmask_mips_irq(irq);
  48. local_irq_restore(flags);
  49. }
  50. static void mips_cpu_irq_disable(unsigned int irq)
  51. {
  52. unsigned long flags;
  53. local_irq_save(flags);
  54. mask_mips_irq(irq);
  55. local_irq_restore(flags);
  56. }
  57. static unsigned int mips_cpu_irq_startup(unsigned int irq)
  58. {
  59. mips_cpu_irq_enable(irq);
  60. return 0;
  61. }
  62. #define mips_cpu_irq_shutdown mips_cpu_irq_disable
  63. /*
  64. * While we ack the interrupt interrupts are disabled and thus we don't need
  65. * to deal with concurrency issues. Same for mips_cpu_irq_end.
  66. */
  67. static void mips_cpu_irq_ack(unsigned int irq)
  68. {
  69. /* Only necessary for soft interrupts */
  70. clear_c0_cause(0x100 << (irq - mips_cpu_irq_base));
  71. mask_mips_irq(irq);
  72. }
  73. static void mips_cpu_irq_end(unsigned int irq)
  74. {
  75. if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
  76. unmask_mips_irq(irq);
  77. }
  78. static hw_irq_controller mips_cpu_irq_controller = {
  79. "MIPS",
  80. mips_cpu_irq_startup,
  81. mips_cpu_irq_shutdown,
  82. mips_cpu_irq_enable,
  83. mips_cpu_irq_disable,
  84. mips_cpu_irq_ack,
  85. mips_cpu_irq_end,
  86. NULL /* no affinity stuff for UP */
  87. };
  88. void __init mips_cpu_irq_init(int irq_base)
  89. {
  90. int i;
  91. for (i = irq_base; i < irq_base + 8; i++) {
  92. irq_desc[i].status = IRQ_DISABLED;
  93. irq_desc[i].action = NULL;
  94. irq_desc[i].depth = 1;
  95. irq_desc[i].handler = &mips_cpu_irq_controller;
  96. }
  97. mips_cpu_irq_base = irq_base;
  98. }