ppc8xx_pic.c 3.3 KB

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