irq.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. 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. spin_lock(&desc->lock);
  68. desc->status &= ~IRQ_INPROGRESS;
  69. if (desc->status & IRQ_DISABLED)
  70. out_mask:
  71. desc->chip->mask(irq);
  72. /* ack unconditionally to unmask lower prio irqs */
  73. desc->chip->ack(irq);
  74. spin_unlock(&desc->lock);
  75. }
  76. #define handle_irq handle_prio_irq
  77. #endif
  78. void __init ns9xxx_init_irq(void)
  79. {
  80. int i;
  81. /* disable all IRQs */
  82. for (i = 0; i < 8; ++i)
  83. __raw_writel((4 * i) << 24 | (4 * i + 1) << 16 |
  84. (4 * i + 2) << 8 | (4 * i + 3), SYS_IC(i));
  85. /* simple interrupt prio table:
  86. * prio(x) < prio(y) <=> x < y
  87. */
  88. for (i = 0; i < 32; ++i)
  89. __raw_writel(i, SYS_IVA(i));
  90. for (i = 0; i <= 31; ++i) {
  91. set_irq_chip(i, &ns9xxx_chip);
  92. set_irq_handler(i, handle_irq);
  93. set_irq_flags(i, IRQF_VALID);
  94. }
  95. }