fvp-defs.dtsi 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. /*
  2. * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef FVP_DEFS_DTSI
  7. #define FVP_DEFS_DTSI
  8. /* Set default topology values if not passed from platform's makefile */
  9. #ifndef CLUSTER_COUNT
  10. #ifdef FVP_CLUSTER_COUNT
  11. #define CLUSTER_COUNT FVP_CLUSTER_COUNT
  12. #else
  13. #define CLUSTER_COUNT 2
  14. #endif
  15. #endif /* CLUSTER_COUNT */
  16. #ifndef CPUS_PER_CLUSTER
  17. #ifdef FVP_MAX_CPUS_PER_CLUSTER
  18. #define CPUS_PER_CLUSTER FVP_MAX_CPUS_PER_CLUSTER
  19. #else
  20. #define CPUS_PER_CLUSTER 4
  21. #endif
  22. #endif /* CPUS_PER_CLUSTER */
  23. /* Get platform's topology */
  24. #define CPUS_COUNT (CLUSTER_COUNT * CPUS_PER_CLUSTER)
  25. #define CONCAT(x, y) x##y
  26. #define CONC(x, y) CONCAT(x, y)
  27. /* CPU's cluster */
  28. #define CLS(n) (n / CPUS_PER_CLUSTER)
  29. /* CPU's position in cluster */
  30. #define POS(n) (n % CPUS_PER_CLUSTER)
  31. #define ADR(n, c, p) \
  32. CPU##n:cpu@CONC(c, CONC(p, AFF)) {
  33. #define PRE \
  34. device_type = "cpu"; \
  35. compatible = "arm,armv8";
  36. #define POST \
  37. enable-method = "psci"; \
  38. cpu-idle-states = <&CPU_SLEEP_0 &CLUSTER_SLEEP_0>; \
  39. next-level-cache = <&L2_0>; \
  40. };
  41. #define CPU_0 \
  42. CPU0:cpu@0 { \
  43. PRE \
  44. reg = <0x0 0x0>;\
  45. POST
  46. /*
  47. * n - CPU number
  48. */
  49. #define CPU(n, c, p) \
  50. ADR(n, c, p) \
  51. PRE \
  52. reg = <0x0 CONC(0x, CONC(c, CONC(p, AFF)))>; \
  53. POST
  54. /* 2 CPUs */
  55. #if (CPUS_COUNT > 1)
  56. #if (CLS(1) == 0)
  57. #define c1
  58. #define p1 1
  59. #else
  60. #define c1 10
  61. #define p1 0
  62. #endif
  63. #define CPU_1 CPU(1, c1, p1) /* CPU1: 0.1; 1.0 */
  64. /* 3 CPUs */
  65. #if (CPUS_COUNT > 2)
  66. #if (CLS(2) == 0)
  67. #define c2
  68. #define p2 2
  69. #elif (CLS(2) == 1)
  70. #define c2 10
  71. #define p2 0
  72. #else
  73. #define c2 20
  74. #define p2 0
  75. #endif
  76. #define CPU_2 CPU(2, c2, p2) /* CPU2: 0.2; 1.0; 2.0 */
  77. /* 4 CPUs */
  78. #if (CPUS_COUNT > 3)
  79. #if (CLS(3) == 0)
  80. #define c3
  81. #elif (CLS(3) == 1)
  82. #define c3 10
  83. #else
  84. #define c3 30
  85. #endif
  86. #if (POS(3) == 0)
  87. #define p3 0
  88. #elif (POS(3) == 1)
  89. #define p3 1
  90. #else
  91. #define p3 3
  92. #endif
  93. #define CPU_3 CPU(3, c3, p3) /* CPU3: 0.3; 1.0; 1.1; 3.0 */
  94. /* 6 CPUs */
  95. #if (CPUS_COUNT > 4)
  96. #if (CLS(4) == 1)
  97. #define c4 10
  98. #else
  99. #define c4 20
  100. #endif
  101. #if (POS(4) == 0)
  102. #define p4 0
  103. #else
  104. #define p4 1
  105. #endif
  106. #if (CLS(5) == 1)
  107. #define c5 10
  108. #else
  109. #define c5 20
  110. #endif
  111. #if (POS(5) == 1)
  112. #define p5 1
  113. #else
  114. #define p5 2
  115. #endif
  116. #define CPU_4 CPU(4, c4, p4) /* CPU4: 1.0; 1.1; 2.0 */
  117. #define CPU_5 CPU(5, c5, p5) /* CPU5: 1.1; 1.2; 2.1 */
  118. /* 8 CPUs */
  119. #if (CPUS_COUNT > 6)
  120. #if (CLS(6) == 1)
  121. #define c6 10
  122. #define p6 2
  123. #elif (CLS(6) == 2)
  124. #define c6 20
  125. #define p6 0
  126. #else
  127. #define c6 30
  128. #define p6 0
  129. #endif
  130. #if (CLS(7) == 1)
  131. #define c7 10
  132. #define p7 3
  133. #elif (CLS(7) == 2)
  134. #define c7 20
  135. #define p7 1
  136. #else
  137. #define c7 30
  138. #define p7 1
  139. #endif
  140. #define CPU_6 CPU(6, c6, p6) /* CPU6: 1.2; 2.0; 3.0 */
  141. #define CPU_7 CPU(7, c7, p7) /* CPU7: 1.3; 2.1; 3.1 */
  142. /* 9 CPUs */
  143. #if (CPUS_COUNT > 8)
  144. #if (POS(8) == 0)
  145. #define p8 0
  146. #else
  147. #define p8 2
  148. #endif
  149. #define CPU_8 CPU(8, 20, p8) /* CPU8: 2.0; 2.2 */
  150. /* 12 CPUs */
  151. #if (CPUS_COUNT > 9)
  152. #if (CLS(9) == 2)
  153. #define c9 20
  154. #define p9 1
  155. #else
  156. #define c9 30
  157. #define p9 0
  158. #endif
  159. #if (CLS(10) == 2)
  160. #define c10 20
  161. #define p10 2
  162. #else
  163. #define c10 30
  164. #define p10 1
  165. #endif
  166. #if (CLS(11) == 2)
  167. #define c11 20
  168. #define p11 3
  169. #else
  170. #define c11 30
  171. #define p11 2
  172. #endif
  173. #define CPU_9 CPU(9, c9, p9) /* CPU9: 2.1; 3.0 */
  174. #define CPU_10 CPU(10, c10, p10) /* CPU10: 2.2; 3.1 */
  175. #define CPU_11 CPU(11, c11, p11) /* CPU11: 2.3; 3.2 */
  176. /* 16 CPUs */
  177. #if (CPUS_COUNT > 12)
  178. #define CPU_12 CPU(12, 30, 0) /* CPU12: 3.0 */
  179. #define CPU_13 CPU(13, 30, 1) /* CPU13: 3.1 */
  180. #define CPU_14 CPU(14, 30, 2) /* CPU14: 3.2 */
  181. #define CPU_15 CPU(15, 30, 3) /* CPU15: 3.3 */
  182. #endif /* > 12 */
  183. #endif /* > 9 */
  184. #endif /* > 8 */
  185. #endif /* > 6 */
  186. #endif /* > 4 */
  187. #endif /* > 3 */
  188. #endif /* > 2 */
  189. #endif /* > 1 */
  190. #if (CPUS_COUNT == 1)
  191. #define CPUS \
  192. CPU_0
  193. #elif (CPUS_COUNT == 2)
  194. #define CPUS \
  195. CPU_0 \
  196. CPU_1
  197. #elif (CPUS_COUNT == 3)
  198. #define CPUS \
  199. CPU_0 \
  200. CPU_1 \
  201. CPU_2
  202. #elif (CPUS_COUNT == 4)
  203. #define CPUS \
  204. CPU_0 \
  205. CPU_1 \
  206. CPU_2 \
  207. CPU_3
  208. #elif (CPUS_COUNT == 6)
  209. #define CPUS \
  210. CPU_0 \
  211. CPU_1 \
  212. CPU_2 \
  213. CPU_3 \
  214. CPU_4 \
  215. CPU_5
  216. #elif (CPUS_COUNT == 8)
  217. #define CPUS \
  218. CPU_0 \
  219. CPU_1 \
  220. CPU_2 \
  221. CPU_3 \
  222. CPU_4 \
  223. CPU_5 \
  224. CPU_6 \
  225. CPU_7
  226. #elif (CPUS_COUNT == 9)
  227. #define CPUS \
  228. CPU_0 \
  229. CPU_1 \
  230. CPU_2 \
  231. CPU_3 \
  232. CPU_4 \
  233. CPU_5 \
  234. CPU_6 \
  235. CPU_7 \
  236. CPU_8
  237. #elif (CPUS_COUNT == 12)
  238. #define CPUS \
  239. CPU_0 \
  240. CPU_1 \
  241. CPU_2 \
  242. CPU_3 \
  243. CPU_4 \
  244. CPU_5 \
  245. CPU_6 \
  246. CPU_7 \
  247. CPU_8 \
  248. CPU_9 \
  249. CPU_10 \
  250. CPU_11
  251. #else
  252. #define CPUS \
  253. CPU_0 \
  254. CPU_1 \
  255. CPU_2 \
  256. CPU_3 \
  257. CPU_4 \
  258. CPU_5 \
  259. CPU_6 \
  260. CPU_7 \
  261. CPU_8 \
  262. CPU_9 \
  263. CPU_10 \
  264. CPU_11 \
  265. CPU_12 \
  266. CPU_13 \
  267. CPU_14 \
  268. CPU_15
  269. #endif /* CPUS_COUNT */
  270. #define CORE(n) \
  271. core##n { \
  272. cpu = <&CONC(CPU, __COUNTER__)>; \
  273. };
  274. /* Max 4 CPUs per cluster */
  275. #if (CPUS_PER_CLUSTER == 1)
  276. #define CLUSTER(n) \
  277. cluster##n { \
  278. CORE(0) \
  279. };
  280. #elif (CPUS_PER_CLUSTER == 2)
  281. #define CLUSTER(n) \
  282. cluster##n { \
  283. CORE(0) \
  284. CORE(1) \
  285. };
  286. #elif (CPUS_PER_CLUSTER == 3)
  287. #define CLUSTER(n) \
  288. cluster##n { \
  289. CORE(0) \
  290. CORE(1) \
  291. CORE(2) \
  292. };
  293. #else
  294. #define CLUSTER(n) \
  295. cluster##n { \
  296. CORE(0) \
  297. CORE(1) \
  298. CORE(2) \
  299. CORE(3) \
  300. };
  301. #endif /* CPUS_PER_CLUSTER */
  302. /* Max 4 clusters */
  303. #if (CLUSTER_COUNT == 1)
  304. #define CPU_MAP \
  305. cpu-map { \
  306. CLUSTER(0) \
  307. };
  308. #elif (CLUSTER_COUNT == 2)
  309. #define CPU_MAP \
  310. cpu-map { \
  311. CLUSTER(0) \
  312. CLUSTER(1) \
  313. };
  314. #elif (CLUSTER_COUNT == 3)
  315. #define CPU_MAP \
  316. cpu-map { \
  317. CLUSTER(0) \
  318. CLUSTER(1) \
  319. CLUSTER(2) \
  320. };
  321. #else
  322. #define CPU_MAP \
  323. cpu-map { \
  324. CLUSTER(0) \
  325. CLUSTER(1) \
  326. CLUSTER(2) \
  327. CLUSTER(3) \
  328. };
  329. #endif /* CLUSTER_COUNT */
  330. #endif /* FVP_DEFS_DTSI */