]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - sys-utils/lscpu-arm.c
2 * SPDX-License-Identifier: GPL-2.0-or-later
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * Copyright (C) 2018 Riku Voipio <riku.voipio@iki.fi>
11 * The information here is gathered from
13 * - Linux kernel: arch/armX/include/asm/cputype.h
14 * - GCC sources: config/arch/arch-cores.def
16 * - SMBIOS tables (if applicable)
25 static const struct id_part arm_part
[] = {
36 { 0xb02, "ARM11 MPCore" },
40 { 0xc05, "Cortex-A5" },
41 { 0xc07, "Cortex-A7" },
42 { 0xc08, "Cortex-A8" },
43 { 0xc09, "Cortex-A9" },
44 { 0xc0d, "Cortex-A17" }, /* Originally A12 */
45 { 0xc0f, "Cortex-A15" },
46 { 0xc0e, "Cortex-A17" },
47 { 0xc14, "Cortex-R4" },
48 { 0xc15, "Cortex-R5" },
49 { 0xc17, "Cortex-R7" },
50 { 0xc18, "Cortex-R8" },
51 { 0xc20, "Cortex-M0" },
52 { 0xc21, "Cortex-M1" },
53 { 0xc23, "Cortex-M3" },
54 { 0xc24, "Cortex-M4" },
55 { 0xc27, "Cortex-M7" },
56 { 0xc60, "Cortex-M0+" },
57 { 0xd01, "Cortex-A32" },
58 { 0xd02, "Cortex-A34" },
59 { 0xd03, "Cortex-A53" },
60 { 0xd04, "Cortex-A35" },
61 { 0xd05, "Cortex-A55" },
62 { 0xd06, "Cortex-A65" },
63 { 0xd07, "Cortex-A57" },
64 { 0xd08, "Cortex-A72" },
65 { 0xd09, "Cortex-A73" },
66 { 0xd0a, "Cortex-A75" },
67 { 0xd0b, "Cortex-A76" },
68 { 0xd0c, "Neoverse-N1" },
69 { 0xd0d, "Cortex-A77" },
70 { 0xd0e, "Cortex-A76AE" },
71 { 0xd13, "Cortex-R52" },
72 { 0xd15, "Cortex-R82" },
73 { 0xd16, "Cortex-R52+" },
74 { 0xd20, "Cortex-M23" },
75 { 0xd21, "Cortex-M33" },
76 { 0xd22, "Cortex-M55" },
77 { 0xd23, "Cortex-M85" },
78 { 0xd40, "Neoverse-V1" },
79 { 0xd41, "Cortex-A78" },
80 { 0xd42, "Cortex-A78AE" },
81 { 0xd43, "Cortex-A65AE" },
82 { 0xd44, "Cortex-X1" },
83 { 0xd46, "Cortex-A510" },
84 { 0xd47, "Cortex-A710" },
85 { 0xd48, "Cortex-X2" },
86 { 0xd49, "Neoverse-N2" },
87 { 0xd4a, "Neoverse-E1" },
88 { 0xd4b, "Cortex-A78C" },
89 { 0xd4c, "Cortex-X1C" },
90 { 0xd4d, "Cortex-A715" },
91 { 0xd4e, "Cortex-X3" },
92 { 0xd4f, "Neoverse-V2" },
93 { 0xd80, "Cortex-A520" },
94 { 0xd81, "Cortex-A720" },
95 { 0xd82, "Cortex-X4" },
99 static const struct id_part brcm_part
[] = {
100 { 0x0f, "Brahma-B15" },
101 { 0x100, "Brahma-B53" },
102 { 0x516, "ThunderX2" },
106 static const struct id_part dec_part
[] = {
112 static const struct id_part cavium_part
[] = {
113 { 0x0a0, "ThunderX" },
114 { 0x0a1, "ThunderX-88XX" },
115 { 0x0a2, "ThunderX-81XX" },
116 { 0x0a3, "ThunderX-83XX" },
117 { 0x0af, "ThunderX2-99xx" },
118 { 0x0b0, "OcteonTX2" },
119 { 0x0b1, "OcteonTX2-98XX" },
120 { 0x0b2, "OcteonTX2-96XX" },
121 { 0x0b3, "OcteonTX2-95XX" },
122 { 0x0b4, "OcteonTX2-95XXN" },
123 { 0x0b5, "OcteonTX2-95XXMM" },
124 { 0x0b6, "OcteonTX2-95XXO" },
125 { 0x0b8, "ThunderX3-T110" },
129 static const struct id_part apm_part
[] = {
134 static const struct id_part qcom_part
[] = {
135 { 0x00f, "Scorpion" },
136 { 0x02d, "Scorpion" },
142 { 0x800, "Falkor-V1/Kryo" },
143 { 0x801, "Kryo-V2" },
144 { 0x802, "Kryo-3XX-Gold" },
145 { 0x803, "Kryo-3XX-Silver" },
146 { 0x804, "Kryo-4XX-Gold" },
147 { 0x805, "Kryo-4XX-Silver" },
149 { 0xc01, "Saphira" },
153 static const struct id_part samsung_part
[] = {
154 { 0x001, "exynos-m1" },
155 { 0x002, "exynos-m3" },
156 { 0x003, "exynos-m4" },
157 { 0x004, "exynos-m5" },
161 static const struct id_part nvidia_part
[] = {
163 { 0x003, "Denver 2" },
168 static const struct id_part marvell_part
[] = {
169 { 0x131, "Feroceon-88FR131" },
170 { 0x581, "PJ4/PJ4b" },
171 { 0x584, "PJ4B-MP" },
175 static const struct id_part apple_part
[] = {
177 { 0x001, "Cyclone" },
178 { 0x002, "Typhoon" },
179 { 0x003, "Typhoon/Capri" },
180 { 0x004, "Twister" },
181 { 0x005, "Twister/Elba/Malta" },
182 { 0x006, "Hurricane" },
183 { 0x007, "Hurricane/Myst" },
184 { 0x008, "Monsoon" },
185 { 0x009, "Mistral" },
187 { 0x00c, "Tempest" },
188 { 0x00f, "Tempest-M9" },
189 { 0x010, "Vortex/Aruba" },
190 { 0x011, "Tempest/Aruba" },
191 { 0x012, "Lightning" },
192 { 0x013, "Thunder" },
193 { 0x020, "Icestorm-A14" },
194 { 0x021, "Firestorm-A14" },
195 { 0x022, "Icestorm-M1" },
196 { 0x023, "Firestorm-M1" },
197 { 0x024, "Icestorm-M1-Pro" },
198 { 0x025, "Firestorm-M1-Pro" },
199 { 0x026, "Thunder-M10" },
200 { 0x028, "Icestorm-M1-Max" },
201 { 0x029, "Firestorm-M1-Max" },
202 { 0x030, "Blizzard-A15" },
203 { 0x031, "Avalanche-A15" },
204 { 0x032, "Blizzard-M2" },
205 { 0x033, "Avalanche-M2" },
206 { 0x034, "Blizzard-M2-Pro" },
207 { 0x035, "Avalanche-M2-Pro" },
208 { 0x036, "Sawtooth-A16" },
209 { 0x037, "Everest-A16" },
210 { 0x038, "Blizzard-M2-Max" },
211 { 0x039, "Avalanche-M2-Max" },
215 static const struct id_part faraday_part
[] = {
221 static const struct id_part intel_part
[] = {
223 { 0x210, "PXA250A" },
224 { 0x212, "PXA210A" },
225 { 0x242, "i80321-400" },
226 { 0x243, "i80321-600" },
227 { 0x290, "PXA250B/PXA26x" },
228 { 0x292, "PXA210B" },
229 { 0x2c2, "i80321-400-B0" },
230 { 0x2c3, "i80321-600-B0" },
231 { 0x2d0, "PXA250C/PXA255/PXA26x" },
232 { 0x2d2, "PXA210C" },
234 { 0x41c, "IPX425-533" },
235 { 0x41d, "IPX425-400" },
236 { 0x41f, "IPX425-266" },
238 { 0x683, "PXA930/PXA935" },
242 { 0xc12, "IPX1200" },
246 static const struct id_part fujitsu_part
[] = {
251 static const struct id_part hisi_part
[] = {
252 { 0xd01, "TaiShan-v110" }, /* used in Kunpeng-920 SoC */
253 { 0xd02, "TaiShan-v120" }, /* used in Kirin 990A and 9000S SoCs */
254 { 0xd40, "Cortex-A76" }, /* HiSilicon uses this ID though advertises A76 */
255 { 0xd41, "Cortex-A77" }, /* HiSilicon uses this ID though advertises A77 */
259 static const struct id_part ampere_part
[] = {
260 { 0xac3, "Ampere-1" },
261 { 0xac4, "Ampere-1a" },
265 static const struct id_part ft_part
[] = {
276 static const struct id_part unknown_part
[] = {
282 const struct id_part
*parts
;
286 static const struct hw_impl hw_implementer
[] = {
287 { 0x41, arm_part
, "ARM" },
288 { 0x42, brcm_part
, "Broadcom" },
289 { 0x43, cavium_part
, "Cavium" },
290 { 0x44, dec_part
, "DEC" },
291 { 0x46, fujitsu_part
, "FUJITSU" },
292 { 0x48, hisi_part
, "HiSilicon" },
293 { 0x49, unknown_part
, "Infineon" },
294 { 0x4d, unknown_part
, "Motorola/Freescale" },
295 { 0x4e, nvidia_part
, "NVIDIA" },
296 { 0x50, apm_part
, "APM" },
297 { 0x51, qcom_part
, "Qualcomm" },
298 { 0x53, samsung_part
, "Samsung" },
299 { 0x56, marvell_part
, "Marvell" },
300 { 0x61, apple_part
, "Apple" },
301 { 0x66, faraday_part
, "Faraday" },
302 { 0x69, intel_part
, "Intel" },
303 { 0x70, ft_part
, "Phytium" },
304 { 0xc0, ampere_part
, "Ampere" },
305 { -1, unknown_part
, "unknown" },
308 static int parse_id(const char *str
)
313 if (!str
|| strncmp(str
, "0x",2) != 0)
317 id
= (int) strtol(str
, &end
, 0);
318 if (errno
|| str
== end
)
324 #define parse_model_id(_cxt) (parse_id((_cxt)->model))
326 static inline int parse_implementer_id(struct lscpu_cputype
*ct
)
329 return ct
->vendor_id
;
330 ct
->vendor_id
= parse_id(ct
->vendor
);
331 return ct
->vendor_id
;
335 * Use model and vendor IDs to decode to human readable names.
337 static int arm_ids_decode(struct lscpu_cputype
*ct
)
340 const struct id_part
*parts
= NULL
;
342 impl
= parse_implementer_id(ct
);
344 return -EINVAL
; /* no ARM or missing ID */
347 for (j
= 0; hw_implementer
[j
].id
!= -1; j
++) {
348 if (hw_implementer
[j
].id
== impl
) {
349 parts
= hw_implementer
[j
].parts
;
351 ct
->vendor
= xstrdup(hw_implementer
[j
].name
);
360 part
= parse_model_id(ct
);
364 for (j
= 0; parts
[j
].id
!= -1; j
++) {
365 if (parts
[j
].id
== part
) {
367 ct
->modelname
= xstrdup(parts
[j
].name
);
375 /* use "rXpY" string as stepping */
376 static int arm_rXpY_decode(struct lscpu_cputype
*ct
)
378 int impl
, revision
, variant
;
382 impl
= parse_implementer_id(ct
);
384 if (impl
!= 0x41 || !ct
->revision
|| !ct
->stepping
)
388 revision
= (int) strtol(ct
->revision
, &end
, 10);
389 if (errno
|| ct
->revision
== end
)
393 variant
= (int) strtol(ct
->stepping
, &end
, 0);
394 if (errno
|| ct
->stepping
== end
)
397 snprintf(buf
, sizeof(buf
), "r%dp%d", variant
, revision
);
399 ct
->stepping
= xstrdup(buf
);
404 static void arm_decode(struct lscpu_cxt
*cxt
, struct lscpu_cputype
*ct
)
406 if (!cxt
->noalive
&& access(_PATH_SYS_DMI
, R_OK
) == 0)
407 dmi_decode_cputype(ct
);
412 if (!cxt
->noalive
&& cxt
->is_cluster
)
413 ct
->nr_socket_on_cluster
= get_number_of_physical_sockets_from_dmi();
416 static int is_cluster_arm(struct lscpu_cxt
*cxt
)
421 && strcmp(cxt
->arch
->name
, "aarch64") == 0
422 && stat(_PATH_ACPI_PPTT
, &st
) < 0 && cxt
->ncputypes
== 1)
428 void lscpu_decode_arm(struct lscpu_cxt
*cxt
)
432 cxt
->is_cluster
= is_cluster_arm(cxt
);
434 for (i
= 0; i
< cxt
->ncputypes
; i
++)
435 arm_decode(cxt
, cxt
->cputypes
[i
]);