entry-macro.S 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* arch/arm/mach-tegra/include/mach/entry-macro.S
  2. *
  3. * Copyright (C) 2009 Palm, Inc.
  4. *
  5. * This software is licensed under the terms of the GNU General Public
  6. * License version 2, as published by the Free Software Foundation, and
  7. * may be copied, distributed, and modified under those terms.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. */
  15. #include <mach/iomap.h>
  16. #include <mach/io.h>
  17. #if defined(CONFIG_ARM_GIC)
  18. #include <asm/hardware/gic.h>
  19. /* Uses the GIC interrupt controller built into the cpu */
  20. #define ICTRL_BASE (IO_CPU_VIRT + 0x100)
  21. .macro disable_fiq
  22. .endm
  23. .macro get_irqnr_preamble, base, tmp
  24. movw \base, #(ICTRL_BASE & 0x0000ffff)
  25. movt \base, #((ICTRL_BASE & 0xffff0000) >> 16)
  26. .endm
  27. .macro arch_ret_to_user, tmp1, tmp2
  28. .endm
  29. /*
  30. * The interrupt numbering scheme is defined in the
  31. * interrupt controller spec. To wit:
  32. *
  33. * Interrupts 0-15 are IPI
  34. * 16-28 are reserved
  35. * 29-31 are local. We allow 30 to be used for the watchdog.
  36. * 32-1020 are global
  37. * 1021-1022 are reserved
  38. * 1023 is "spurious" (no interrupt)
  39. *
  40. * For now, we ignore all local interrupts so only return an interrupt
  41. * if it's between 30 and 1020. The test_for_ipi routine below will
  42. * pick up on IPIs.
  43. *
  44. * A simple read from the controller will tell us the number of the
  45. * highest priority enabled interrupt. We then just need to check
  46. * whether it is in the valid range for an IRQ (30-1020 inclusive).
  47. */
  48. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  49. /* bits 12-10 = src CPU, 9-0 = int # */
  50. ldr \irqstat, [\base, #GIC_CPU_INTACK]
  51. ldr \tmp, =1021
  52. bic \irqnr, \irqstat, #0x1c00
  53. cmp \irqnr, #29
  54. cmpcc \irqnr, \irqnr
  55. cmpne \irqnr, \tmp
  56. cmpcs \irqnr, \irqnr
  57. .endm
  58. /* We assume that irqstat (the raw value of the IRQ acknowledge
  59. * register) is preserved from the macro above.
  60. * If there is an IPI, we immediately signal end of interrupt on the
  61. * controller, since this requires the original irqstat value which
  62. * we won't easily be able to recreate later.
  63. */
  64. .macro test_for_ipi, irqnr, irqstat, base, tmp
  65. bic \irqnr, \irqstat, #0x1c00
  66. cmp \irqnr, #16
  67. strcc \irqstat, [\base, #GIC_CPU_EOI]
  68. cmpcs \irqnr, \irqnr
  69. .endm
  70. /* As above, this assumes that irqstat and base are preserved.. */
  71. .macro test_for_ltirq, irqnr, irqstat, base, tmp
  72. bic \irqnr, \irqstat, #0x1c00
  73. mov \tmp, #0
  74. cmp \irqnr, #29
  75. moveq \tmp, #1
  76. streq \irqstat, [\base, #GIC_CPU_EOI]
  77. cmp \tmp, #0
  78. .endm
  79. #else
  80. /* legacy interrupt controller for AP16 */
  81. .macro disable_fiq
  82. .endm
  83. .macro get_irqnr_preamble, base, tmp
  84. @ enable imprecise aborts
  85. cpsie a
  86. @ EVP base at 0xf010f000
  87. mov \base, #0xf0000000
  88. orr \base, #0x00100000
  89. orr \base, #0x0000f000
  90. .endm
  91. .macro arch_ret_to_user, tmp1, tmp2
  92. .endm
  93. .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
  94. ldr \irqnr, [\base, #0x20] @ EVT_IRQ_STS
  95. cmp \irqnr, #0x80
  96. .endm
  97. #endif