influenceAnalysisOfCableAging.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software
  14. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. * 02110-1301, USA.
  16. */
  17. #ifndef __ARCH_ARM_MACH_MSM_IOMMU_HW_8XXX_H
  18. #define __ARCH_ARM_MACH_MSM_IOMMU_HW_8XXX_H
  19. #define CTX_SHIFT 12
  20. #define GET_GLOBAL_REG(reg, base) (readl((base) + (reg)))
  21. #define GET_CTX_REG(reg, base, ctx) \
  22. (readl((base) + (reg) + ((ctx) << CTX_SHIFT)))
  23. #define SET_GLOBAL_REG(reg, base, val) writel((val), ((base) + (reg)))
  24. #define SET_CTX_REG(reg, base, ctx, val) \
  25. writel((val), ((base) + (reg) + ((ctx) << CTX_SHIFT)))
  26. /* Wrappers for numbered registers */
  27. #define SET_GLOBAL_REG_N(b, n, r, v) SET_GLOBAL_REG(b, ((r) + (n << 2)), (v))
  28. #define GET_GLOBAL_REG_N(b, n, r) GET_GLOBAL_REG(b, ((r) + (n << 2)))
  29. /* Field wrappers */
  30. #define GET_GLOBAL_FIELD(b, r, F) GET_FIELD(((b) + (r)), F##_MASK, F##_SHIFT)
  31. #define GET_CONTEXT_FIELD(b, c, r, F) \
  32. GET_FIELD(((b) + (r) + ((c) << CTX_SHIFT)), F##_MASK, F##_SHIFT)
  33. #define SET_GLOBAL_FIELD(b, r, F, v) \
  34. SET_FIELD(((b) + (r)), F##_MASK, F##_SHIFT, (v))
  35. #define SET_CONTEXT_FIELD(b, c, r, F, v) \
  36. SET_FIELD(((b) + (r) + ((c) << CTX_SHIFT)), F##_MASK, F##_SHIFT, (v))
  37. #define GET_FIELD(addr, mask, shift) ((readl(addr) >> (shift)) & (mask))
  38. #define SET_FIELD(addr, mask, shift, v) \
  39. do { \
  40. int t = readl(addr); \
  41. writel((t & ~((mask) << (shift))) + (((v) & (mask)) << (shift)), addr);\
  42. } while (0)
  43. #define NUM_FL_PTE 4096
  44. #define NUM_SL_PTE 256
  45. #define NUM_TEX_CLASS 8
  46. /* First-level page table bits */
  47. #define FL_BASE_MASK 0xFFFFFC00
  48. #define FL_TYPE_TABLE (1 << 0)
  49. #define FL_TYPE_SECT (2 << 0)
  50. #define FL_SUPERSECTION (1 << 18)
  51. #define FL_AP_WRITE (1 << 10)
  52. #define FL_AP_READ (1 << 11)
  53. #define FL_SHARED (1 << 16)
  54. #define FL_BUFFERABLE (1 << 2)
  55. #define FL_CACHEABLE (1 << 3)
  56. #define FL_TEX0 (1 << 12)
  57. #define FL_OFFSET(va) (((va) & 0xFFF00000) >> 20)
  58. #define FL_NG (1 << 17)
  59. /* Second-level page table bits */
  60. #define SL_BASE_MASK_LARGE 0xFFFF0000
  61. #define SL_BASE_MASK_SMALL 0xFFFFF000
  62. #define SL_TYPE_LARGE (1 << 0)
  63. #define SL_TYPE_SMALL (2 << 0)
  64. #define SL_AP0 (1 << 4)
  65. #define SL_AP1 (2 << 4)
  66. #define SL_SHARED (1 << 10)
  67. #define SL_BUFFERABLE (1 << 2)
  68. #define SL_CACHEABLE (1 << 3)
  69. #define SL_TEX0 (1 << 6)
  70. #define SL_OFFSET(va) (((va) & 0xFF000) >> 12)
  71. #define SL_NG (1 << 11)
  72. /* Memory type and cache policy attributes */
  73. #define MT_SO 0
  74. #define MT_DEV 1
  75. #define MT_NORMAL 2
  76. #define CP_NONCACHED 0
  77. #define CP_WB_WA 1
  78. #define CP_WT 2
  79. #define CP_WB_NWA 3
  80. /* Global register setters / getters */
  81. #define SET_M2VCBR_N(b, N, v) SET_GLOBAL_REG_N(M2VCBR_N, N, (b), (v))
  82. #define SET_CBACR_N(b, N, v) SET_GLOBAL_REG_N(CBACR_N, N, (b), (v))
  83. #define SET_TLBRSW(b, v) SET_GLOBAL_REG(TLBRSW, (b), (v))
  84. #define SET_TLBTR0(b, v) SET_GLOBAL_REG(TLBTR0, (b), (v))
  85. #define SET_TLBTR1(b, v) SET_GLOBAL_REG(TLBTR1, (b), (v))
  86. #define SET_TLBTR2(b, v) SET_GLOBAL_REG(TLBTR2, (b), (v))
  87. #define SET_TESTBUSCR(b, v) SET_GLOBAL_REG(TESTBUSCR, (b), (v))
  88. #define SET_GLOBAL_TLBIALL(b, v) SET_GLOBAL_REG(GLOBAL_TLBIALL, (b), (v))
  89. #define SET_TLBIVMID(b, v) SET_GLOBAL_REG(TLBIVMID, (b), (v))
  90. #define SET_CR(b, v) SET_GLOBAL_REG(CR, (b), (v))
  91. #define SET_EAR(b, v) SET_GLOBAL_REG(EAR, (b), (v))
  92. #define SET_ESR(b, v) SET_GLOBAL_REG(ESR, (b), (v))
  93. #define SET_ESRRESTORE(b, v) SET_GLOBAL_REG(ESRRESTORE, (b), (v))
  94. #define SET_ESYNR0(b, v) SET_GLOBAL_REG(ESYNR0, (b), (v))
  95. #define SET_ESYNR1(b, v) SET_GLOBAL_REG(ESYNR1, (b), (v))
  96. #define SET_RPU_ACR(b, v) SET_GLOBAL_REG(RPU_ACR, (b), (v))
  97. #define GET_M2VCBR_N(b, N) GET_GLOBAL_REG_N(M2VCBR_N, N, (b))
  98. #define GET_CBACR_N(b, N) GET_GLOBAL_REG_N(CBACR_N, N, (b))
  99. #define GET_TLBTR0(b) GET_GLOBAL_REG(TLBTR0, (b))
  100. #define GET_TLBTR1(b) GET_GLOBAL_REG(TLBTR1, (b))
  101. #define GET_TLBTR2(b) GET_GLOBAL_REG(TLBTR2, (b))
  102. #define GET_TESTBUSCR(b) GET_GLOBAL_REG(TESTBUSCR, (b))
  103. #define GET_GLOBAL_TLBIALL(b) GET_GLOBAL_REG(GLOBAL_TLBIALL, (b))
  104. #define GET_TLBIVMID(b) GET_GLOBAL_REG(TLBIVMID, (b))
  105. #define GET_CR(b) GET_GLOBAL_REG(CR, (b))
  106. #define GET_EAR(b) GET_GLOBAL_REG(EAR, (b))
  107. #define GET_ESR(b) GET_GLOBAL_REG(ESR, (b))
  108. #define GET_ESRRESTORE(b) GET_GLOBAL_REG(ESRRESTORE, (b))
  109. #define GET_ESYNR0(b) GET_GLOBAL_REG(ESYNR0, (b))
  110. #define GET_ESYNR1(b) GET_GLOBAL_REG(ESYNR1, (b))
  111. #define GET_REV(b) GET_GLOBAL_REG(REV, (b))
  112. #define GET_IDR(b) GET_GLOBAL_REG(IDR, (b))
  113. #define GET_RPU_ACR(b) GET_GLOBAL_REG(RPU_ACR, (b))
  114. /* Context register setters/getters */
  115. #define SET_SCTLR(b, c, v) SET_CTX_REG(SCTLR, (b), (c), (v))
  116. #define SET_ACTLR(b, c, v) SET_CTX_REG(ACTLR, (b), (c), (v))
  117. #define SET_CONTEXTIDR(b, c, v) SET_CTX_REG(CONTEXTIDR, (b), (c), (v))
  118. #define SET_TTBR0(b, c, v) SET_CTX_REG(TTBR0, (b), (c), (v))
  119. #define SET_TTBR1(b, c, v) SET_CTX_REG(TTBR1, (b), (c), (v))
  120. #define SET_TTBCR(b, c, v) SET_CTX_REG(TTBCR, (b), (c), (v))
  121. #define SET_PAR(b, c, v) SET_CTX_REG(PAR, (b), (c), (v))
  122. #define SET_FSR(b, c, v) SET_CTX_REG(FSR, (b), (c), (v))
  123. #define SET_FSRRESTORE(b, c, v) SET_CTX_REG(FSRRESTORE, (b), (c), (v))
  124. #define SET_FAR(b, c, v) SET_CTX_REG(FAR, (b), (c), (v))
  125. #define SET_FSYNR0(b, c, v) SET_CTX_REG(FSYNR0, (b), (c), (v))
  126. #define SET_FSYNR1(b, c, v) SET_CTX_REG(FSYNR1, (b), (c), (v))
  127. #define SET_PRRR(b, c, v) SET_CTX_REG(PRRR, (b), (c), (v))
  128. #define SET_NMRR(b, c, v) SET_CTX_REG(NMRR, (b), (c), (v))
  129. #define SET_TLBLKCR(b, c, v) SET_CTX_REG(TLBLCKR, (b), (c), (v))
  130. #define SET_V2PSR(b, c, v) SET_CTX_REG(V2PSR, (b), (c), (v))
  131. #define SET_TLBFLPTER(b, c, v) SET_CTX_REG(TLBFLPTER, (b), (c), (v))
  132. #define SET_TLBSLPTER(b, c, v) SET_CTX_REG(TLBSLPTER, (b), (c), (v))
  133. #define SET_BFBCR(b, c, v) SET_CTX_REG(BFBCR, (b), (c), (v))
  134. #define SET_CTX_TLBIALL(b, c, v) SET_CTX_REG(CTX_TLBIALL, (b), (c), (v))
  135. #define SET_TLBIASID(b, c, v) SET_CTX_REG(TLBIASID, (b), (c), (v))
  136. #define SET_TLBIVA(b, c, v) SET_CTX_REG(TLBIVA, (b), (c), (v))
  137. #define SET_TLBIVAA(b, c, v) SET_CTX_REG(TLBIVAA, (b), (c), (v))
  138. #define SET_V2PPR(b, c, v) SET_CTX_REG(V2PPR, (b), (c), (v))
  139. #define SET_V2PPW(b, c, v) SET_CTX_REG(V2PPW, (b), (c), (v))
  140. #define SET_V2PUR(b, c, v) SET_CTX_REG(V2PUR, (b), (c), (v))
  141. #define SET_V2PUW(b, c, v) SET_CTX_REG(V2PUW, (b), (c), (v))
  142. #define SET_RESUME(b, c, v) SET_CTX_REG(RESUME, (b), (c), (v))
  143. #define GET_SCTLR(b, c) GET_CTX_REG(SCTLR, (b), (c))
  144. #define GET_ACTLR(b, c) GET_CTX_REG(ACTLR, (b), (c))
  145. #define GET_CONTEXTIDR(b, c) GET_CTX_REG(CONTEXTIDR, (b), (c))
  146. #define GET_TTBR0(b, c) GET_CTX_REG(TTBR0, (b), (c))
  147. #define GET_TTBR1(b, c) GET_CTX_REG(TTBR1, (b), (c))
  148. #define GET_TTBCR(b, c) GET_CTX_REG(TTBCR, (b), (c))
  149. #define GET_PAR(b, c) GET_CTX_REG(PAR, (b), (c))
  150. #define GET_FSR(b, c) GET_CTX_REG(FSR, (b), (c))
  151. #define GET_FSRRESTORE(b, c) GET_CTX_REG(FSRRESTORE, (b), (c))
  152. #define GET_FAR(b, c) GET_CTX_REG(FAR, (b), (c))
  153. #define GET_FSYNR0(b, c) GET_CTX_REG(FSYNR0, (b), (c))
  154. #define GET_FSYNR1(b, c) GET_CTX_REG(FSYNR1, (b), (c))
  155. #define GET_PRRR(b, c) GET_CTX_REG(PRRR, (b), (c))
  156. #define GET_NMRR(b, c) GET_CTX_REG(NMRR, (b), (c))
  157. #define GET_TLBLCKR(b, c) GET_CTX_REG(TLBLCKR, (b), (c))
  158. #define GET_V2PSR(b, c) GET_CTX_REG(V2PSR, (b), (c))
  159. #define GET_TLBFLPTER(b, c) GET_CTX_REG(TLBFLPTER, (b), (c))
  160. #define GET_TLBSLPTER(b, c) GET_CTX_REG(TLBSLPTER, (b), (c))
  161. #define GET_BFBCR(b, c) GET_CTX_REG(BFBCR, (b), (c))