ppc8xx_pic.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #include <linux/config.h>
  2. #include <linux/module.h>
  3. #include <linux/stddef.h>
  4. #include <linux/init.h>
  5. #include <linux/sched.h>
  6. #include <linux/signal.h>
  7. #include <linux/interrupt.h>
  8. #include <asm/irq.h>
  9. #include <asm/8xx_immap.h>
  10. #include <asm/mpc8xx.h>
  11. #include "ppc8xx_pic.h"
  12. extern int cpm_get_irq(struct pt_regs *regs);
  13. /* The 8xx internal interrupt controller. It is usually
  14. * the only interrupt controller. Some boards, like the MBX and
  15. * Sandpoint have the 8259 as a secondary controller. Depending
  16. * upon the processor type, the internal controller can have as
  17. * few as 16 interrups or as many as 64. We could use the
  18. * "clear_bit()" and "set_bit()" functions like other platforms,
  19. * but they are overkill for us.
  20. */
  21. static void m8xx_mask_irq(unsigned int irq_nr)
  22. {
  23. int bit, word;
  24. bit = irq_nr & 0x1f;
  25. word = irq_nr >> 5;
  26. ppc_cached_irq_mask[word] &= ~(1 << (31-bit));
  27. ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_simask =
  28. ppc_cached_irq_mask[word];
  29. }
  30. static void m8xx_unmask_irq(unsigned int irq_nr)
  31. {
  32. int bit, word;
  33. bit = irq_nr & 0x1f;
  34. word = irq_nr >> 5;
  35. ppc_cached_irq_mask[word] |= (1 << (31-bit));
  36. ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_simask =
  37. ppc_cached_irq_mask[word];
  38. }
  39. static void m8xx_end_irq(unsigned int irq_nr)
  40. {
  41. if (!(irq_desc[irq_nr].status & (IRQ_DISABLED|IRQ_INPROGRESS))
  42. && irq_desc[irq_nr].action) {
  43. int bit, word;
  44. bit = irq_nr & 0x1f;
  45. word = irq_nr >> 5;
  46. ppc_cached_irq_mask[word] |= (1 << (31-bit));
  47. ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_simask =
  48. ppc_cached_irq_mask[word];
  49. }
  50. }
  51. static void m8xx_mask_and_ack(unsigned int irq_nr)
  52. {
  53. int bit, word;
  54. bit = irq_nr & 0x1f;
  55. word = irq_nr >> 5;
  56. ppc_cached_irq_mask[word] &= ~(1 << (31-bit));
  57. ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_simask =
  58. ppc_cached_irq_mask[word];
  59. ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_sipend = 1 << (31-bit);
  60. }
  61. struct hw_interrupt_type ppc8xx_pic = {
  62. .typename = " 8xx SIU ",
  63. .enable = m8xx_unmask_irq,
  64. .disable = m8xx_mask_irq,
  65. .ack = m8xx_mask_and_ack,
  66. .end = m8xx_end_irq,
  67. };
  68. /*
  69. * We either return a valid interrupt or -1 if there is nothing pending
  70. */
  71. int
  72. m8xx_get_irq(struct pt_regs *regs)
  73. {
  74. int irq;
  75. /* For MPC8xx, read the SIVEC register and shift the bits down
  76. * to get the irq number.
  77. */
  78. irq = ((immap_t *)IMAP_ADDR)->im_siu_conf.sc_sivec >> 26;
  79. /*
  80. * When we read the sivec without an interrupt to process, we will
  81. * get back SIU_LEVEL7. In this case, return -1
  82. */
  83. if (irq == CPM_INTERRUPT)
  84. irq = CPM_IRQ_OFFSET + cpm_get_irq(regs);
  85. #if defined(CONFIG_PCI)
  86. else if (irq == ISA_BRIDGE_INT) {
  87. int isa_irq;
  88. if ((isa_irq = i8259_poll(regs)) >= 0)
  89. irq = I8259_IRQ_OFFSET + isa_irq;
  90. }
  91. #endif /* CONFIG_PCI */
  92. else if (irq == SIU_LEVEL7)
  93. irq = -1;
  94. return irq;
  95. }
  96. #if defined(CONFIG_MBX) && defined(CONFIG_PCI)
  97. /* Only the MBX uses the external 8259. This allows us to catch standard
  98. * drivers that may mess up the internal interrupt controllers, and also
  99. * allow them to run without modification on the MBX.
  100. */
  101. void mbx_i8259_action(int irq, void *dev_id, struct pt_regs *regs)
  102. {
  103. /* This interrupt handler never actually gets called. It is
  104. * installed only to unmask the 8259 cascade interrupt in the SIU
  105. * and to make the 8259 cascade interrupt visible in /proc/interrupts.
  106. */
  107. }
  108. #endif /* CONFIG_PCI */