entry-macro.S 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * arch/arm/plat-omap/include/mach/entry-macro.S
  3. *
  4. * Low-level IRQ helper macros for OMAP-based platforms
  5. *
  6. * Copyright (C) 2009 Texas Instruments
  7. * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
  8. *
  9. * This file is licensed under the terms of the GNU General Public
  10. * License version 2. This program is licensed "as is" without any
  11. * warranty of any kind, whether express or implied.
  12. */
  13. #include <mach/hardware.h>
  14. #include <mach/io.h>
  15. #include <mach/irqs.h>
  16. #include <asm/hardware/gic.h>
  17. #include <plat/omap24xx.h>
  18. #include <plat/omap34xx.h>
  19. #include <plat/omap44xx.h>
  20. #define OMAP2_IRQ_BASE OMAP2_L4_IO_ADDRESS(OMAP24XX_IC_BASE)
  21. #define OMAP3_IRQ_BASE OMAP2_L4_IO_ADDRESS(OMAP34XX_IC_BASE)
  22. #define OMAP4_IRQ_BASE OMAP2_L4_IO_ADDRESS(OMAP44XX_GIC_CPU_BASE)
  23. #define INTCPS_SIR_IRQ_OFFSET 0x0040 /* omap2/3 active interrupt offset */
  24. #define ACTIVEIRQ_MASK 0x7f /* omap2/3 active interrupt bits */
  25. .macro disable_fiq
  26. .endm
  27. .macro arch_ret_to_user, tmp1, tmp2
  28. .endm
  29. #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
  30. .pushsection .data
  31. omap_irq_base: .word 0
  32. .popsection
  33. #if defined(CONFIG_ARCH_OMAP2) && defined(CONFIG_ARCH_OMAP3)
  34. /* Configure the interrupt base on the first interrupt */
  35. .macro get_irqnr_preamble, base, tmp
  36. 9:
  37. ldr \base, =omap_irq_base @ irq base address
  38. ldr \base, [\base, #0] @ irq base value
  39. cmp \base, #0 @ already configured?
  40. bne 9998f @ nothing to do
  41. mrc p15, 0, \tmp, c0, c0, 0 @ get processor revision
  42. and \tmp, \tmp, #0x000f0000 @ only check architecture
  43. cmp \tmp, #0x00060000 @ is v6?
  44. beq 2400f @ found v6 so it's omap24xx
  45. cmp \tmp, #0x000f0000 @ is cortex?
  46. beq 3400f @ found v7 so it's omap34xx
  47. 2400: ldr \base, =OMAP2_IRQ_BASE
  48. ldr \tmp, =omap_irq_base
  49. str \base, [\tmp, #0]
  50. b 9b
  51. 3400: ldr \base, =OMAP3_IRQ_BASE
  52. ldr \tmp, =omap_irq_base
  53. str \base, [\tmp, #0]
  54. b 9b
  55. 9998:
  56. .endm
  57. #else
  58. .macro get_irqnr_preamble, base, tmp
  59. #ifdef CONFIG_ARCH_OMAP2
  60. ldr \base, =OMAP2_IRQ_BASE
  61. #else
  62. ldr \base, =OMAP3_IRQ_BASE
  63. #endif
  64. .endm
  65. #endif
  66. /* Check the pending interrupts. Note that base already set */
  67. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  68. ldr \irqnr, [\base, #0x98] /* IRQ pending reg 1 */
  69. cmp \irqnr, #0x0
  70. bne 9999f
  71. ldr \irqnr, [\base, #0xb8] /* IRQ pending reg 2 */
  72. cmp \irqnr, #0x0
  73. bne 9999f
  74. ldr \irqnr, [\base, #0xd8] /* IRQ pending reg 3 */
  75. cmp \irqnr, #0x0
  76. 9999:
  77. ldrne \irqnr, [\base, #INTCPS_SIR_IRQ_OFFSET]
  78. and \irqnr, \irqnr, #ACTIVEIRQ_MASK /* Clear spurious bits */
  79. .endm
  80. #endif
  81. #ifdef CONFIG_ARCH_OMAP4
  82. .macro get_irqnr_preamble, base, tmp
  83. .endm
  84. /*
  85. * The interrupt numbering scheme is defined in the
  86. * interrupt controller spec. To wit:
  87. *
  88. * Interrupts 0-15 are IPI
  89. * 16-28 are reserved
  90. * 29-31 are local. We allow 30 to be used for the watchdog.
  91. * 32-1020 are global
  92. * 1021-1022 are reserved
  93. * 1023 is "spurious" (no interrupt)
  94. *
  95. * For now, we ignore all local interrupts so only return an
  96. * interrupt if it's between 30 and 1020. The test_for_ipi
  97. * routine below will pick up on IPIs.
  98. * A simple read from the controller will tell us the number
  99. * of the highest priority enabled interrupt.
  100. * We then just need to check whether it is in the
  101. * valid range for an IRQ (30-1020 inclusive).
  102. */
  103. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  104. ldr \base, =OMAP4_IRQ_BASE
  105. ldr \irqstat, [\base, #GIC_CPU_INTACK]
  106. ldr \tmp, =1021
  107. bic \irqnr, \irqstat, #0x1c00
  108. cmp \irqnr, #29
  109. cmpcc \irqnr, \irqnr
  110. cmpne \irqnr, \tmp
  111. cmpcs \irqnr, \irqnr
  112. .endm
  113. /* We assume that irqstat (the raw value of the IRQ acknowledge
  114. * register) is preserved from the macro above.
  115. * If there is an IPI, we immediately signal end of interrupt
  116. * on the controller, since this requires the original irqstat
  117. * value which we won't easily be able to recreate later.
  118. */
  119. .macro test_for_ipi, irqnr, irqstat, base, tmp
  120. bic \irqnr, \irqstat, #0x1c00
  121. cmp \irqnr, #16
  122. it cc
  123. strcc \irqstat, [\base, #GIC_CPU_EOI]
  124. it cs
  125. cmpcs \irqnr, \irqnr
  126. .endm
  127. /* As above, this assumes that irqstat and base are preserved */
  128. .macro test_for_ltirq, irqnr, irqstat, base, tmp
  129. bic \irqnr, \irqstat, #0x1c00
  130. mov \tmp, #0
  131. cmp \irqnr, #29
  132. itt eq
  133. moveq \tmp, #1
  134. streq \irqstat, [\base, #GIC_CPU_EOI]
  135. cmp \tmp, #0
  136. .endm
  137. #endif
  138. .macro irq_prio_table
  139. .endm