irq.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2007 Lemote Inc. & Insititute 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_IRQ(LOONGSON2_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. };
  40. void __init set_irq_trigger_mode(void)
  41. {
  42. /* most bonito irq should be level triggered */
  43. BONITO_INTEDGE = BONITO_ICU_SYSTEMERR | BONITO_ICU_MASTERERR |
  44. BONITO_ICU_RETRYERR | BONITO_ICU_MBOXES;
  45. }
  46. void __init mach_init_irq(void)
  47. {
  48. /* init all controller
  49. * 0-15 ------> i8259 interrupt
  50. * 16-23 ------> mips cpu interrupt
  51. * 32-63 ------> bonito irq
  52. */
  53. /* Sets the first-level interrupt dispatcher. */
  54. mips_cpu_irq_init();
  55. init_i8259_irqs();
  56. bonito_irq_init();
  57. /* bonito irq at IP2 */
  58. setup_irq(MIPS_CPU_IRQ_BASE + 2, &cascade_irqaction);
  59. /* 8259 irq at IP5 */
  60. setup_irq(MIPS_CPU_IRQ_BASE + 5, &cascade_irqaction);
  61. }