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>
14 static const char *cpu_feature_name[CPU_FEAT_COUNT] = {
21 static int print_cpu_list(bool detail)
26 for (uclass_first_device(UCLASS_CPU, &dev);
28 uclass_next_device(&dev)) {
29 struct cpu_platdata *plat = dev_get_parent_platdata(dev);
34 ret = cpu_get_desc(dev, buf, sizeof(buf));
35 printf("%3d: %-10s %s\n", dev->seq, dev->name,
36 ret ? "<no description>" : buf);
39 ret = cpu_get_info(dev, &info);
41 printf("\t(no detail available");
43 printf(": err=%d", ret);
47 printf("\tID = %d, freq = ", plat->cpu_id);
48 print_freq(info.cpu_freq, "");
49 for (i = 0; i < CPU_FEAT_COUNT; i++) {
50 if (info.features & (1 << i)) {
51 printf("%s%s", first ? ": " : ", ",
57 if (info.features & (1 << CPU_FEAT_UCODE))
58 printf("\tMicrocode version %#x\n",
60 if (info.features & (1 << CPU_FEAT_DEVICE_ID))
61 printf("\tDevice ID %#lx\n", plat->device_id);
67 static int do_cpu_list(cmd_tbl_t *cmdtp, int flag, int argc,
70 if (print_cpu_list(false))
71 return CMD_RET_FAILURE;
76 static int do_cpu_detail(cmd_tbl_t *cmdtp, int flag, int argc,
79 if (print_cpu_list(true))
80 return CMD_RET_FAILURE;
85 static cmd_tbl_t cmd_cpu_sub[] = {
86 U_BOOT_CMD_MKENT(list, 2, 1, do_cpu_list, "", ""),
87 U_BOOT_CMD_MKENT(detail, 4, 0, do_cpu_detail, "", ""),
91 * Process a cpu sub-command
93 static int do_cpu(cmd_tbl_t *cmdtp, int flag, int argc,
98 /* Strip off leading 'cpu' command argument */
103 c = find_cmd_tbl(argv[0], cmd_cpu_sub,
104 ARRAY_SIZE(cmd_cpu_sub));
107 return c->cmd(cmdtp, flag, argc, argv);
109 return CMD_RET_USAGE;
114 "display information about CPUs",
115 "list - list available CPUs\n"
116 "cpu detail - show CPU detail"