msp_irq_slp.c 2.7 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 <asm/system.h>
  18. #include <msp_slp_int.h>
  19. #include <msp_regs.h>
  20. static inline void unmask_msp_slp_irq(struct irq_data *d)
  21. {
  22. unsigned int irq = d->irq;
  23. /* check for PER interrupt range */
  24. if (irq < MSP_PER_INTBASE)
  25. *SLP_INT_MSK_REG |= (1 << (irq - MSP_SLP_INTBASE));
  26. else
  27. *PER_INT_MSK_REG |= (1 << (irq - MSP_PER_INTBASE));
  28. }
  29. static inline void mask_msp_slp_irq(struct irq_data *d)
  30. {
  31. unsigned int irq = d->irq;
  32. /* check for PER interrupt range */
  33. if (irq < MSP_PER_INTBASE)
  34. *SLP_INT_MSK_REG &= ~(1 << (irq - MSP_SLP_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_slp_irq_end.
  41. */
  42. static inline void ack_msp_slp_irq(struct irq_data *d)
  43. {
  44. unsigned int irq = d->irq;
  45. /* check for PER interrupt range */
  46. if (irq < MSP_PER_INTBASE)
  47. *SLP_INT_STS_REG = (1 << (irq - MSP_SLP_INTBASE));
  48. else
  49. *PER_INT_STS_REG = (1 << (irq - MSP_PER_INTBASE));
  50. }
  51. static struct irq_chip msp_slp_irq_controller = {
  52. .name = "MSP_SLP",
  53. .irq_ack = ack_msp_slp_irq,
  54. .irq_mask = mask_msp_slp_irq,
  55. .irq_unmask = unmask_msp_slp_irq,
  56. };
  57. void __init msp_slp_irq_init(void)
  58. {
  59. int i;
  60. /* Mask/clear interrupts. */
  61. *SLP_INT_MSK_REG = 0x00000000;
  62. *PER_INT_MSK_REG = 0x00000000;
  63. *SLP_INT_STS_REG = 0xFFFFFFFF;
  64. *PER_INT_STS_REG = 0xFFFFFFFF;
  65. /* initialize all the IRQ descriptors */
  66. for (i = MSP_SLP_INTBASE; i < MSP_PER_INTBASE + 32; i++)
  67. irq_set_chip_and_handler(i, &msp_slp_irq_controller,
  68. handle_level_irq);
  69. }
  70. void msp_slp_irq_dispatch(void)
  71. {
  72. u32 pending;
  73. int intbase;
  74. intbase = MSP_SLP_INTBASE;
  75. pending = *SLP_INT_STS_REG & *SLP_INT_MSK_REG;
  76. /* check for PER interrupt */
  77. if (pending == (1 << (MSP_INT_PER - MSP_SLP_INTBASE))) {
  78. intbase = MSP_PER_INTBASE;
  79. pending = *PER_INT_STS_REG & *PER_INT_MSK_REG;
  80. }
  81. /* check for spurious interrupt */
  82. if (pending == 0x00000000) {
  83. printk(KERN_ERR "Spurious %s interrupt?\n",
  84. (intbase == MSP_SLP_INTBASE) ? "SLP" : "PER");
  85. return;
  86. }
  87. /* dispatch the irq */
  88. do_IRQ(ffs(pending) + intbase - 1);
  89. }