entry-macro.S 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. #include <plat/multi.h>
  21. #define OMAP2_IRQ_BASE OMAP2_L4_IO_ADDRESS(OMAP24XX_IC_BASE)
  22. #define OMAP3_IRQ_BASE OMAP2_L4_IO_ADDRESS(OMAP34XX_IC_BASE)
  23. #define OMAP4_IRQ_BASE OMAP2_L4_IO_ADDRESS(OMAP44XX_GIC_CPU_BASE)
  24. #define INTCPS_SIR_IRQ_OFFSET 0x0040 /* omap2/3 active interrupt offset */
  25. #define ACTIVEIRQ_MASK 0x7f /* omap2/3 active interrupt bits */
  26. .macro disable_fiq
  27. .endm
  28. .macro arch_ret_to_user, tmp1, tmp2
  29. .endm
  30. /*
  31. * Unoptimized irq functions for multi-omap2, 3 and 4
  32. */
  33. #ifdef MULTI_OMAP2
  34. /*
  35. * We use __glue to avoid errors with multiple definitions of
  36. * .globl omap_irq_base as it's included from entry-armv.S but not
  37. * from entry-common.S.
  38. */
  39. #ifdef __glue
  40. .pushsection .data
  41. .globl omap_irq_base
  42. omap_irq_base:
  43. .word 0
  44. .popsection
  45. #endif
  46. /*
  47. * Configure the interrupt base on the first interrupt.
  48. * See also omap_irq_base_init for setting omap_irq_base.
  49. */
  50. .macro get_irqnr_preamble, base, tmp
  51. ldr \base, =omap_irq_base @ irq base address
  52. ldr \base, [\base, #0] @ irq base value
  53. .endm
  54. /* Check the pending interrupts. Note that base already set */
  55. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  56. tst \base, #0x100 @ gic address?
  57. bne 4401f @ found gic
  58. /* Handle omap2 and omap3 */
  59. ldr \irqnr, [\base, #0x98] /* IRQ pending reg 1 */
  60. cmp \irqnr, #0x0
  61. bne 9998f
  62. ldr \irqnr, [\base, #0xb8] /* IRQ pending reg 2 */
  63. cmp \irqnr, #0x0
  64. bne 9998f
  65. ldr \irqnr, [\base, #0xd8] /* IRQ pending reg 3 */
  66. cmp \irqnr, #0x0
  67. 9998:
  68. ldrne \irqnr, [\base, #INTCPS_SIR_IRQ_OFFSET]
  69. and \irqnr, \irqnr, #ACTIVEIRQ_MASK /* Clear spurious bits */
  70. b 9999f
  71. /* Handle omap4 */
  72. 4401: ldr \irqstat, [\base, #GIC_CPU_INTACK]
  73. ldr \tmp, =1021
  74. bic \irqnr, \irqstat, #0x1c00
  75. cmp \irqnr, #29
  76. cmpcc \irqnr, \irqnr
  77. cmpne \irqnr, \tmp
  78. cmpcs \irqnr, \irqnr
  79. 9999:
  80. .endm
  81. #else /* MULTI_OMAP2 */
  82. /*
  83. * Optimized irq functions for omap2, 3 and 4
  84. */
  85. #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
  86. .macro get_irqnr_preamble, base, tmp
  87. #ifdef CONFIG_ARCH_OMAP2
  88. ldr \base, =OMAP2_IRQ_BASE
  89. #else
  90. ldr \base, =OMAP3_IRQ_BASE
  91. #endif
  92. .endm
  93. /* Check the pending interrupts. Note that base already set */
  94. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  95. ldr \irqnr, [\base, #0x98] /* IRQ pending reg 1 */
  96. cmp \irqnr, #0x0
  97. bne 9999f
  98. ldr \irqnr, [\base, #0xb8] /* IRQ pending reg 2 */
  99. cmp \irqnr, #0x0
  100. bne 9999f
  101. ldr \irqnr, [\base, #0xd8] /* IRQ pending reg 3 */
  102. cmp \irqnr, #0x0
  103. 9999:
  104. ldrne \irqnr, [\base, #INTCPS_SIR_IRQ_OFFSET]
  105. and \irqnr, \irqnr, #ACTIVEIRQ_MASK /* Clear spurious bits */
  106. .endm
  107. #endif
  108. #ifdef CONFIG_ARCH_OMAP4
  109. .macro get_irqnr_preamble, base, tmp
  110. ldr \base, =OMAP4_IRQ_BASE
  111. .endm
  112. /*
  113. * The interrupt numbering scheme is defined in the
  114. * interrupt controller spec. To wit:
  115. *
  116. * Interrupts 0-15 are IPI
  117. * 16-28 are reserved
  118. * 29-31 are local. We allow 30 to be used for the watchdog.
  119. * 32-1020 are global
  120. * 1021-1022 are reserved
  121. * 1023 is "spurious" (no interrupt)
  122. *
  123. * For now, we ignore all local interrupts so only return an
  124. * interrupt if it's between 30 and 1020. The test_for_ipi
  125. * routine below will pick up on IPIs.
  126. * A simple read from the controller will tell us the number
  127. * of the highest priority enabled interrupt.
  128. * We then just need to check whether it is in the
  129. * valid range for an IRQ (30-1020 inclusive).
  130. */
  131. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  132. ldr \irqstat, [\base, #GIC_CPU_INTACK]
  133. ldr \tmp, =1021
  134. bic \irqnr, \irqstat, #0x1c00
  135. cmp \irqnr, #29
  136. cmpcc \irqnr, \irqnr
  137. cmpne \irqnr, \tmp
  138. cmpcs \irqnr, \irqnr
  139. .endm
  140. #endif
  141. #endif /* MULTI_OMAP2 */
  142. #ifdef CONFIG_SMP
  143. /* We assume that irqstat (the raw value of the IRQ acknowledge
  144. * register) is preserved from the macro above.
  145. * If there is an IPI, we immediately signal end of interrupt
  146. * on the controller, since this requires the original irqstat
  147. * value which we won't easily be able to recreate later.
  148. */
  149. .macro test_for_ipi, irqnr, irqstat, base, tmp
  150. bic \irqnr, \irqstat, #0x1c00
  151. cmp \irqnr, #16
  152. it cc
  153. strcc \irqstat, [\base, #GIC_CPU_EOI]
  154. it cs
  155. cmpcs \irqnr, \irqnr
  156. .endm
  157. /* As above, this assumes that irqstat and base are preserved */
  158. .macro test_for_ltirq, irqnr, irqstat, base, tmp
  159. bic \irqnr, \irqstat, #0x1c00
  160. mov \tmp, #0
  161. cmp \irqnr, #29
  162. itt eq
  163. moveq \tmp, #1
  164. streq \irqstat, [\base, #GIC_CPU_EOI]
  165. cmp \tmp, #0
  166. .endm
  167. #endif /* CONFIG_SMP */
  168. .macro irq_prio_table
  169. .endm