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] = {
20 static int print_cpu_list(bool detail)
27 ret = uclass_get(UCLASS_CPU, &uc);
29 printf("Cannot find CPU uclass\n");
32 uclass_foreach_dev(dev, uc) {
33 struct cpu_platdata *plat = dev_get_parent_platdata(dev);
38 ret = cpu_get_desc(dev, buf, sizeof(buf));
39 printf("%3d: %-10s %s\n", dev->seq, dev->name,
40 ret ? "<no description>" : buf);
43 ret = cpu_get_info(dev, &info);
45 printf("\t(no detail available");
47 printf(": err=%d\n", ret);
51 printf("\tID = %d, freq = ", plat->cpu_id);
52 print_freq(info.cpu_freq, "");
54 for (i = 0; i < CPU_FEAT_COUNT; i++) {
55 if (info.features & (1 << i)) {
56 printf("%s%s", first ? ": " : ", ",
62 if (info.features & (1 << CPU_FEAT_UCODE)) {
63 printf("\tMicrocode version %#x\n",
66 if (info.features & (1 << CPU_FEAT_DEVICE_ID))
67 printf("\tDevice ID %#lx\n", plat->device_id);
73 static int do_cpu_list(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
75 if (print_cpu_list(false))
76 return CMD_RET_FAILURE;
81 static int do_cpu_detail(cmd_tbl_t *cmdtp, int flag, int argc,
84 if (print_cpu_list(true))
85 return CMD_RET_FAILURE;
90 static cmd_tbl_t cmd_cpu_sub[] = {
91 U_BOOT_CMD_MKENT(list, 2, 1, do_cpu_list, "", ""),
92 U_BOOT_CMD_MKENT(detail, 4, 0, do_cpu_detail, "", ""),
96 * Process a cpu sub-command
98 static int do_cpu(cmd_tbl_t *cmdtp, int flag, int argc,
103 /* Strip off leading 'cpu' command argument */
108 c = find_cmd_tbl(argv[0], cmd_cpu_sub, ARRAY_SIZE(cmd_cpu_sub));
111 return c->cmd(cmdtp, flag, argc, argv);
113 return CMD_RET_USAGE;
118 "display information about CPUs",
119 "list - list available CPUs\n"
120 "cpu detail - show CPU detail"