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] = {
19 static int print_cpu_list(bool detail)
26 ret = uclass_get(UCLASS_CPU, &uc);
28 printf("Cannot find CPU uclass\n");
31 uclass_foreach_dev(dev, uc) {
32 struct cpu_platdata *plat = dev_get_parent_platdata(dev);
37 ret = cpu_get_desc(dev, buf, sizeof(buf));
38 printf("%3d: %-10s %s\n", dev->seq, dev->name,
39 ret ? "<no description>" : buf);
42 ret = cpu_get_info(dev, &info);
44 printf("\t(no detail available");
46 printf(": err=%d\n", ret);
50 printf("\tID = %d, freq = ", plat->cpu_id);
51 print_freq(info.cpu_freq, "");
53 for (i = 0; i < CPU_FEAT_COUNT; i++) {
54 if (info.features & (1 << i)) {
55 printf("%s%s", first ? ": " : ", ",
66 static int do_cpu_list(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
68 if (print_cpu_list(false))
69 return CMD_RET_FAILURE;
74 static int do_cpu_detail(cmd_tbl_t *cmdtp, int flag, int argc,
77 if (print_cpu_list(true))
78 return CMD_RET_FAILURE;
83 static cmd_tbl_t cmd_cpu_sub[] = {
84 U_BOOT_CMD_MKENT(list, 2, 1, do_cpu_list, "", ""),
85 U_BOOT_CMD_MKENT(detail, 4, 0, do_cpu_detail, "", ""),
89 * Process a cpu sub-command
91 static int do_cpu(cmd_tbl_t *cmdtp, int flag, int argc,
96 /* Strip off leading 'cpu' command argument */
101 c = find_cmd_tbl(argv[0], cmd_cpu_sub, ARRAY_SIZE(cmd_cpu_sub));
104 return c->cmd(cmdtp, flag, argc, argv);
106 return CMD_RET_USAGE;
111 "display information about CPUs",
112 "list - list available CPUs\n"
113 "cpu detail - show CPU detail"