msp_irq_slp.c 2.6 KB

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