irq.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (C) 2007 Lemote Inc. & Institute of Computing Technology
  3. * Author: Fuxin Zhang, zhangfx@lemote.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/interrupt.h>
  11. #include <asm/irq_cpu.h>
  12. #include <asm/i8259.h>
  13. #include <loongson.h>
  14. static void i8259_irqdispatch(void)
  15. {
  16. int irq;
  17. irq = i8259_irq();
  18. if (irq >= 0)
  19. do_IRQ(irq);
  20. else
  21. spurious_interrupt();
  22. }
  23. asmlinkage void mach_irq_dispatch(unsigned int pending)
  24. {
  25. if (pending & CAUSEF_IP7)
  26. do_IRQ(MIPS_CPU_IRQ_BASE + 7);
  27. else if (pending & CAUSEF_IP6) /* perf counter loverflow */
  28. do_perfcnt_IRQ();
  29. else if (pending & CAUSEF_IP5)
  30. i8259_irqdispatch();
  31. else if (pending & CAUSEF_IP2)
  32. bonito_irqdispatch();
  33. else
  34. spurious_interrupt();
  35. }
  36. static struct irqaction cascade_irqaction = {
  37. .handler = no_action,
  38. .name = "cascade",
  39. .flags = IRQF_NO_THREAD,
  40. };
  41. void __init mach_init_irq(void)
  42. {
  43. /* init all controller
  44. * 0-15 ------> i8259 interrupt
  45. * 16-23 ------> mips cpu interrupt
  46. * 32-63 ------> bonito irq
  47. */
  48. /* most bonito irq should be level triggered */
  49. LOONGSON_INTEDGE = LOONGSON_ICU_SYSTEMERR | LOONGSON_ICU_MASTERERR |
  50. LOONGSON_ICU_RETRYERR | LOONGSON_ICU_MBOXES;
  51. /* Sets the first-level interrupt dispatcher. */
  52. mips_cpu_irq_init();
  53. init_i8259_irqs();
  54. bonito_irq_init();
  55. /* bonito irq at IP2 */
  56. setup_irq(MIPS_CPU_IRQ_BASE + 2, &cascade_irqaction);
  57. /* 8259 irq at IP5 */
  58. setup_irq(MIPS_CPU_IRQ_BASE + 5, &cascade_irqaction);
  59. }