irq_srm.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Handle interrupts from the SRM, assuming no additional weirdness.
  3. */
  4. #include <linux/init.h>
  5. #include <linux/sched.h>
  6. #include <linux/irq.h>
  7. #include "proto.h"
  8. #include "irq_impl.h"
  9. /*
  10. * Is the palcode SMP safe? In other words: can we call cserve_ena/dis
  11. * at the same time in multiple CPUs? To be safe I added a spinlock
  12. * but it can be removed trivially if the palcode is robust against smp.
  13. */
  14. DEFINE_SPINLOCK(srm_irq_lock);
  15. static inline void
  16. srm_enable_irq(struct irq_data *d)
  17. {
  18. spin_lock(&srm_irq_lock);
  19. cserve_ena(d->irq - 16);
  20. spin_unlock(&srm_irq_lock);
  21. }
  22. static void
  23. srm_disable_irq(struct irq_data *d)
  24. {
  25. spin_lock(&srm_irq_lock);
  26. cserve_dis(d->irq - 16);
  27. spin_unlock(&srm_irq_lock);
  28. }
  29. /* Handle interrupts from the SRM, assuming no additional weirdness. */
  30. static struct irq_chip srm_irq_type = {
  31. .name = "SRM",
  32. .irq_unmask = srm_enable_irq,
  33. .irq_mask = srm_disable_irq,
  34. .irq_mask_ack = srm_disable_irq,
  35. };
  36. void __init
  37. init_srm_irqs(long max, unsigned long ignore_mask)
  38. {
  39. long i;
  40. if (NR_IRQS <= 16)
  41. return;
  42. for (i = 16; i < max; ++i) {
  43. if (i < 64 && ((ignore_mask >> i) & 1))
  44. continue;
  45. irq_set_chip_and_handler(i, &srm_irq_type, handle_level_irq);
  46. irq_set_status_flags(i, IRQ_LEVEL);
  47. }
  48. }
  49. void
  50. srm_device_interrupt(unsigned long vector)
  51. {
  52. int irq = (vector - 0x800) >> 4;
  53. handle_irq(irq);
  54. }