1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (c) 2015 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
5 * Copyright (c) 2017 Álvaro Fernández Rojas <noltari@gmail.com>
11 #include <display_options.h>
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_plat *plat = dev_get_parent_plat(dev);
35 ret = cpu_get_desc(dev, buf, sizeof(buf));
36 printf("%3d: %-10s %s\n", dev_seq(dev), 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(struct cmd_tbl *cmdtp, int flag, int argc,
71 if (print_cpu_list(false))
72 return CMD_RET_FAILURE;
77 static int do_cpu_detail(struct cmd_tbl *cmdtp, int flag, int argc,
80 if (print_cpu_list(true))
81 return CMD_RET_FAILURE;
86 #if CONFIG_IS_ENABLED(SYS_LONGHELP)
87 static char cpu_help_text[] =
88 "list - list available CPUs\n"
89 "cpu detail - show CPU detail"
93 U_BOOT_CMD_WITH_SUBCMDS(cpu, "display information about CPUs", cpu_help_text,
94 U_BOOT_SUBCMD_MKENT(list, 1, 1, do_cpu_list),
95 U_BOOT_SUBCMD_MKENT(detail, 1, 0, do_cpu_detail));