irq.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * linux/arch/arm/mach-omap/omap2/irq.c
  3. *
  4. * Interrupt handler for OMAP2 boards.
  5. *
  6. * Copyright (C) 2005 Nokia Corporation
  7. * Author: Paul Mundt <paul.mundt@nokia.com>
  8. *
  9. * This file is subject to the terms and conditions of the GNU General Public
  10. * License. See the file "COPYING" in the main directory of this archive
  11. * for more details.
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/config.h>
  16. #include <linux/interrupt.h>
  17. #include <asm/hardware.h>
  18. #include <asm/mach/irq.h>
  19. #include <asm/irq.h>
  20. #include <asm/io.h>
  21. #define INTC_REVISION 0x0000
  22. #define INTC_SYSCONFIG 0x0010
  23. #define INTC_SYSSTATUS 0x0014
  24. #define INTC_CONTROL 0x0048
  25. #define INTC_MIR_CLEAR0 0x0088
  26. #define INTC_MIR_SET0 0x008c
  27. /*
  28. * OMAP2 has a number of different interrupt controllers, each interrupt
  29. * controller is identified as its own "bank". Register definitions are
  30. * fairly consistent for each bank, but not all registers are implemented
  31. * for each bank.. when in doubt, consult the TRM.
  32. */
  33. static struct omap_irq_bank {
  34. unsigned long base_reg;
  35. unsigned int nr_irqs;
  36. } __attribute__ ((aligned(4))) irq_banks[] = {
  37. {
  38. /* MPU INTC */
  39. .base_reg = OMAP24XX_IC_BASE,
  40. .nr_irqs = 96,
  41. }, {
  42. /* XXX: DSP INTC */
  43. #if 0
  44. /*
  45. * Commented out for now until we fix the IVA clocking
  46. */
  47. #ifdef CONFIG_ARCH_OMAP2420
  48. }, {
  49. /* IVA INTC (2420 only) */
  50. .base_reg = OMAP24XX_IVA_INTC_BASE,
  51. .nr_irqs = 16, /* Actually 32, but only 16 are used */
  52. #endif
  53. #endif
  54. }
  55. };
  56. /* XXX: FIQ and additional INTC support (only MPU at the moment) */
  57. static void omap_ack_irq(unsigned int irq)
  58. {
  59. omap_writel(0x1, irq_banks[0].base_reg + INTC_CONTROL);
  60. }
  61. static void omap_mask_irq(unsigned int irq)
  62. {
  63. int offset = (irq >> 5) << 5;
  64. if (irq >= 64) {
  65. irq %= 64;
  66. } else if (irq >= 32) {
  67. irq %= 32;
  68. }
  69. omap_writel(1 << irq, irq_banks[0].base_reg + INTC_MIR_SET0 + offset);
  70. }
  71. static void omap_unmask_irq(unsigned int irq)
  72. {
  73. int offset = (irq >> 5) << 5;
  74. if (irq >= 64) {
  75. irq %= 64;
  76. } else if (irq >= 32) {
  77. irq %= 32;
  78. }
  79. omap_writel(1 << irq, irq_banks[0].base_reg + INTC_MIR_CLEAR0 + offset);
  80. }
  81. static void omap_mask_ack_irq(unsigned int irq)
  82. {
  83. omap_mask_irq(irq);
  84. omap_ack_irq(irq);
  85. }
  86. static struct irqchip omap_irq_chip = {
  87. .ack = omap_mask_ack_irq,
  88. .mask = omap_mask_irq,
  89. .unmask = omap_unmask_irq,
  90. };
  91. static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
  92. {
  93. unsigned long tmp;
  94. tmp = omap_readl(bank->base_reg + INTC_REVISION) & 0xff;
  95. printk(KERN_INFO "IRQ: Found an INTC at 0x%08lx "
  96. "(revision %ld.%ld) with %d interrupts\n",
  97. bank->base_reg, tmp >> 4, tmp & 0xf, bank->nr_irqs);
  98. tmp = omap_readl(bank->base_reg + INTC_SYSCONFIG);
  99. tmp |= 1 << 1; /* soft reset */
  100. omap_writel(tmp, bank->base_reg + INTC_SYSCONFIG);
  101. while (!(omap_readl(bank->base_reg + INTC_SYSSTATUS) & 0x1))
  102. /* Wait for reset to complete */;
  103. }
  104. void __init omap_init_irq(void)
  105. {
  106. unsigned long nr_irqs = 0;
  107. unsigned int nr_banks = 0;
  108. int i;
  109. for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
  110. struct omap_irq_bank *bank = irq_banks + i;
  111. /* XXX */
  112. if (!bank->base_reg)
  113. continue;
  114. omap_irq_bank_init_one(bank);
  115. nr_irqs += bank->nr_irqs;
  116. nr_banks++;
  117. }
  118. printk(KERN_INFO "Total of %ld interrupts on %d active controller%s\n",
  119. nr_irqs, nr_banks, nr_banks > 1 ? "s" : "");
  120. for (i = 0; i < nr_irqs; i++) {
  121. set_irq_chip(i, &omap_irq_chip);
  122. set_irq_handler(i, do_level_IRQ);
  123. set_irq_flags(i, IRQF_VALID);
  124. }
  125. }