irq.c 2.8 KB

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