msp_irq_slp.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. mask_slp_irq(irq);
  43. /*
  44. * only really necessary for 18, 16-14 and sometimes 3:0 (since
  45. * these can be edge sensitive) but it doesn't hurt for the others.
  46. */
  47. /* check for PER interrupt range */
  48. if (irq < MSP_PER_INTBASE)
  49. *SLP_INT_STS_REG = (1 << (irq - MSP_SLP_INTBASE));
  50. else
  51. *PER_INT_STS_REG = (1 << (irq - MSP_PER_INTBASE));
  52. }
  53. static struct irq_chip msp_slp_irq_controller = {
  54. .name = "MSP_SLP",
  55. .ack = ack_msp_slp_irq,
  56. .mask = ack_msp_slp_irq,
  57. .mask_ack = ack_msp_slp_irq,
  58. .unmask = unmask_msp_slp_irq,
  59. };
  60. void __init msp_slp_irq_init(void)
  61. {
  62. int i;
  63. /* Mask/clear interrupts. */
  64. *SLP_INT_MSK_REG = 0x00000000;
  65. *PER_INT_MSK_REG = 0x00000000;
  66. *SLP_INT_STS_REG = 0xFFFFFFFF;
  67. *PER_INT_STS_REG = 0xFFFFFFFF;
  68. /* initialize all the IRQ descriptors */
  69. for (i = MSP_SLP_INTBASE; i < MSP_PER_INTBASE + 32; i++)
  70. set_irq_chip_and_handler(i, &msp_slp_irq_controller
  71. handle_level_irq);
  72. }
  73. void msp_slp_irq_dispatch(void)
  74. {
  75. u32 pending;
  76. int intbase;
  77. intbase = MSP_SLP_INTBASE;
  78. pending = *SLP_INT_STS_REG & *SLP_INT_MSK_REG;
  79. /* check for PER interrupt */
  80. if (pending == (1 << (MSP_INT_PER - MSP_SLP_INTBASE))) {
  81. intbase = MSP_PER_INTBASE;
  82. pending = *PER_INT_STS_REG & *PER_INT_MSK_REG;
  83. }
  84. /* check for spurious interrupt */
  85. if (pending == 0x00000000) {
  86. printk(KERN_ERR "Spurious %s interrupt?\n",
  87. (intbase == MSP_SLP_INTBASE) ? "SLP" : "PER");
  88. return;
  89. }
  90. /* dispatch the irq */
  91. do_IRQ(ffs(pending) + intbase - 1);
  92. }