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