irq.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
  3. * Copyright (C) 2007-2009 PetaLogix
  4. * Copyright (C) 2006 Atmark Techno, Inc.
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/kernel.h>
  12. #include <linux/hardirq.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/irqflags.h>
  15. #include <linux/seq_file.h>
  16. #include <linux/kernel_stat.h>
  17. #include <linux/irq.h>
  18. #include <asm/prom.h>
  19. unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
  20. {
  21. struct of_irq oirq;
  22. if (of_irq_map_one(dev, index, &oirq))
  23. return NO_IRQ;
  24. return oirq.specifier[0];
  25. }
  26. EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
  27. /*
  28. * 'what should we do if we get a hw irq event on an illegal vector'.
  29. * each architecture has to answer this themselves.
  30. */
  31. void ack_bad_irq(unsigned int irq)
  32. {
  33. printk(KERN_WARNING "unexpected IRQ trap at vector %02x\n", irq);
  34. }
  35. static u32 concurrent_irq;
  36. void do_IRQ(struct pt_regs *regs)
  37. {
  38. unsigned int irq;
  39. struct pt_regs *old_regs = set_irq_regs(regs);
  40. irq_enter();
  41. irq = get_irq(regs);
  42. next_irq:
  43. BUG_ON(irq == -1U);
  44. generic_handle_irq(irq);
  45. irq = get_irq(regs);
  46. if (irq != -1U) {
  47. pr_debug("next irq: %d\n", irq);
  48. ++concurrent_irq;
  49. goto next_irq;
  50. }
  51. irq_exit();
  52. set_irq_regs(old_regs);
  53. }
  54. int show_interrupts(struct seq_file *p, void *v)
  55. {
  56. int i = *(loff_t *) v, j;
  57. struct irqaction *action;
  58. unsigned long flags;
  59. if (i == 0) {
  60. seq_printf(p, " ");
  61. for_each_online_cpu(j)
  62. seq_printf(p, "CPU%-8d", j);
  63. seq_putc(p, '\n');
  64. }
  65. if (i < nr_irq) {
  66. spin_lock_irqsave(&irq_desc[i].lock, flags);
  67. action = irq_desc[i].action;
  68. if (!action)
  69. goto skip;
  70. seq_printf(p, "%3d: ", i);
  71. #ifndef CONFIG_SMP
  72. seq_printf(p, "%10u ", kstat_irqs(i));
  73. #else
  74. for_each_online_cpu(j)
  75. seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
  76. #endif
  77. seq_printf(p, " %8s", irq_desc[i].status &
  78. IRQ_LEVEL ? "level" : "edge");
  79. seq_printf(p, " %8s", irq_desc[i].chip->name);
  80. seq_printf(p, " %s", action->name);
  81. for (action = action->next; action; action = action->next)
  82. seq_printf(p, ", %s", action->name);
  83. seq_putc(p, '\n');
  84. skip:
  85. spin_unlock_irqrestore(&irq_desc[i].lock, flags);
  86. }
  87. return 0;
  88. }