ppc403_pic.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. /* Function Prototypes */
  27. static void ppc403_aic_enable(unsigned int irq);
  28. static void ppc403_aic_disable(unsigned int irq);
  29. static void ppc403_aic_disable_and_ack(unsigned int irq);
  30. static struct hw_interrupt_type ppc403_aic = {
  31. .typename = "403GC AIC",
  32. .enable = ppc403_aic_enable,
  33. .disable = ppc403_aic_disable,
  34. .ack = ppc403_aic_disable_and_ack,
  35. };
  36. int
  37. ppc403_pic_get_irq(struct pt_regs *regs)
  38. {
  39. int irq;
  40. unsigned long bits;
  41. /*
  42. * Only report the status of those interrupts that are actually
  43. * enabled.
  44. */
  45. bits = mfdcr(DCRN_EXISR) & mfdcr(DCRN_EXIER);
  46. /*
  47. * Walk through the interrupts from highest priority to lowest, and
  48. * report the first pending interrupt found.
  49. * We want PPC, not C bit numbering, so just subtract the ffs()
  50. * result from 32.
  51. */
  52. irq = 32 - ffs(bits);
  53. if (irq == NR_AIC_IRQS)
  54. irq = -1;
  55. return (irq);
  56. }
  57. static void
  58. ppc403_aic_enable(unsigned int irq)
  59. {
  60. int bit, word;
  61. bit = irq & 0x1f;
  62. word = irq >> 5;
  63. ppc_cached_irq_mask[word] |= (1 << (31 - bit));
  64. mtdcr(DCRN_EXIER, ppc_cached_irq_mask[word]);
  65. }
  66. static void
  67. ppc403_aic_disable(unsigned int irq)
  68. {
  69. int bit, word;
  70. bit = irq & 0x1f;
  71. word = irq >> 5;
  72. ppc_cached_irq_mask[word] &= ~(1 << (31 - bit));
  73. mtdcr(DCRN_EXIER, ppc_cached_irq_mask[word]);
  74. }
  75. static void
  76. ppc403_aic_disable_and_ack(unsigned int irq)
  77. {
  78. int bit, word;
  79. bit = irq & 0x1f;
  80. word = irq >> 5;
  81. ppc_cached_irq_mask[word] &= ~(1 << (31 - bit));
  82. mtdcr(DCRN_EXIER, ppc_cached_irq_mask[word]);
  83. mtdcr(DCRN_EXISR, (1 << (31 - bit)));
  84. }
  85. void __init
  86. ppc4xx_pic_init(void)
  87. {
  88. int i;
  89. /*
  90. * Disable all external interrupts until they are
  91. * explicity requested.
  92. */
  93. ppc_cached_irq_mask[0] = 0;
  94. mtdcr(DCRN_EXIER, ppc_cached_irq_mask[0]);
  95. ppc_md.get_irq = ppc403_pic_get_irq;
  96. for (i = 0; i < NR_IRQS; i++)
  97. irq_desc[i].handler = &ppc403_aic;
  98. }