ppc403_pic.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. *
  3. * Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
  4. *
  5. * Module name: ppc403_pic.c
  6. *
  7. * Description:
  8. * Interrupt controller driver for PowerPC 403-based processors.
  9. */
  10. /*
  11. * The PowerPC 403 cores' Asynchronous Interrupt Controller (AIC) has
  12. * 32 possible interrupts, a majority of which are not implemented on
  13. * all cores. There are six configurable, external interrupt pins and
  14. * there are eight internal interrupts for the on-chip serial port
  15. * (SPU), DMA controller, and JTAG controller.
  16. *
  17. */
  18. #include <linux/init.h>
  19. #include <linux/sched.h>
  20. #include <linux/signal.h>
  21. #include <linux/stddef.h>
  22. #include <asm/processor.h>
  23. #include <asm/system.h>
  24. #include <asm/irq.h>
  25. #include <asm/ppc4xx_pic.h>
  26. #include <asm/machdep.h>
  27. /* Function Prototypes */
  28. static void ppc403_aic_enable(unsigned int irq);
  29. static void ppc403_aic_disable(unsigned int irq);
  30. static void ppc403_aic_disable_and_ack(unsigned int irq);
  31. static struct hw_interrupt_type ppc403_aic = {
  32. .typename = "403GC AIC",
  33. .enable = ppc403_aic_enable,
  34. .disable = ppc403_aic_disable,
  35. .ack = ppc403_aic_disable_and_ack,
  36. };
  37. int
  38. ppc403_pic_get_irq(struct pt_regs *regs)
  39. {
  40. int irq;
  41. unsigned long bits;
  42. /*
  43. * Only report the status of those interrupts that are actually
  44. * enabled.
  45. */
  46. bits = mfdcr(DCRN_EXISR) & mfdcr(DCRN_EXIER);
  47. /*
  48. * Walk through the interrupts from highest priority to lowest, and
  49. * report the first pending interrupt found.
  50. * We want PPC, not C bit numbering, so just subtract the ffs()
  51. * result from 32.
  52. */
  53. irq = 32 - ffs(bits);
  54. if (irq == NR_AIC_IRQS)
  55. irq = -1;
  56. return (irq);
  57. }
  58. static void
  59. ppc403_aic_enable(unsigned int irq)
  60. {
  61. int bit, word;
  62. bit = irq & 0x1f;
  63. word = irq >> 5;
  64. ppc_cached_irq_mask[word] |= (1 << (31 - bit));
  65. mtdcr(DCRN_EXIER, ppc_cached_irq_mask[word]);
  66. }
  67. static void
  68. ppc403_aic_disable(unsigned int irq)
  69. {
  70. int bit, word;
  71. bit = irq & 0x1f;
  72. word = irq >> 5;
  73. ppc_cached_irq_mask[word] &= ~(1 << (31 - bit));
  74. mtdcr(DCRN_EXIER, ppc_cached_irq_mask[word]);
  75. }
  76. static void
  77. ppc403_aic_disable_and_ack(unsigned int irq)
  78. {
  79. int bit, word;
  80. bit = irq & 0x1f;
  81. word = irq >> 5;
  82. ppc_cached_irq_mask[word] &= ~(1 << (31 - bit));
  83. mtdcr(DCRN_EXIER, ppc_cached_irq_mask[word]);
  84. mtdcr(DCRN_EXISR, (1 << (31 - bit)));
  85. }
  86. void __init
  87. ppc4xx_pic_init(void)
  88. {
  89. int i;
  90. /*
  91. * Disable all external interrupts until they are
  92. * explicity requested.
  93. */
  94. ppc_cached_irq_mask[0] = 0;
  95. mtdcr(DCRN_EXIER, ppc_cached_irq_mask[0]);
  96. ppc_md.get_irq = ppc403_pic_get_irq;
  97. for (i = 0; i < NR_IRQS; i++)
  98. irq_desc[i].handler = &ppc403_aic;
  99. }