[U-Boot,05/16] dm: board: Add a command to view phase info

Submitted by Simon Glass on March 19, 2017, 6:59 p.m.

Details

Message ID 20170319185935.20950-6-sjg@chromium.org
State Changes Requested
Delegated to: Bin Meng
Headers show

Commit Message

Simon Glass March 19, 2017, 6:59 p.m.
Add a 'board phases' command ('boa' or 'boa p' for short) which shows
which board phases have been run and how many devices provided an
implementation of each phase. Sample output:

=> board phases
  1 arch_cpu_init_dm
  0 board_early_init_f
  1 checkcpu
  0 misc_init_f
  1 dram_init
  1 reserve_arch

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/Kconfig  |  8 ++++++++
 cmd/Makefile |  1 +
 cmd/board.c  | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+)
 create mode 100644 cmd/board.c

Patch hide | download patch | download mbox

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 25e3b783a8..9b93f213b7 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -126,6 +126,14 @@  config CMD_BDI
 	help
 	  Print board info
 
+config CMD_BOARD
+	bool "board"
+	default y if BOARD
+	help
+	  Provides access to board-specific drivers. This includes information
+	  about which board init was completed as well as the board
+	  description.
+
 config CMD_CONFIG
 	bool "config"
 	select BUILD_BIN2C
diff --git a/cmd/Makefile b/cmd/Makefile
index f13bb8c11e..4b1d183514 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -16,6 +16,7 @@  obj-y += version.o
 obj-$(CONFIG_CMD_AES) += aes.o
 obj-$(CONFIG_CMD_AMBAPP) += ambapp.o
 obj-$(CONFIG_CMD_ARMFLASH) += armflash.o
+obj-$(CONFIG_CMD_BOARD) += board.o
 obj-$(CONFIG_SOURCE) += source.o
 obj-$(CONFIG_CMD_SOURCE) += source.o
 obj-$(CONFIG_CMD_BDI) += bdinfo.o
diff --git a/cmd/board.c b/cmd/board.c
new file mode 100644
index 0000000000..3ee91ca25d
--- /dev/null
+++ b/cmd/board.c
@@ -0,0 +1,58 @@ 
+/*
+ * Board driver commands
+ *
+ * Copyright (c) 2017 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <board.h>
+#include <command.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const char * const phase_name[] = {
+	[BOARD_F_ARCH_CPU_INIT_DM] = "arch_cpu_init_dm",
+	[BOARD_F_EARLY_INIT_F] = "board_early_init_f",
+	[BOARD_F_CHECKCPU] = "checkcpu",
+	[BOARD_F_MISC_INIT_F] = "misc_init_f",
+	[BOARD_F_DRAM_INIT] = "dram_init",
+	[BOARD_F_RESERVE_ARCH] = "reserve_arch",
+	[BOARD_PHASE_TEST] = "test",
+	[BOARD_PHASE_INVALID] = "invalid",
+
+};
+
+static void board_list_phases(void)
+{
+	enum board_phase_t phase;
+
+	for (phase = BOARD_PHASE_FIRST; phase < BOARD_PHASE_TEST; phase++)
+		printf("%3d %s\n", gd->phase_count[phase], phase_name[phase]);
+}
+
+static int do_board(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	int cmd = 'p';
+
+	if (argc > 1)
+		cmd = argv[1][0];
+
+	switch (cmd) {
+	case 'p': /* phases */
+		board_list_phases();
+		break;
+	default:
+		return CMD_RET_FAILURE;
+	}
+
+	return 0;
+}
+
+U_BOOT_CMD(
+	board,	2,	0,	do_board,
+	"Access board information",
+	"phases\t- Show information about completed board init phases"
+);