msp_irq_slp.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * This file define the irq handler for MSP SLM subsystem interrupts.
  3. *
  4. * Copyright 2005-2006 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/mipsregs.h>
  17. #include <asm/system.h>
  18. #include <msp_slp_int.h>
  19. #include <msp_regs.h>
  20. static inline void unmask_msp_slp_irq(unsigned int irq)
  21. {
  22. /* check for PER interrupt range */
  23. if (irq < MSP_PER_INTBASE)
  24. *SLP_INT_MSK_REG |= (1 << (irq - MSP_SLP_INTBASE));
  25. else
  26. *PER_INT_MSK_REG |= (1 << (irq - MSP_PER_INTBASE));
  27. }
  28. static inline void mask_msp_slp_irq(unsigned int irq)
  29. {
  30. /* check for PER interrupt range */
  31. if (irq < MSP_PER_INTBASE)
  32. *SLP_INT_MSK_REG &= ~(1 << (irq - MSP_SLP_INTBASE));
  33. else
  34. *PER_INT_MSK_REG &= ~(1 << (irq - MSP_PER_INTBASE));
  35. }
  36. /*
  37. * While we ack the interrupt interrupts are disabled and thus we don't need
  38. * to deal with concurrency issues. Same for msp_slp_irq_end.
  39. */
  40. static inline void ack_msp_slp_irq(unsigned int irq)
  41. {
  42. /* check for PER interrupt range */
  43. if (irq < MSP_PER_INTBASE)
  44. *SLP_INT_STS_REG = (1 << (irq - MSP_SLP_INTBASE));
  45. else
  46. *PER_INT_STS_REG = (1 << (irq - MSP_PER_INTBASE));
  47. }
  48. static struct irq_chip msp_slp_irq_controller = {
  49. .name = "MSP_SLP",
  50. .ack = ack_msp_slp_irq,
  51. .mask = mask_msp_slp_irq,
  52. .unmask = unmask_msp_slp_irq,
  53. };
  54. void __init msp_slp_irq_init(void)
  55. {
  56. int i;
  57. /* Mask/clear interrupts. */
  58. *SLP_INT_MSK_REG = 0x00000000;
  59. *PER_INT_MSK_REG = 0x00000000;
  60. *SLP_INT_STS_REG = 0xFFFFFFFF;
  61. *PER_INT_STS_REG = 0xFFFFFFFF;
  62. /* initialize all the IRQ descriptors */
  63. for (i = MSP_SLP_INTBASE; i < MSP_PER_INTBASE + 32; i++)
  64. set_irq_chip_and_handler(i, &msp_slp_irq_controller,
  65. handle_level_irq);
  66. }
  67. void msp_slp_irq_dispatch(void)
  68. {
  69. u32 pending;
  70. int intbase;
  71. intbase = MSP_SLP_INTBASE;
  72. pending = *SLP_INT_STS_REG & *SLP_INT_MSK_REG;
  73. /* check for PER interrupt */
  74. if (pending == (1 << (MSP_INT_PER - MSP_SLP_INTBASE))) {
  75. intbase = MSP_PER_INTBASE;
  76. pending = *PER_INT_STS_REG & *PER_INT_MSK_REG;
  77. }
  78. /* check for spurious interrupt */
  79. if (pending == 0x00000000) {
  80. printk(KERN_ERR "Spurious %s interrupt?\n",
  81. (intbase == MSP_SLP_INTBASE) ? "SLP" : "PER");
  82. return;
  83. }
  84. /* dispatch the irq */
  85. do_IRQ(ffs(pending) + intbase - 1);
  86. }