2 * Copyright (c) 2015 Google, Inc
3 * Written by Simon Glass <sjg@chromium.org>
5 * SPDX-License-Identifier: GPL-2.0+
13 static const char *cpu_feature_name[CPU_FEAT_COUNT] = {
18 static int print_cpu_list(bool detail)
25 ret = uclass_get(UCLASS_CPU, &uc);
27 printf("Cannot find CPU uclass\n");
30 uclass_foreach_dev(dev, uc) {
31 struct cpu_platdata *plat = dev_get_parent_platdata(dev);
36 ret = cpu_get_desc(dev, buf, sizeof(buf));
37 printf("%3d: %-10s %s\n", dev->seq, dev->name,
38 ret ? "<no description>" : buf);
41 ret = cpu_get_info(dev, &info);
43 printf("\t(no detail available");
45 printf(": err=%d\n", ret);
49 printf("\tID = %d, freq = ", plat->cpu_id);
50 print_freq(info.cpu_freq, "");
52 for (i = 0; i < CPU_FEAT_COUNT; i++) {
53 if (info.features & (1 << i)) {
54 printf("%s%s", first ? ": " : ", ",
65 static int do_cpu_list(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
67 if (print_cpu_list(false))
68 return CMD_RET_FAILURE;
73 static int do_cpu_detail(cmd_tbl_t *cmdtp, int flag, int argc,
76 if (print_cpu_list(true))
77 return CMD_RET_FAILURE;
82 static cmd_tbl_t cmd_cpu_sub[] = {
83 U_BOOT_CMD_MKENT(list, 2, 1, do_cpu_list, "", ""),
84 U_BOOT_CMD_MKENT(detail, 4, 0, do_cpu_detail, "", ""),
88 * Process a cpu sub-command
90 static int do_cpu(cmd_tbl_t *cmdtp, int flag, int argc,
95 /* Strip off leading 'cpu' command argument */
100 c = find_cmd_tbl(argv[0], cmd_cpu_sub, ARRAY_SIZE(cmd_cpu_sub));
103 return c->cmd(cmdtp, flag, argc, argv);
105 return CMD_RET_USAGE;
110 "display information about CPUs",
111 "list - list available CPUs\n"
112 "cpu detail - show CPU detail"