vrc5476_irq.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * The irq controller for vrc5476.
  3. *
  4. * Copyright (C) 2001 MontaVista Software Inc.
  5. * Author: jsun@mvista.com or jsun@junsun.net
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. *
  12. */
  13. #include <linux/init.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/irq.h>
  16. #include <linux/types.h>
  17. #include <linux/ptrace.h>
  18. #include <asm/system.h>
  19. #include <asm/ddb5xxx/ddb5xxx.h>
  20. static int irq_base;
  21. static void vrc5476_irq_enable(uint irq)
  22. {
  23. nile4_enable_irq(irq - irq_base);
  24. }
  25. static void vrc5476_irq_disable(uint irq)
  26. {
  27. nile4_disable_irq(irq - irq_base);
  28. }
  29. static unsigned int vrc5476_irq_startup(uint irq)
  30. {
  31. nile4_enable_irq(irq - irq_base);
  32. return 0;
  33. }
  34. #define vrc5476_irq_shutdown vrc5476_irq_disable
  35. static void vrc5476_irq_ack(uint irq)
  36. {
  37. nile4_clear_irq(irq - irq_base);
  38. nile4_disable_irq(irq - irq_base);
  39. }
  40. static void vrc5476_irq_end(uint irq)
  41. {
  42. if(!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
  43. vrc5476_irq_enable(irq);
  44. }
  45. static hw_irq_controller vrc5476_irq_controller = {
  46. "vrc5476",
  47. vrc5476_irq_startup,
  48. vrc5476_irq_shutdown,
  49. vrc5476_irq_enable,
  50. vrc5476_irq_disable,
  51. vrc5476_irq_ack,
  52. vrc5476_irq_end,
  53. NULL /* no affinity stuff for UP */
  54. };
  55. void __init
  56. vrc5476_irq_init(u32 base)
  57. {
  58. u32 i;
  59. irq_base = base;
  60. for (i= base; i< base + NUM_VRC5476_IRQ; i++) {
  61. irq_desc[i].status = IRQ_DISABLED;
  62. irq_desc[i].action = NULL;
  63. irq_desc[i].depth = 1;
  64. irq_desc[i].handler = &vrc5476_irq_controller;
  65. }
  66. }
  67. asmlinkage void
  68. vrc5476_irq_dispatch(struct pt_regs *regs)
  69. {
  70. extern void spurious_interrupt(void);
  71. u32 mask;
  72. int nile4_irq;
  73. mask = nile4_get_irq_stat(0);
  74. /* quick check for possible time interrupt */
  75. if (mask & (1 << VRC5476_IRQ_GPT)) {
  76. do_IRQ(VRC5476_IRQ_BASE + VRC5476_IRQ_GPT, regs);
  77. return;
  78. }
  79. /* check for i8259 interrupts */
  80. if (mask & (1 << VRC5476_I8259_CASCADE)) {
  81. int i8259_irq = nile4_i8259_iack();
  82. do_IRQ(I8259_IRQ_BASE + i8259_irq, regs);
  83. return;
  84. }
  85. /* regular nile4 interrupts (we should not really have any */
  86. for (nile4_irq = 0; mask; nile4_irq++, mask >>= 1) {
  87. if (mask & 1) {
  88. do_IRQ(VRC5476_IRQ_BASE + nile4_irq, regs);
  89. return;
  90. }
  91. }
  92. spurious_interrupt();
  93. }