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