entry-macro.S 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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. .pushsection .data
  35. omap_irq_base: .word 0
  36. .popsection
  37. /* Configure the interrupt base on the first interrupt */
  38. .macro get_irqnr_preamble, base, tmp
  39. 9:
  40. ldr \base, =omap_irq_base @ irq base address
  41. ldr \base, [\base, #0] @ irq base value
  42. cmp \base, #0 @ already configured?
  43. bne 9997f @ nothing to do
  44. mrc p15, 0, \tmp, c0, c0, 0 @ get processor revision
  45. and \tmp, \tmp, #0x000f0000 @ only check architecture
  46. cmp \tmp, #0x00070000 @ is v6?
  47. beq 2400f @ found v6 so it's omap24xx
  48. mrc p15, 0, \tmp, c0, c0, 0 @ get processor revision
  49. and \tmp, \tmp, #0x000000f0 @ check cortex 8 or 9
  50. cmp \tmp, #0x00000080 @ cortex A-8?
  51. beq 3400f @ found A-8 so it's omap34xx
  52. cmp \tmp, #0x00000090 @ cortex A-9?
  53. beq 4400f @ found A-9 so it's omap44xx
  54. 2400: ldr \base, =OMAP2_IRQ_BASE
  55. ldr \tmp, =omap_irq_base
  56. str \base, [\tmp, #0]
  57. b 9b
  58. 3400: ldr \base, =OMAP3_IRQ_BASE
  59. ldr \tmp, =omap_irq_base
  60. str \base, [\tmp, #0]
  61. b 9b
  62. 4400: ldr \base, =OMAP4_IRQ_BASE
  63. ldr \tmp, =omap_irq_base
  64. str \base, [\tmp, #0]
  65. b 9b
  66. 9997:
  67. .endm
  68. /* Check the pending interrupts. Note that base already set */
  69. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  70. tst \base, #0x100 @ gic address?
  71. bne 4401f @ found gic
  72. /* Handle omap2 and omap3 */
  73. ldr \irqnr, [\base, #0x98] /* IRQ pending reg 1 */
  74. cmp \irqnr, #0x0
  75. bne 9998f
  76. ldr \irqnr, [\base, #0xb8] /* IRQ pending reg 2 */
  77. cmp \irqnr, #0x0
  78. bne 9998f
  79. ldr \irqnr, [\base, #0xd8] /* IRQ pending reg 3 */
  80. cmp \irqnr, #0x0
  81. 9998:
  82. ldrne \irqnr, [\base, #INTCPS_SIR_IRQ_OFFSET]
  83. and \irqnr, \irqnr, #ACTIVEIRQ_MASK /* Clear spurious bits */
  84. b 9999f
  85. /* Handle omap4 */
  86. 4401: ldr \irqstat, [\base, #GIC_CPU_INTACK]
  87. ldr \tmp, =1021
  88. bic \irqnr, \irqstat, #0x1c00
  89. cmp \irqnr, #29
  90. cmpcc \irqnr, \irqnr
  91. cmpne \irqnr, \tmp
  92. cmpcs \irqnr, \irqnr
  93. 9999:
  94. .endm
  95. #else /* MULTI_OMAP2 */
  96. /*
  97. * Optimized irq functions for omap2, 3 and 4
  98. */
  99. #if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3)
  100. .macro get_irqnr_preamble, base, tmp
  101. #ifdef CONFIG_ARCH_OMAP2
  102. ldr \base, =OMAP2_IRQ_BASE
  103. #else
  104. ldr \base, =OMAP3_IRQ_BASE
  105. #endif
  106. .endm
  107. /* Check the pending interrupts. Note that base already set */
  108. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  109. ldr \irqnr, [\base, #0x98] /* IRQ pending reg 1 */
  110. cmp \irqnr, #0x0
  111. bne 9999f
  112. ldr \irqnr, [\base, #0xb8] /* IRQ pending reg 2 */
  113. cmp \irqnr, #0x0
  114. bne 9999f
  115. ldr \irqnr, [\base, #0xd8] /* IRQ pending reg 3 */
  116. cmp \irqnr, #0x0
  117. 9999:
  118. ldrne \irqnr, [\base, #INTCPS_SIR_IRQ_OFFSET]
  119. and \irqnr, \irqnr, #ACTIVEIRQ_MASK /* Clear spurious bits */
  120. .endm
  121. #endif
  122. #ifdef CONFIG_ARCH_OMAP4
  123. .macro get_irqnr_preamble, base, tmp
  124. ldr \base, =OMAP4_IRQ_BASE
  125. .endm
  126. /*
  127. * The interrupt numbering scheme is defined in the
  128. * interrupt controller spec. To wit:
  129. *
  130. * Interrupts 0-15 are IPI
  131. * 16-28 are reserved
  132. * 29-31 are local. We allow 30 to be used for the watchdog.
  133. * 32-1020 are global
  134. * 1021-1022 are reserved
  135. * 1023 is "spurious" (no interrupt)
  136. *
  137. * For now, we ignore all local interrupts so only return an
  138. * interrupt if it's between 30 and 1020. The test_for_ipi
  139. * routine below will pick up on IPIs.
  140. * A simple read from the controller will tell us the number
  141. * of the highest priority enabled interrupt.
  142. * We then just need to check whether it is in the
  143. * valid range for an IRQ (30-1020 inclusive).
  144. */
  145. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  146. ldr \irqstat, [\base, #GIC_CPU_INTACK]
  147. ldr \tmp, =1021
  148. bic \irqnr, \irqstat, #0x1c00
  149. cmp \irqnr, #29
  150. cmpcc \irqnr, \irqnr
  151. cmpne \irqnr, \tmp
  152. cmpcs \irqnr, \irqnr
  153. .endm
  154. #endif
  155. #endif /* MULTI_OMAP2 */
  156. #ifdef CONFIG_SMP
  157. /* We assume that irqstat (the raw value of the IRQ acknowledge
  158. * register) is preserved from the macro above.
  159. * If there is an IPI, we immediately signal end of interrupt
  160. * on the controller, since this requires the original irqstat
  161. * value which we won't easily be able to recreate later.
  162. */
  163. .macro test_for_ipi, irqnr, irqstat, base, tmp
  164. bic \irqnr, \irqstat, #0x1c00
  165. cmp \irqnr, #16
  166. it cc
  167. strcc \irqstat, [\base, #GIC_CPU_EOI]
  168. it cs
  169. cmpcs \irqnr, \irqnr
  170. .endm
  171. /* As above, this assumes that irqstat and base are preserved */
  172. .macro test_for_ltirq, irqnr, irqstat, base, tmp
  173. bic \irqnr, \irqstat, #0x1c00
  174. mov \tmp, #0
  175. cmp \irqnr, #29
  176. itt eq
  177. moveq \tmp, #1
  178. streq \irqstat, [\base, #GIC_CPU_EOI]
  179. cmp \tmp, #0
  180. .endm
  181. #endif /* CONFIG_SMP */
  182. .macro irq_prio_table
  183. .endm