irq.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. if (unlikely(desc->status & IRQ_INPROGRESS))
  59. goto out_unlock;
  60. desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
  61. kstat_cpu(cpu).irqs[irq]++;
  62. action = desc->action;
  63. if (unlikely(!action || (desc->status & IRQ_DISABLED)))
  64. goto out_unlock;
  65. desc->status |= IRQ_INPROGRESS;
  66. spin_unlock(&desc->lock);
  67. action_ret = handle_IRQ_event(irq, action);
  68. spin_lock(&desc->lock);
  69. desc->status &= ~IRQ_INPROGRESS;
  70. if (!(desc->status & IRQ_DISABLED) && desc->chip->ack)
  71. desc->chip->ack(irq);
  72. out_unlock:
  73. spin_unlock(&desc->lock);
  74. }
  75. #define handle_irq handle_prio_irq
  76. #endif
  77. void __init ns9xxx_init_irq(void)
  78. {
  79. int i;
  80. /* disable all IRQs */
  81. for (i = 0; i < 8; ++i)
  82. __raw_writel((4 * i) << 24 | (4 * i + 1) << 16 |
  83. (4 * i + 2) << 8 | (4 * i + 3), SYS_IC(i));
  84. /* simple interrupt prio table:
  85. * prio(x) < prio(y) <=> x < y
  86. */
  87. for (i = 0; i < 32; ++i)
  88. __raw_writel(i, SYS_IVA(i));
  89. for (i = 0; i <= 31; ++i) {
  90. set_irq_chip(i, &ns9xxx_chip);
  91. set_irq_handler(i, handle_irq);
  92. set_irq_flags(i, IRQF_VALID);
  93. }
  94. }