2 * Copyright (c) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
5 * SPDX-License-Identifier: GPL-2.0+
14 static const char *cpu_feature_name[CPU_FEAT_COUNT] = {
21 static int print_cpu_list(bool detail)
28 ret = uclass_get(UCLASS_CPU, &uc);
30 printf("Cannot find CPU uclass\n");
33 uclass_foreach_dev(dev, uc) {
34 struct cpu_platdata *plat = dev_get_parent_platdata(dev);
39 ret = cpu_get_desc(dev, buf, sizeof(buf));
40 printf("%3d: %-10s %s\n", dev->seq, dev->name,
41 ret ? "<no description>" : buf);
44 ret = cpu_get_info(dev, &info);
46 printf("\t(no detail available");
48 printf(": err=%d\n", ret);
52 printf("\tID = %d, freq = ", plat->cpu_id);
53 print_freq(info.cpu_freq, "");
55 for (i = 0; i < CPU_FEAT_COUNT; i++) {
56 if (info.features & (1 << i)) {
57 printf("%s%s", first ? ": " : ", ",
63 if (info.features & (1 << CPU_FEAT_UCODE)) {
64 printf("\tMicrocode version %#x\n",
67 if (info.features & (1 << CPU_FEAT_DEVICE_ID))
68 printf("\tDevice ID %#lx\n", plat->device_id);
74 static int do_cpu_list(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
76 if (print_cpu_list(false))
77 return CMD_RET_FAILURE;
82 static int do_cpu_detail(cmd_tbl_t *cmdtp, int flag, int argc,
85 if (print_cpu_list(true))
86 return CMD_RET_FAILURE;
91 static cmd_tbl_t cmd_cpu_sub[] = {
92 U_BOOT_CMD_MKENT(list, 2, 1, do_cpu_list, "", ""),
93 U_BOOT_CMD_MKENT(detail, 4, 0, do_cpu_detail, "", ""),
97 * Process a cpu sub-command
99 static int do_cpu(cmd_tbl_t *cmdtp, int flag, int argc,
104 /* Strip off leading 'cpu' command argument */
109 c = find_cmd_tbl(argv[0], cmd_cpu_sub, ARRAY_SIZE(cmd_cpu_sub));
112 return c->cmd(cmdtp, flag, argc, argv);
114 return CMD_RET_USAGE;
119 "display information about CPUs",
120 "list - list available CPUs\n"
121 "cpu detail - show CPU detail"