irq.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * arch/arm/mach-ns9xxx/irq.c
  3. *
  4. * Copyright (C) 2006,2007 by Digi International Inc.
  5. * All rights reserved.
  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 version 2 as published by
  9. * the Free Software Foundation.
  10. */
  11. #include <linux/interrupt.h>
  12. #include <linux/kernel_stat.h>
  13. #include <linux/io.h>
  14. #include <asm/mach/irq.h>
  15. #include <mach/regs-sys-common.h>
  16. #include <mach/irqs.h>
  17. #include <mach/board.h>
  18. #include "generic.h"
  19. /* simple interrupt prio table: prio(x) < prio(y) <=> x < y */
  20. #define irq2prio(i) (i)
  21. #define prio2irq(p) (p)
  22. static void ns9xxx_mask_irq(unsigned int irq)
  23. {
  24. /* XXX: better use cpp symbols */
  25. int prio = irq2prio(irq);
  26. u32 ic = __raw_readl(SYS_IC(prio / 4));
  27. ic &= ~(1 << (7 + 8 * (3 - (prio & 3))));
  28. __raw_writel(ic, SYS_IC(prio / 4));
  29. }
  30. static void ns9xxx_ack_irq(unsigned int irq)
  31. {
  32. __raw_writel(0, SYS_ISRADDR);
  33. }
  34. static void ns9xxx_maskack_irq(unsigned int irq)
  35. {
  36. ns9xxx_mask_irq(irq);
  37. ns9xxx_ack_irq(irq);
  38. }
  39. static void ns9xxx_unmask_irq(unsigned int irq)
  40. {
  41. /* XXX: better use cpp symbols */
  42. int prio = irq2prio(irq);
  43. u32 ic = __raw_readl(SYS_IC(prio / 4));
  44. ic |= 1 << (7 + 8 * (3 - (prio & 3)));
  45. __raw_writel(ic, SYS_IC(prio / 4));
  46. }
  47. static struct irq_chip ns9xxx_chip = {
  48. .ack = ns9xxx_ack_irq,
  49. .mask = ns9xxx_mask_irq,
  50. .mask_ack = ns9xxx_maskack_irq,
  51. .unmask = ns9xxx_unmask_irq,
  52. };
  53. #if 0
  54. #define handle_irq handle_level_irq
  55. #else
  56. static void handle_prio_irq(unsigned int irq, struct irq_desc *desc)
  57. {
  58. unsigned int cpu = smp_processor_id();
  59. struct irqaction *action;
  60. irqreturn_t action_ret;
  61. spin_lock(&desc->lock);
  62. BUG_ON(desc->status & IRQ_INPROGRESS);
  63. desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
  64. kstat_cpu(cpu).irqs[irq]++;
  65. action = desc->action;
  66. if (unlikely(!action || (desc->status & IRQ_DISABLED)))
  67. goto out_mask;
  68. desc->status |= IRQ_INPROGRESS;
  69. spin_unlock(&desc->lock);
  70. action_ret = handle_IRQ_event(irq, action);
  71. /* XXX: There is no direct way to access noirqdebug, so check
  72. * unconditionally for spurious irqs...
  73. * Maybe this function should go to kernel/irq/chip.c? */
  74. note_interrupt(irq, desc, action_ret);
  75. spin_lock(&desc->lock);
  76. desc->status &= ~IRQ_INPROGRESS;
  77. if (desc->status & IRQ_DISABLED)
  78. out_mask:
  79. desc->chip->mask(irq);
  80. /* ack unconditionally to unmask lower prio irqs */
  81. desc->chip->ack(irq);
  82. spin_unlock(&desc->lock);
  83. }
  84. #define handle_irq handle_prio_irq
  85. #endif
  86. void __init ns9xxx_init_irq(void)
  87. {
  88. int i;
  89. /* disable all IRQs */
  90. for (i = 0; i < 8; ++i)
  91. __raw_writel(prio2irq(4 * i) << 24 |
  92. prio2irq(4 * i + 1) << 16 |
  93. prio2irq(4 * i + 2) << 8 |
  94. prio2irq(4 * i + 3),
  95. SYS_IC(i));
  96. for (i = 0; i < 32; ++i)
  97. __raw_writel(prio2irq(i), SYS_IVA(i));
  98. for (i = 0; i <= 31; ++i) {
  99. set_irq_chip(i, &ns9xxx_chip);
  100. set_irq_handler(i, handle_irq);
  101. set_irq_flags(i, IRQF_VALID);
  102. }
  103. }