]>
git.ipfire.org Git - people/ms/u-boot.git/blob - cmd/cpu.c
2 * Copyright (c) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
4 * Copyright (c) 2017 Álvaro Fernández Rojas <noltari@gmail.com>
6 * SPDX-License-Identifier: GPL-2.0+
15 static const char *cpu_feature_name
[CPU_FEAT_COUNT
] = {
22 static int print_cpu_list(bool detail
)
27 for (uclass_first_device(UCLASS_CPU
, &dev
);
29 uclass_next_device(&dev
)) {
30 struct cpu_platdata
*plat
= dev_get_parent_platdata(dev
);
35 ret
= cpu_get_desc(dev
, buf
, sizeof(buf
));
36 printf("%3d: %-10s %s\n", dev
->seq
, dev
->name
,
37 ret
? "<no description>" : buf
);
40 ret
= cpu_get_info(dev
, &info
);
42 printf("\t(no detail available");
44 printf(": err=%d", ret
);
48 printf("\tID = %d, freq = ", plat
->cpu_id
);
49 print_freq(info
.cpu_freq
, "");
50 for (i
= 0; i
< CPU_FEAT_COUNT
; i
++) {
51 if (info
.features
& (1 << i
)) {
52 printf("%s%s", first
? ": " : ", ",
58 if (info
.features
& (1 << CPU_FEAT_UCODE
))
59 printf("\tMicrocode version %#x\n",
61 if (info
.features
& (1 << CPU_FEAT_DEVICE_ID
))
62 printf("\tDevice ID %#lx\n", plat
->device_id
);
68 static int do_cpu_list(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
71 if (print_cpu_list(false))
72 return CMD_RET_FAILURE
;
77 static int do_cpu_detail(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
80 if (print_cpu_list(true))
81 return CMD_RET_FAILURE
;
86 static cmd_tbl_t cmd_cpu_sub
[] = {
87 U_BOOT_CMD_MKENT(list
, 2, 1, do_cpu_list
, "", ""),
88 U_BOOT_CMD_MKENT(detail
, 4, 0, do_cpu_detail
, "", ""),
92 * Process a cpu sub-command
94 static int do_cpu(cmd_tbl_t
*cmdtp
, int flag
, int argc
,
99 /* Strip off leading 'cpu' command argument */
104 c
= find_cmd_tbl(argv
[0], cmd_cpu_sub
,
105 ARRAY_SIZE(cmd_cpu_sub
));
108 return c
->cmd(cmdtp
, flag
, argc
, argv
);
110 return CMD_RET_USAGE
;
115 "display information about CPUs",
116 "list - list available CPUs\n"
117 "cpu detail - show CPU detail"