gic.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2000, 07 MIPS Technologies, Inc.
  7. *
  8. * GIC Register Definitions
  9. *
  10. */
  11. #ifndef _ASM_GICREGS_H
  12. #define _ASM_GICREGS_H
  13. #undef GICISBYTELITTLEENDIAN
  14. #define GICISWORDLITTLEENDIAN
  15. /* Constants */
  16. #define GIC_POL_POS 1
  17. #define GIC_POL_NEG 0
  18. #define GIC_TRIG_EDGE 1
  19. #define GIC_TRIG_LEVEL 0
  20. #define GIC_NUM_INTRS 32
  21. #define MSK(n) ((1 << (n)) - 1)
  22. #define REG32(addr) (*(volatile unsigned int *) (addr))
  23. #define REG(base, offs) REG32((unsigned long)(base) + offs##_##OFS)
  24. #define REGP(base, phys) REG32((unsigned long)(base) + (phys))
  25. /* Accessors */
  26. #define GIC_REG(segment, offset) \
  27. REG32(_gic_base + segment##_##SECTION_OFS + offset##_##OFS)
  28. #define GIC_REG_ADDR(segment, offset) \
  29. REG32(_gic_base + segment##_##SECTION_OFS + offset)
  30. #define GIC_ABS_REG(segment, offset) \
  31. (_gic_base + segment##_##SECTION_OFS + offset##_##OFS)
  32. #define GIC_REG_ABS_ADDR(segment, offset) \
  33. (_gic_base + segment##_##SECTION_OFS + offset)
  34. #ifdef GICISBYTELITTLEENDIAN
  35. #define GICREAD(reg, data) (data) = (reg), (data) = le32_to_cpu(data)
  36. #define GICWRITE(reg, data) (reg) = cpu_to_le32(data)
  37. #define GICBIS(reg, bits) \
  38. ({unsigned int data; \
  39. GICREAD(reg, data); \
  40. data |= bits; \
  41. GICWRITE(reg, data); \
  42. })
  43. #else
  44. #define GICREAD(reg, data) (data) = (reg)
  45. #define GICWRITE(reg, data) (reg) = (data)
  46. #define GICBIS(reg, bits) (reg) |= (bits)
  47. #endif
  48. /* GIC Address Space */
  49. #define SHARED_SECTION_OFS 0x0000
  50. #define SHARED_SECTION_SIZE 0x8000
  51. #define VPE_LOCAL_SECTION_OFS 0x8000
  52. #define VPE_LOCAL_SECTION_SIZE 0x4000
  53. #define VPE_OTHER_SECTION_OFS 0xc000
  54. #define VPE_OTHER_SECTION_SIZE 0x4000
  55. #define USM_VISIBLE_SECTION_OFS 0x10000
  56. #define USM_VISIBLE_SECTION_SIZE 0x10000
  57. /* Register Map for Shared Section */
  58. #if defined(CONFIG_CPU_LITTLE_ENDIAN) || defined(GICISWORDLITTLEENDIAN)
  59. #define GIC_SH_CONFIG_OFS 0x0000
  60. /* Shared Global Counter */
  61. #define GIC_SH_COUNTER_31_00_OFS 0x0010
  62. #define GIC_SH_COUNTER_63_32_OFS 0x0014
  63. /* Interrupt Polarity */
  64. #define GIC_SH_POL_31_0_OFS 0x0100
  65. #define GIC_SH_POL_63_32_OFS 0x0104
  66. #define GIC_SH_POL_95_64_OFS 0x0108
  67. #define GIC_SH_POL_127_96_OFS 0x010c
  68. #define GIC_SH_POL_159_128_OFS 0x0110
  69. #define GIC_SH_POL_191_160_OFS 0x0114
  70. #define GIC_SH_POL_223_192_OFS 0x0118
  71. #define GIC_SH_POL_255_224_OFS 0x011c
  72. /* Edge/Level Triggering */
  73. #define GIC_SH_TRIG_31_0_OFS 0x0180
  74. #define GIC_SH_TRIG_63_32_OFS 0x0184
  75. #define GIC_SH_TRIG_95_64_OFS 0x0188
  76. #define GIC_SH_TRIG_127_96_OFS 0x018c
  77. #define GIC_SH_TRIG_159_128_OFS 0x0190
  78. #define GIC_SH_TRIG_191_160_OFS 0x0194
  79. #define GIC_SH_TRIG_223_192_OFS 0x0198
  80. #define GIC_SH_TRIG_255_224_OFS 0x019c
  81. /* Dual Edge Triggering */
  82. #define GIC_SH_DUAL_31_0_OFS 0x0200
  83. #define GIC_SH_DUAL_63_32_OFS 0x0204
  84. #define GIC_SH_DUAL_95_64_OFS 0x0208
  85. #define GIC_SH_DUAL_127_96_OFS 0x020c
  86. #define GIC_SH_DUAL_159_128_OFS 0x0210
  87. #define GIC_SH_DUAL_191_160_OFS 0x0214
  88. #define GIC_SH_DUAL_223_192_OFS 0x0218
  89. #define GIC_SH_DUAL_255_224_OFS 0x021c
  90. /* Set/Clear corresponding bit in Edge Detect Register */
  91. #define GIC_SH_WEDGE_OFS 0x0280
  92. /* Reset Mask - Disables Interrupt */
  93. #define GIC_SH_RMASK_31_0_OFS 0x0300
  94. #define GIC_SH_RMASK_63_32_OFS 0x0304
  95. #define GIC_SH_RMASK_95_64_OFS 0x0308
  96. #define GIC_SH_RMASK_127_96_OFS 0x030c
  97. #define GIC_SH_RMASK_159_128_OFS 0x0310
  98. #define GIC_SH_RMASK_191_160_OFS 0x0314
  99. #define GIC_SH_RMASK_223_192_OFS 0x0318
  100. #define GIC_SH_RMASK_255_224_OFS 0x031c
  101. /* Set Mask (WO) - Enables Interrupt */
  102. #define GIC_SH_SMASK_31_0_OFS 0x0380
  103. #define GIC_SH_SMASK_63_32_OFS 0x0384
  104. #define GIC_SH_SMASK_95_64_OFS 0x0388
  105. #define GIC_SH_SMASK_127_96_OFS 0x038c
  106. #define GIC_SH_SMASK_159_128_OFS 0x0390
  107. #define GIC_SH_SMASK_191_160_OFS 0x0394
  108. #define GIC_SH_SMASK_223_192_OFS 0x0398
  109. #define GIC_SH_SMASK_255_224_OFS 0x039c
  110. /* Global Interrupt Mask Register (RO) - Bit Set == Interrupt enabled */
  111. #define GIC_SH_MASK_31_0_OFS 0x0400
  112. #define GIC_SH_MASK_63_32_OFS 0x0404
  113. #define GIC_SH_MASK_95_64_OFS 0x0408
  114. #define GIC_SH_MASK_127_96_OFS 0x040c
  115. #define GIC_SH_MASK_159_128_OFS 0x0410
  116. #define GIC_SH_MASK_191_160_OFS 0x0414
  117. #define GIC_SH_MASK_223_192_OFS 0x0418
  118. #define GIC_SH_MASK_255_224_OFS 0x041c
  119. /* Pending Global Interrupts (RO) */
  120. #define GIC_SH_PEND_31_0_OFS 0x0480
  121. #define GIC_SH_PEND_63_32_OFS 0x0484
  122. #define GIC_SH_PEND_95_64_OFS 0x0488
  123. #define GIC_SH_PEND_127_96_OFS 0x048c
  124. #define GIC_SH_PEND_159_128_OFS 0x0490
  125. #define GIC_SH_PEND_191_160_OFS 0x0494
  126. #define GIC_SH_PEND_223_192_OFS 0x0498
  127. #define GIC_SH_PEND_255_224_OFS 0x049c
  128. #define GIC_SH_INTR_MAP_TO_PIN_BASE_OFS 0x0500
  129. /* Maps Interrupt X to a Pin */
  130. #define GIC_SH_MAP_TO_PIN(intr) \
  131. (GIC_SH_INTR_MAP_TO_PIN_BASE_OFS + (4 * intr))
  132. #define GIC_SH_INTR_MAP_TO_VPE_BASE_OFS 0x2000
  133. /* Maps Interrupt X to a VPE */
  134. #define GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe) \
  135. (GIC_SH_INTR_MAP_TO_VPE_BASE_OFS + (32 * (intr)) + (((vpe) / 32) * 4))
  136. #define GIC_SH_MAP_TO_VPE_REG_BIT(vpe) (1 << ((vpe) % 32))
  137. /* Polarity : Reset Value is always 0 */
  138. #define GIC_SH_SET_POLARITY_OFS 0x0100
  139. #define GIC_SET_POLARITY(intr, pol) \
  140. GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_POLARITY_OFS + (((intr) / 32) * 4)), (pol) << ((intr) % 32))
  141. /* Triggering : Reset Value is always 0 */
  142. #define GIC_SH_SET_TRIGGER_OFS 0x0180
  143. #define GIC_SET_TRIGGER(intr, trig) \
  144. GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_TRIGGER_OFS + (((intr) / 32) * 4)), (trig) << ((intr) % 32))
  145. /* Mask manipulation */
  146. #define GIC_SH_SMASK_OFS 0x0380
  147. #define GIC_SET_INTR_MASK(intr, val) \
  148. GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_SMASK_OFS + (((intr) / 32) * 4)), ((val) << ((intr) % 32)))
  149. #define GIC_SH_RMASK_OFS 0x0300
  150. #define GIC_CLR_INTR_MASK(intr, val) \
  151. GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_RMASK_OFS + (((intr) / 32) * 4)), ((val) << ((intr) % 32)))
  152. /* Register Map for Local Section */
  153. #define GIC_VPE_CTL_OFS 0x0000
  154. #define GIC_VPE_PEND_OFS 0x0004
  155. #define GIC_VPE_MASK_OFS 0x0008
  156. #define GIC_VPE_RMASK_OFS 0x000c
  157. #define GIC_VPE_SMASK_OFS 0x0010
  158. #define GIC_VPE_WD_MAP_OFS 0x0040
  159. #define GIC_VPE_COMPARE_MAP_OFS 0x0044
  160. #define GIC_VPE_TIMER_MAP_OFS 0x0048
  161. #define GIC_VPE_PERFCTR_MAP_OFS 0x0050
  162. #define GIC_VPE_SWINT0_MAP_OFS 0x0054
  163. #define GIC_VPE_SWINT1_MAP_OFS 0x0058
  164. #define GIC_VPE_OTHER_ADDR_OFS 0x0080
  165. #define GIC_VPE_WD_CONFIG0_OFS 0x0090
  166. #define GIC_VPE_WD_COUNT0_OFS 0x0094
  167. #define GIC_VPE_WD_INITIAL0_OFS 0x0098
  168. #define GIC_VPE_COMPARE_LO_OFS 0x00a0
  169. #define GIC_VPE_COMPARE_HI 0x00a4
  170. #define GIC_VPE_EIC_SHADOW_SET_BASE 0x0100
  171. #define GIC_VPE_EIC_SS(intr) \
  172. (GIC_EIC_SHADOW_SET_BASE + (4 * intr))
  173. #define GIC_VPE_EIC_VEC_BASE 0x0800
  174. #define GIC_VPE_EIC_VEC(intr) \
  175. (GIC_VPE_EIC_VEC_BASE + (4 * intr))
  176. #define GIC_VPE_TENABLE_NMI_OFS 0x1000
  177. #define GIC_VPE_TENABLE_YQ_OFS 0x1004
  178. #define GIC_VPE_TENABLE_INT_31_0_OFS 0x1080
  179. #define GIC_VPE_TENABLE_INT_63_32_OFS 0x1084
  180. /* User Mode Visible Section Register Map */
  181. #define GIC_UMV_SH_COUNTER_31_00_OFS 0x0000
  182. #define GIC_UMV_SH_COUNTER_63_32_OFS 0x0004
  183. #else /* CONFIG_CPU_BIG_ENDIAN */
  184. #define GIC_SH_CONFIG_OFS 0x0000
  185. /* Shared Global Counter */
  186. #define GIC_SH_COUNTER_31_00_OFS 0x0014
  187. #define GIC_SH_COUNTER_63_32_OFS 0x0010
  188. /* Interrupt Polarity */
  189. #define GIC_SH_POL_31_0_OFS 0x0104
  190. #define GIC_SH_POL_63_32_OFS 0x0100
  191. #define GIC_SH_POL_95_64_OFS 0x010c
  192. #define GIC_SH_POL_127_96_OFS 0x0108
  193. #define GIC_SH_POL_159_128_OFS 0x0114
  194. #define GIC_SH_POL_191_160_OFS 0x0110
  195. #define GIC_SH_POL_223_192_OFS 0x011c
  196. #define GIC_SH_POL_255_224_OFS 0x0118
  197. /* Edge/Level Triggering */
  198. #define GIC_SH_TRIG_31_0_OFS 0x0184
  199. #define GIC_SH_TRIG_63_32_OFS 0x0180
  200. #define GIC_SH_TRIG_95_64_OFS 0x018c
  201. #define GIC_SH_TRIG_127_96_OFS 0x0188
  202. #define GIC_SH_TRIG_159_128_OFS 0x0194
  203. #define GIC_SH_TRIG_191_160_OFS 0x0190
  204. #define GIC_SH_TRIG_223_192_OFS 0x019c
  205. #define GIC_SH_TRIG_255_224_OFS 0x0198
  206. /* Dual Edge Triggering */
  207. #define GIC_SH_DUAL_31_0_OFS 0x0204
  208. #define GIC_SH_DUAL_63_32_OFS 0x0200
  209. #define GIC_SH_DUAL_95_64_OFS 0x020c
  210. #define GIC_SH_DUAL_127_96_OFS 0x0208
  211. #define GIC_SH_DUAL_159_128_OFS 0x0214
  212. #define GIC_SH_DUAL_191_160_OFS 0x0210
  213. #define GIC_SH_DUAL_223_192_OFS 0x021c
  214. #define GIC_SH_DUAL_255_224_OFS 0x0218
  215. /* Set/Clear corresponding bit in Edge Detect Register */
  216. #define GIC_SH_WEDGE_OFS 0x0280
  217. /* Reset Mask - Disables Interrupt */
  218. #define GIC_SH_RMASK_31_0_OFS 0x0304
  219. #define GIC_SH_RMASK_63_32_OFS 0x0300
  220. #define GIC_SH_RMASK_95_64_OFS 0x030c
  221. #define GIC_SH_RMASK_127_96_OFS 0x0308
  222. #define GIC_SH_RMASK_159_128_OFS 0x0314
  223. #define GIC_SH_RMASK_191_160_OFS 0x0310
  224. #define GIC_SH_RMASK_223_192_OFS 0x031c
  225. #define GIC_SH_RMASK_255_224_OFS 0x0318
  226. /* Set Mask (WO) - Enables Interrupt */
  227. #define GIC_SH_SMASK_31_0_OFS 0x0384
  228. #define GIC_SH_SMASK_63_32_OFS 0x0380
  229. #define GIC_SH_SMASK_95_64_OFS 0x038c
  230. #define GIC_SH_SMASK_127_96_OFS 0x0388
  231. #define GIC_SH_SMASK_159_128_OFS 0x0394
  232. #define GIC_SH_SMASK_191_160_OFS 0x0390
  233. #define GIC_SH_SMASK_223_192_OFS 0x039c
  234. #define GIC_SH_SMASK_255_224_OFS 0x0398
  235. /* Global Interrupt Mask Register (RO) - Bit Set == Interrupt enabled */
  236. #define GIC_SH_MASK_31_0_OFS 0x0404
  237. #define GIC_SH_MASK_63_32_OFS 0x0400
  238. #define GIC_SH_MASK_95_64_OFS 0x040c
  239. #define GIC_SH_MASK_127_96_OFS 0x0408
  240. #define GIC_SH_MASK_159_128_OFS 0x0414
  241. #define GIC_SH_MASK_191_160_OFS 0x0410
  242. #define GIC_SH_MASK_223_192_OFS 0x041c
  243. #define GIC_SH_MASK_255_224_OFS 0x0418
  244. /* Pending Global Interrupts (RO) */
  245. #define GIC_SH_PEND_31_0_OFS 0x0484
  246. #define GIC_SH_PEND_63_32_OFS 0x0480
  247. #define GIC_SH_PEND_95_64_OFS 0x048c
  248. #define GIC_SH_PEND_127_96_OFS 0x0488
  249. #define GIC_SH_PEND_159_128_OFS 0x0494
  250. #define GIC_SH_PEND_191_160_OFS 0x0490
  251. #define GIC_SH_PEND_223_192_OFS 0x049c
  252. #define GIC_SH_PEND_255_224_OFS 0x0498
  253. #define GIC_SH_INTR_MAP_TO_PIN_BASE_OFS 0x0500
  254. /* Maps Interrupt X to a Pin */
  255. #define GIC_SH_MAP_TO_PIN(intr) \
  256. (GIC_SH_INTR_MAP_TO_PIN_BASE_OFS + (4 * intr))
  257. #define GIC_SH_INTR_MAP_TO_VPE_BASE_OFS 0x2004
  258. /*
  259. * Maps Interrupt X to a VPE. This is more complex than the LE case, as
  260. * odd and even registers need to be transposed. It does work - trust me!
  261. */
  262. #define GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe) \
  263. (GIC_SH_INTR_MAP_TO_VPE_BASE_OFS + (32 * (intr)) + \
  264. (((((vpe) / 32) ^ 1) - 1) * 4))
  265. #define GIC_SH_MAP_TO_VPE_REG_BIT(vpe) (1 << ((vpe) % 32))
  266. /* Polarity */
  267. #define GIC_SH_SET_POLARITY_OFS 0x0100
  268. #define GIC_SET_POLARITY(intr, pol) \
  269. GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_POLARITY_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), (pol) << ((intr) % 32))
  270. /* Triggering */
  271. #define GIC_SH_SET_TRIGGER_OFS 0x0180
  272. #define GIC_SET_TRIGGER(intr, trig) \
  273. GICBIS(GIC_REG_ADDR(SHARED, GIC_SH_SET_TRIGGER_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), (trig) << ((intr) % 32))
  274. /* Mask manipulation */
  275. #define GIC_SH_SMASK_OFS 0x0380
  276. #define GIC_SET_INTR_MASK(intr, val) \
  277. GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_SMASK_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), ((val) << ((intr) % 32)))
  278. #define GIC_SH_RMASK_OFS 0x0300
  279. #define GIC_CLR_INTR_MASK(intr, val) \
  280. GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_RMASK_OFS + 4 + (((((intr) / 32) ^ 1) - 1) * 4)), ((val) << ((intr) % 32)))
  281. /* Register Map for Local Section */
  282. #define GIC_VPE_CTL_OFS 0x0000
  283. #define GIC_VPE_PEND_OFS 0x0004
  284. #define GIC_VPE_MASK_OFS 0x0008
  285. #define GIC_VPE_RMASK_OFS 0x000c
  286. #define GIC_VPE_SMASK_OFS 0x0010
  287. #define GIC_VPE_WD_MAP_OFS 0x0040
  288. #define GIC_VPE_COMPARE_MAP_OFS 0x0044
  289. #define GIC_VPE_TIMER_MAP_OFS 0x0048
  290. #define GIC_VPE_PERFCTR_MAP_OFS 0x0050
  291. #define GIC_VPE_SWINT0_MAP_OFS 0x0054
  292. #define GIC_VPE_SWINT1_MAP_OFS 0x0058
  293. #define GIC_VPE_OTHER_ADDR_OFS 0x0080
  294. #define GIC_VPE_WD_CONFIG0_OFS 0x0090
  295. #define GIC_VPE_WD_COUNT0_OFS 0x0094
  296. #define GIC_VPE_WD_INITIAL0_OFS 0x0098
  297. #define GIC_VPE_COMPARE_LO_OFS 0x00a4
  298. #define GIC_VPE_COMPARE_HI_OFS 0x00a0
  299. #define GIC_VPE_EIC_SHADOW_SET_BASE 0x0100
  300. #define GIC_VPE_EIC_SS(intr) \
  301. (GIC_EIC_SHADOW_SET_BASE + (4 * intr))
  302. #define GIC_VPE_EIC_VEC_BASE 0x0800
  303. #define GIC_VPE_EIC_VEC(intr) \
  304. (GIC_VPE_EIC_VEC_BASE + (4 * intr))
  305. #define GIC_VPE_TENABLE_NMI_OFS 0x1000
  306. #define GIC_VPE_TENABLE_YQ_OFS 0x1004
  307. #define GIC_VPE_TENABLE_INT_31_0_OFS 0x1080
  308. #define GIC_VPE_TENABLE_INT_63_32_OFS 0x1084
  309. /* User Mode Visible Section Register Map */
  310. #define GIC_UMV_SH_COUNTER_31_00_OFS 0x0004
  311. #define GIC_UMV_SH_COUNTER_63_32_OFS 0x0000
  312. #endif /* !LE */
  313. /* Masks */
  314. #define GIC_SH_CONFIG_COUNTSTOP_SHF 28
  315. #define GIC_SH_CONFIG_COUNTSTOP_MSK (MSK(1) << GIC_SH_CONFIG_COUNTSTOP_SHF)
  316. #define GIC_SH_CONFIG_COUNTBITS_SHF 24
  317. #define GIC_SH_CONFIG_COUNTBITS_MSK (MSK(4) << GIC_SH_CONFIG_COUNTBITS_SHF)
  318. #define GIC_SH_CONFIG_NUMINTRS_SHF 16
  319. #define GIC_SH_CONFIG_NUMINTRS_MSK (MSK(8) << GIC_SH_CONFIG_NUMINTRS_SHF)
  320. #define GIC_SH_CONFIG_NUMVPES_SHF 0
  321. #define GIC_SH_CONFIG_NUMVPES_MSK (MSK(8) << GIC_SH_CONFIG_NUMVPES_SHF)
  322. #define GIC_SH_WEDGE_SET(intr) (intr | (0x1 << 31))
  323. #define GIC_SH_WEDGE_CLR(intr) (intr & ~(0x1 << 31))
  324. #define GIC_MAP_TO_PIN_SHF 31
  325. #define GIC_MAP_TO_PIN_MSK (MSK(1) << GIC_MAP_TO_PIN_SHF)
  326. #define GIC_MAP_TO_NMI_SHF 30
  327. #define GIC_MAP_TO_NMI_MSK (MSK(1) << GIC_MAP_TO_NMI_SHF)
  328. #define GIC_MAP_TO_YQ_SHF 29
  329. #define GIC_MAP_TO_YQ_MSK (MSK(1) << GIC_MAP_TO_YQ_SHF)
  330. #define GIC_MAP_SHF 0
  331. #define GIC_MAP_MSK (MSK(6) << GIC_MAP_SHF)
  332. /* GIC_VPE_CTL Masks */
  333. #define GIC_VPE_CTL_PERFCNT_RTBL_SHF 2
  334. #define GIC_VPE_CTL_PERFCNT_RTBL_MSK (MSK(1) << GIC_VPE_CTL_PERFCNT_RTBL_SHF)
  335. #define GIC_VPE_CTL_TIMER_RTBL_SHF 1
  336. #define GIC_VPE_CTL_TIMER_RTBL_MSK (MSK(1) << GIC_VPE_CTL_TIMER_RTBL_SHF)
  337. #define GIC_VPE_CTL_EIC_MODE_SHF 0
  338. #define GIC_VPE_CTL_EIC_MODE_MSK (MSK(1) << GIC_VPE_CTL_EIC_MODE_SHF)
  339. /* GIC_VPE_PEND Masks */
  340. #define GIC_VPE_PEND_WD_SHF 0
  341. #define GIC_VPE_PEND_WD_MSK (MSK(1) << GIC_VPE_PEND_WD_SHF)
  342. #define GIC_VPE_PEND_CMP_SHF 1
  343. #define GIC_VPE_PEND_CMP_MSK (MSK(1) << GIC_VPE_PEND_CMP_SHF)
  344. #define GIC_VPE_PEND_TIMER_SHF 2
  345. #define GIC_VPE_PEND_TIMER_MSK (MSK(1) << GIC_VPE_PEND_TIMER_SHF)
  346. #define GIC_VPE_PEND_PERFCOUNT_SHF 3
  347. #define GIC_VPE_PEND_PERFCOUNT_MSK (MSK(1) << GIC_VPE_PEND_PERFCOUNT_SHF)
  348. #define GIC_VPE_PEND_SWINT0_SHF 4
  349. #define GIC_VPE_PEND_SWINT0_MSK (MSK(1) << GIC_VPE_PEND_SWINT0_SHF)
  350. #define GIC_VPE_PEND_SWINT1_SHF 5
  351. #define GIC_VPE_PEND_SWINT1_MSK (MSK(1) << GIC_VPE_PEND_SWINT1_SHF)
  352. /* GIC_VPE_RMASK Masks */
  353. #define GIC_VPE_RMASK_WD_SHF 0
  354. #define GIC_VPE_RMASK_WD_MSK (MSK(1) << GIC_VPE_RMASK_WD_SHF)
  355. #define GIC_VPE_RMASK_CMP_SHF 1
  356. #define GIC_VPE_RMASK_CMP_MSK (MSK(1) << GIC_VPE_RMASK_CMP_SHF)
  357. #define GIC_VPE_RMASK_TIMER_SHF 2
  358. #define GIC_VPE_RMASK_TIMER_MSK (MSK(1) << GIC_VPE_RMASK_TIMER_SHF)
  359. #define GIC_VPE_RMASK_PERFCNT_SHF 3
  360. #define GIC_VPE_RMASK_PERFCNT_MSK (MSK(1) << GIC_VPE_RMASK_PERFCNT_SHF)
  361. #define GIC_VPE_RMASK_SWINT0_SHF 4
  362. #define GIC_VPE_RMASK_SWINT0_MSK (MSK(1) << GIC_VPE_RMASK_SWINT0_SHF)
  363. #define GIC_VPE_RMASK_SWINT1_SHF 5
  364. #define GIC_VPE_RMASK_SWINT1_MSK (MSK(1) << GIC_VPE_RMASK_SWINT1_SHF)
  365. /* GIC_VPE_SMASK Masks */
  366. #define GIC_VPE_SMASK_WD_SHF 0
  367. #define GIC_VPE_SMASK_WD_MSK (MSK(1) << GIC_VPE_SMASK_WD_SHF)
  368. #define GIC_VPE_SMASK_CMP_SHF 1
  369. #define GIC_VPE_SMASK_CMP_MSK (MSK(1) << GIC_VPE_SMASK_CMP_SHF)
  370. #define GIC_VPE_SMASK_TIMER_SHF 2
  371. #define GIC_VPE_SMASK_TIMER_MSK (MSK(1) << GIC_VPE_SMASK_TIMER_SHF)
  372. #define GIC_VPE_SMASK_PERFCNT_SHF 3
  373. #define GIC_VPE_SMASK_PERFCNT_MSK (MSK(1) << GIC_VPE_SMASK_PERFCNT_SHF)
  374. #define GIC_VPE_SMASK_SWINT0_SHF 4
  375. #define GIC_VPE_SMASK_SWINT0_MSK (MSK(1) << GIC_VPE_SMASK_SWINT0_SHF)
  376. #define GIC_VPE_SMASK_SWINT1_SHF 5
  377. #define GIC_VPE_SMASK_SWINT1_MSK (MSK(1) << GIC_VPE_SMASK_SWINT1_SHF)
  378. /*
  379. * Set the Mapping of Interrupt X to a VPE.
  380. */
  381. #define GIC_SH_MAP_TO_VPE_SMASK(intr, vpe) \
  382. GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_MAP_TO_VPE_REG_OFF(intr, vpe)), \
  383. GIC_SH_MAP_TO_VPE_REG_BIT(vpe))
  384. struct gic_pcpu_mask {
  385. DECLARE_BITMAP(pcpu_mask, GIC_NUM_INTRS);
  386. };
  387. struct gic_pending_regs {
  388. DECLARE_BITMAP(pending, GIC_NUM_INTRS);
  389. };
  390. struct gic_intrmask_regs {
  391. DECLARE_BITMAP(intrmask, GIC_NUM_INTRS);
  392. };
  393. /*
  394. * Interrupt Meta-data specification. The ipiflag helps
  395. * in building ipi_map.
  396. */
  397. struct gic_intr_map {
  398. unsigned int intrnum; /* Ext Intr Num */
  399. unsigned int cpunum; /* Directed to this CPU */
  400. unsigned int pin; /* Directed to this Pin */
  401. unsigned int polarity; /* Polarity : +/- */
  402. unsigned int trigtype; /* Trigger : Edge/Levl */
  403. unsigned int ipiflag; /* Is used for IPI ? */
  404. };
  405. extern void gic_init(unsigned long gic_base_addr,
  406. unsigned long gic_addrspace_size, struct gic_intr_map *intrmap,
  407. unsigned int intrmap_size, unsigned int irqbase);
  408. extern unsigned int gic_get_int(void);
  409. extern void gic_send_ipi(unsigned int intr);
  410. #endif /* _ASM_GICREGS_H */