summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig8
-rw-r--r--common/Makefile1
-rw-r--r--common/board_f.c9
-rw-r--r--common/board_r.c2
-rw-r--r--common/cmd_cpu.c113
5 files changed, 127 insertions, 6 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 5d7e48a5b6..15759f75aa 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -31,6 +31,14 @@ config CMD_CONSOLE
help
Print console devices and information.
+config CMD_CPU
+ bool "cpu"
+ help
+ Print information about available CPUs. This normally shows the
+ number of CPUs, type (e.g. manufacturer, architecture, product or
+ internal name) and clock frequency. Other information may be
+ available depending on the CPU driver.
+
config CMD_LICENSE
bool "license"
help
diff --git a/common/Makefile b/common/Makefile
index fba3830f1d..9084c73ad9 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -74,6 +74,7 @@ obj-$(CONFIG_CMD_CBFS) += cmd_cbfs.o
obj-$(CONFIG_CMD_CLK) += cmd_clk.o
obj-$(CONFIG_CMD_CONSOLE) += cmd_console.o
obj-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o
+obj-$(CONFIG_CMD_CPU) += cmd_cpu.o
obj-$(CONFIG_DATAFLASH_MMC_SELECT) += cmd_dataflash_mmc_mux.o
obj-$(CONFIG_CMD_DATE) += cmd_date.o
obj-$(CONFIG_CMD_DEMO) += cmd_demo.o
diff --git a/common/board_f.c b/common/board_f.c
index 322e0700d7..fbbad1bcb9 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -73,7 +73,7 @@ DECLARE_GLOBAL_DATA_PTR;
#endif
/*
- * sjg: IMO this code should be
+ * TODO(sjg@chromium.org): IMO this code should be
* refactored to a single function, something like:
*
* void led_set_state(enum led_colour_t colour, int on);
@@ -300,7 +300,7 @@ __weak ulong board_get_usable_ram_top(ulong total_size)
{
#ifdef CONFIG_SYS_SDRAM_BASE
/*
- * Detect whether we have so much RAM it goes past the end of our
+ * Detect whether we have so much RAM that it goes past the end of our
* 32-bit address space. If so, clip the usable RAM so it doesn't.
*/
if (gd->ram_top < CONFIG_SYS_SDRAM_BASE)
@@ -507,7 +507,7 @@ static int reserve_global_data(void)
static int reserve_fdt(void)
{
/*
- * If the device tree is sitting immediate above our image then we
+ * If the device tree is sitting immediately above our image then we
* must relocate it. If it is embedded in the data section, then it
* will be relocated with other data.
*/
@@ -535,7 +535,7 @@ static int reserve_stacks(void)
gd->start_addr_sp &= ~0xf;
/*
- * let the architecture specific code tailor gd->start_addr_sp and
+ * let the architecture-specific code tailor gd->start_addr_sp and
* gd->irq_sp
*/
return arch_reserve_stacks();
@@ -556,7 +556,6 @@ static int setup_board_part1(void)
/*
* Save local variables to board info struct
*/
-
bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of memory */
bd->bi_memsize = gd->ram_size; /* size in bytes */
diff --git a/common/board_r.c b/common/board_r.c
index 307124ed80..1a46f6224f 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -779,7 +779,7 @@ init_fnc_t init_sequence_r[] = {
initr_flash,
#endif
INIT_FUNC_WATCHDOG_RESET
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K)
+#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_X86)
/* initialize higher level parts of CPU like time base and timers */
cpu_init_r,
#endif
diff --git a/common/cmd_cpu.c b/common/cmd_cpu.c
new file mode 100644
index 0000000000..c3e229f00a
--- /dev/null
+++ b/common/cmd_cpu.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <command.h>
+#include <cpu.h>
+#include <dm.h>
+
+static const char *cpu_feature_name[CPU_FEAT_COUNT] = {
+ "L1 cache",
+ "MMU",
+};
+
+static int print_cpu_list(bool detail)
+{
+ struct udevice *dev;
+ struct uclass *uc;
+ char buf[100];
+ int ret;
+
+ ret = uclass_get(UCLASS_CPU, &uc);
+ if (ret) {
+ printf("Cannot find CPU uclass\n");
+ return ret;
+ }
+ uclass_foreach_dev(dev, uc) {
+ struct cpu_platdata *plat = dev_get_parent_platdata(dev);
+ struct cpu_info info;
+ bool first;
+ int i;
+
+ ret = cpu_get_desc(dev, buf, sizeof(buf));
+ printf("%3d: %-10s %s\n", dev->seq, dev->name,
+ ret ? "<no description>" : buf);
+ if (!detail)
+ continue;
+ ret = cpu_get_info(dev, &info);
+ if (ret) {
+ printf("\t(no detail available");
+ if (ret != -ENOSYS)
+ printf(": err=%d\n", ret);
+ printf(")\n");
+ continue;
+ }
+ printf("\tID = %d, freq = ", plat->cpu_id);
+ print_freq(info.cpu_freq, "");
+ first = true;
+ for (i = 0; i < CPU_FEAT_COUNT; i++) {
+ if (info.features & (1 << i)) {
+ printf("%s%s", first ? ": " : ", ",
+ cpu_feature_name[i]);
+ first = false;
+ }
+ }
+ printf("\n");
+ }
+
+ return 0;
+}
+
+static int do_cpu_list(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
+{
+ if (print_cpu_list(false))
+ return CMD_RET_FAILURE;
+
+ return 0;
+}
+
+static int do_cpu_detail(cmd_tbl_t *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ if (print_cpu_list(true))
+ return CMD_RET_FAILURE;
+
+ return 0;
+}
+
+static cmd_tbl_t cmd_cpu_sub[] = {
+ U_BOOT_CMD_MKENT(list, 2, 1, do_cpu_list, "", ""),
+ U_BOOT_CMD_MKENT(detail, 4, 0, do_cpu_detail, "", ""),
+};
+
+/*
+ * Process a cpu sub-command
+ */
+static int do_cpu(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ cmd_tbl_t *c = NULL;
+
+ /* Strip off leading 'cpu' command argument */
+ argc--;
+ argv++;
+
+ if (argc)
+ c = find_cmd_tbl(argv[0], cmd_cpu_sub, ARRAY_SIZE(cmd_cpu_sub));
+
+ if (c)
+ return c->cmd(cmdtp, flag, argc, argv);
+ else
+ return CMD_RET_USAGE;
+}
+
+U_BOOT_CMD(
+ cpu, 2, 1, do_cpu,
+ "display information about CPUs",
+ "list - list available CPUs\n"
+ "cpu detail - show CPU detail"
+);