irq.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * linux/arch/arm/mach-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/interrupt.h>
  16. #include <asm/hardware.h>
  17. #include <asm/mach/irq.h>
  18. #include <asm/irq.h>
  19. #include <asm/io.h>
  20. #define INTC_REVISION 0x0000
  21. #define INTC_SYSCONFIG 0x0010
  22. #define INTC_SYSSTATUS 0x0014
  23. #define INTC_CONTROL 0x0048
  24. #define INTC_MIR_CLEAR0 0x0088
  25. #define INTC_MIR_SET0 0x008c
  26. /*
  27. * OMAP2 has a number of different interrupt controllers, each interrupt
  28. * controller is identified as its own "bank". Register definitions are
  29. * fairly consistent for each bank, but not all registers are implemented
  30. * for each bank.. when in doubt, consult the TRM.
  31. */
  32. static struct omap_irq_bank {
  33. unsigned long base_reg;
  34. unsigned int nr_irqs;
  35. } __attribute__ ((aligned(4))) irq_banks[] = {
  36. {
  37. /* MPU INTC */
  38. .base_reg = OMAP24XX_IC_BASE,
  39. .nr_irqs = 96,
  40. }, {
  41. /* XXX: DSP INTC */
  42. }
  43. };
  44. /* XXX: FIQ and additional INTC support (only MPU at the moment) */
  45. static void omap_ack_irq(unsigned int irq)
  46. {
  47. omap_writel(0x1, irq_banks[0].base_reg + INTC_CONTROL);
  48. }
  49. static void omap_mask_irq(unsigned int irq)
  50. {
  51. int offset = (irq >> 5) << 5;
  52. if (irq >= 64) {
  53. irq %= 64;
  54. } else if (irq >= 32) {
  55. irq %= 32;
  56. }
  57. omap_writel(1 << irq, irq_banks[0].base_reg + INTC_MIR_SET0 + offset);
  58. }
  59. static void omap_unmask_irq(unsigned int irq)
  60. {
  61. int offset = (irq >> 5) << 5;
  62. if (irq >= 64) {
  63. irq %= 64;
  64. } else if (irq >= 32) {
  65. irq %= 32;
  66. }
  67. omap_writel(1 << irq, irq_banks[0].base_reg + INTC_MIR_CLEAR0 + offset);
  68. }
  69. static void omap_mask_ack_irq(unsigned int irq)
  70. {
  71. omap_mask_irq(irq);
  72. omap_ack_irq(irq);
  73. }
  74. static struct irq_chip omap_irq_chip = {
  75. .name = "INTC",
  76. .ack = omap_mask_ack_irq,
  77. .mask = omap_mask_irq,
  78. .unmask = omap_unmask_irq,
  79. };
  80. static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
  81. {
  82. unsigned long tmp;
  83. tmp = omap_readl(bank->base_reg + INTC_REVISION) & 0xff;
  84. printk(KERN_INFO "IRQ: Found an INTC at 0x%08lx "
  85. "(revision %ld.%ld) with %d interrupts\n",
  86. bank->base_reg, tmp >> 4, tmp & 0xf, bank->nr_irqs);
  87. tmp = omap_readl(bank->base_reg + INTC_SYSCONFIG);
  88. tmp |= 1 << 1; /* soft reset */
  89. omap_writel(tmp, bank->base_reg + INTC_SYSCONFIG);
  90. while (!(omap_readl(bank->base_reg + INTC_SYSSTATUS) & 0x1))
  91. /* Wait for reset to complete */;
  92. }
  93. void __init omap_init_irq(void)
  94. {
  95. unsigned long nr_irqs = 0;
  96. unsigned int nr_banks = 0;
  97. int i;
  98. for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
  99. struct omap_irq_bank *bank = irq_banks + i;
  100. /* XXX */
  101. if (!bank->base_reg)
  102. continue;
  103. omap_irq_bank_init_one(bank);
  104. nr_irqs += bank->nr_irqs;
  105. nr_banks++;
  106. }
  107. printk(KERN_INFO "Total of %ld interrupts on %d active controller%s\n",
  108. nr_irqs, nr_banks, nr_banks > 1 ? "s" : "");
  109. for (i = 0; i < nr_irqs; i++) {
  110. set_irq_chip(i, &omap_irq_chip);
  111. set_irq_handler(i, handle_level_irq);
  112. set_irq_flags(i, IRQF_VALID);
  113. }
  114. }