msp_irq_cic.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * This file define the irq handler for MSP SLM subsystem interrupts.
  3. *
  4. * Copyright 2005-2007 PMC-Sierra, Inc, derived from irq_cpu.c
  5. * Author: Andrew Hughes, Andrew_Hughes@pmc-sierra.com
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2 of the License, or (at your
  10. * option) any later version.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/kernel.h>
  15. #include <linux/bitops.h>
  16. #include <asm/system.h>
  17. #include <msp_cic_int.h>
  18. #include <msp_regs.h>
  19. /*
  20. * NOTE: We are only enabling support for VPE0 right now.
  21. */
  22. static inline void unmask_msp_cic_irq(unsigned int irq)
  23. {
  24. /* check for PER interrupt range */
  25. if (irq < MSP_PER_INTBASE)
  26. *CIC_VPE0_MSK_REG |= (1 << (irq - MSP_CIC_INTBASE));
  27. else
  28. *PER_INT_MSK_REG |= (1 << (irq - MSP_PER_INTBASE));
  29. }
  30. static inline void mask_msp_cic_irq(unsigned int irq)
  31. {
  32. /* check for PER interrupt range */
  33. if (irq < MSP_PER_INTBASE)
  34. *CIC_VPE0_MSK_REG &= ~(1 << (irq - MSP_CIC_INTBASE));
  35. else
  36. *PER_INT_MSK_REG &= ~(1 << (irq - MSP_PER_INTBASE));
  37. }
  38. /*
  39. * While we ack the interrupt interrupts are disabled and thus we don't need
  40. * to deal with concurrency issues. Same for msp_cic_irq_end.
  41. */
  42. static inline void ack_msp_cic_irq(unsigned int irq)
  43. {
  44. mask_msp_cic_irq(irq);
  45. /*
  46. * only really necessary for 18, 16-14 and sometimes 3:0 (since
  47. * these can be edge sensitive) but it doesn't hurt for the others.
  48. */
  49. /* check for PER interrupt range */
  50. if (irq < MSP_PER_INTBASE)
  51. *CIC_STS_REG = (1 << (irq - MSP_CIC_INTBASE));
  52. else
  53. *PER_INT_STS_REG = (1 << (irq - MSP_PER_INTBASE));
  54. }
  55. static struct irq_chip msp_cic_irq_controller = {
  56. .name = "MSP_CIC",
  57. .ack = ack_msp_cic_irq,
  58. .mask = ack_msp_cic_irq,
  59. .mask_ack = ack_msp_cic_irq,
  60. .unmask = unmask_msp_cic_irq,
  61. };
  62. void __init msp_cic_irq_init(void)
  63. {
  64. int i;
  65. /* Mask/clear interrupts. */
  66. *CIC_VPE0_MSK_REG = 0x00000000;
  67. *PER_INT_MSK_REG = 0x00000000;
  68. *CIC_STS_REG = 0xFFFFFFFF;
  69. *PER_INT_STS_REG = 0xFFFFFFFF;
  70. #if defined(CONFIG_PMC_MSP7120_GW) || \
  71. defined(CONFIG_PMC_MSP7120_EVAL)
  72. /*
  73. * The MSP7120 RG and EVBD boards use IRQ[6:4] for PCI.
  74. * These inputs map to EXT_INT_POL[6:4] inside the CIC.
  75. * They are to be active low, level sensitive.
  76. */
  77. *CIC_EXT_CFG_REG &= 0xFFFF8F8F;
  78. #endif
  79. /* initialize all the IRQ descriptors */
  80. for (i = MSP_CIC_INTBASE; i < MSP_PER_INTBASE + 32; i++)
  81. set_irq_chip_and_handler(i, &msp_cic_irq_controller,
  82. handle_level_irq);
  83. }
  84. void msp_cic_irq_dispatch(void)
  85. {
  86. u32 pending;
  87. int intbase;
  88. intbase = MSP_CIC_INTBASE;
  89. pending = *CIC_STS_REG & *CIC_VPE0_MSK_REG;
  90. /* check for PER interrupt */
  91. if (pending == (1 << (MSP_INT_PER - MSP_CIC_INTBASE))) {
  92. intbase = MSP_PER_INTBASE;
  93. pending = *PER_INT_STS_REG & *PER_INT_MSK_REG;
  94. }
  95. /* check for spurious interrupt */
  96. if (pending == 0x00000000) {
  97. printk(KERN_ERR
  98. "Spurious %s interrupt? status %08x, mask %08x\n",
  99. (intbase == MSP_CIC_INTBASE) ? "CIC" : "PER",
  100. (intbase == MSP_CIC_INTBASE) ?
  101. *CIC_STS_REG : *PER_INT_STS_REG,
  102. (intbase == MSP_CIC_INTBASE) ?
  103. *CIC_VPE0_MSK_REG : *PER_INT_MSK_REG);
  104. return;
  105. }
  106. /* check for the timer and dispatch it first */
  107. if ((intbase == MSP_CIC_INTBASE) &&
  108. (pending & (1 << (MSP_INT_VPE0_TIMER - MSP_CIC_INTBASE))))
  109. do_IRQ(MSP_INT_VPE0_TIMER);
  110. else
  111. do_IRQ(ffs(pending) + intbase - 1);
  112. }