synchronousMemoryDatabase.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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/module.h>
  15. #include <linux/init.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/io.h>
  18. #include <asm/exception.h>
  19. #include <asm/mach/irq.h>
  20. #include <linux/irqdomain.h>
  21. #include <linux/of.h>
  22. #include <linux/of_address.h>
  23. #include <linux/of_irq.h>
  24. #include "soc.h"
  25. #include "iomap.h"
  26. #include "common.h"
  27. /* selected INTC register offsets */
  28. #define INTC_REVISION 0x0000
  29. #define INTC_SYSCONFIG 0x0010
  30. #define INTC_SYSSTATUS 0x0014
  31. #define INTC_SIR 0x0040
  32. #define INTC_CONTROL 0x0048
  33. #define INTC_PROTECTION 0x004C
  34. #define INTC_IDLE 0x0050
  35. #define INTC_THRESHOLD 0x0068
  36. #define INTC_MIR0 0x0084
  37. #define INTC_MIR_CLEAR0 0x0088
  38. #define INTC_MIR_SET0 0x008c
  39. #define INTC_PENDING_IRQ0 0x0098
  40. /* Number of IRQ state bits in each MIR register */
  41. #define IRQ_BITS_PER_REG 32
  42. #define OMAP2_IRQ_BASE OMAP2_L4_IO_ADDRESS(OMAP24XX_IC_BASE)
  43. #define OMAP3_IRQ_BASE OMAP2_L4_IO_ADDRESS(OMAP34XX_IC_BASE)
  44. #define INTCPS_SIR_IRQ_OFFSET 0x0040 /* omap2/3 active interrupt offset */
  45. #define ACTIVEIRQ_MASK 0x7f /* omap2/3 active interrupt bits */
  46. #define INTCPS_NR_MIR_REGS 3
  47. #define INTCPS_NR_IRQS 96
  48. /*
  49. * OMAP2 has a number of different interrupt controllers, each interrupt
  50. * controller is identified as its own "bank". Register definitions are
  51. * fairly consistent for each bank, but not all registers are implemented
  52. * for each bank.. when in doubt, consult the TRM.
  53. */
  54. static struct omap_irq_bank {
  55. void __iomem *base_reg;
  56. unsigned int nr_irqs;
  57. } __attribute__ ((aligned(4))) irq_banks[] = {
  58. {
  59. /* MPU INTC */
  60. .nr_irqs = 96,
  61. },
  62. };
  63. static struct irq_domain *domain;
  64. /* Structure to save interrupt controller context */
  65. struct omap3_intc_regs {
  66. u32 sysconfig;
  67. u32 protection;
  68. u32 idle;
  69. u32 threshold;
  70. u32 ilr[INTCPS_NR_IRQS];
  71. u32 mir[INTCPS_NR_MIR_REGS];
  72. };
  73. /* INTC bank register get/set */
  74. static void intc_bank_write_reg(u32 val, struct omap_irq_bank *bank, u16 reg)
  75. {
  76. __raw_writel(val, bank->base_reg + reg);
  77. }
  78. static u32 intc_bank_read_reg(struct omap_irq_bank *bank, u16 reg)
  79. {
  80. return __raw_readl(bank->base_reg + reg);
  81. }
  82. /* XXX: FIQ and additional INTC support (only MPU at the moment) */
  83. static void omap_ack_irq(struct irq_data *d)
  84. {
  85. intc_bank_write_reg(0x1, &irq_banks[0], INTC_CONTROL);
  86. }
  87. static void omap_mask_ack_irq(struct irq_data *d)
  88. {
  89. irq_gc_mask_disable_reg(d);
  90. omap_ack_irq(d);
  91. }
  92. static void __init omap_irq_bank_init_one(struct omap_irq_bank *bank)
  93. {
  94. unsigned long tmp;
  95. tmp = intc_bank_read_reg(bank, INTC_REVISION) & 0xff;
  96. pr_info("IRQ: Found an INTC at 0x%p (revision %ld.%ld) with %d interrupts\n",
  97. bank->base_reg, tmp >> 4, tmp & 0xf, bank->nr_irqs);
  98. tmp = intc_bank_read_reg(bank, INTC_SYSCONFIG);
  99. tmp |= 1 << 1; /* soft reset */
  100. intc_bank_write_reg(tmp, bank, INTC_SYSCONFIG);
  101. while (!(intc_bank_read_reg(bank, INTC_SYSSTATUS) & 0x1))
  102. /* Wait for reset to complete */;
  103. /* Enable autoidle */
  104. intc_bank_write_reg(1 << 0, bank, INTC_SYSCONFIG);
  105. }
  106. int omap_irq_pending(void)
  107. {