ppc8xx_pic.c 3.3 KB

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