From b6a90ac0902ff64a5a1dabe69cf4b480ac34d69a Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 7 Oct 2023 23:40:58 +0200 Subject: cmd: bdinfo: Optionally use getopt and implement bdinfo -a Add optional support for getopt() and in case this is enabled via GETOPT configuration option, implement support for 'bdinfo -a'. The 'bdinfo -a' behaves exactly like bdinfo and prints 'all' the bdinfo information. This is implemented in preparation for other more fine-grained options. Reviewed-by: Simon Glass Signed-off-by: Marek Vasut --- cmd/bdinfo.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index 1fe13ca13a0..2c0d5e9c01b 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -133,10 +134,8 @@ static void print_serial(struct udevice *dev) bdinfo_print_num_l(" clock", info.clock); } -int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +static int bdinfo_print_all(struct bd_info *bd) { - struct bd_info *bd = gd->bd; - #ifdef DEBUG bdinfo_print_num_l("bd address", (ulong)bd); #endif @@ -184,8 +183,30 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return 0; } +int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + struct bd_info *bd = gd->bd; + struct getopt_state gs; + int opt; + + if (!CONFIG_IS_ENABLED(GETOPT) || argc == 1) + return bdinfo_print_all(bd); + + getopt_init_state(&gs); + while ((opt = getopt(&gs, argc, argv, "a")) > 0) { + switch (opt) { + case 'a': + return bdinfo_print_all(bd); + default: + return CMD_RET_USAGE; + } + } + + return CMD_RET_USAGE; +} + U_BOOT_CMD( - bdinfo, 1, 1, do_bdinfo, + bdinfo, 2, 1, do_bdinfo, "print Board Info structure", "" ); -- cgit v1.3.1 From f1774a80307c357ab26f8ee42c5b082a902393b6 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 7 Oct 2023 23:40:59 +0200 Subject: cmd: bdinfo: Implement support for printing memory layout via bdinfo -m Add support for printing memory layout only via 'bdinfo -m' . Reviewed-by: Simon Glass Signed-off-by: Marek Vasut --- cmd/bdinfo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index 2c0d5e9c01b..c720ee6f9b6 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -193,10 +193,13 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return bdinfo_print_all(bd); getopt_init_state(&gs); - while ((opt = getopt(&gs, argc, argv, "a")) > 0) { + while ((opt = getopt(&gs, argc, argv, "am")) > 0) { switch (opt) { case 'a': return bdinfo_print_all(bd); + case 'm': + print_bi_dram(bd); + return CMD_RET_SUCCESS; default: return CMD_RET_USAGE; } -- cgit v1.3.1 From ea9637c92f3b698903ee3d76f0b57e1109b352b0 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 7 Oct 2023 23:41:00 +0200 Subject: cmd: bdinfo: Implement support for printing ethernet settings via bdinfo -e Add support for printing ethernet settings only via 'bdinfo -e' . Reviewed-by: Simon Glass Signed-off-by: Marek Vasut --- cmd/bdinfo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cmd') diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index c720ee6f9b6..79106caeec2 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -193,10 +193,15 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return bdinfo_print_all(bd); getopt_init_state(&gs); - while ((opt = getopt(&gs, argc, argv, "am")) > 0) { + while ((opt = getopt(&gs, argc, argv, "aem")) > 0) { switch (opt) { case 'a': return bdinfo_print_all(bd); + case 'e': + if (!IS_ENABLED(CONFIG_CMD_NET)) + return CMD_RET_USAGE; + print_eth(); + return CMD_RET_SUCCESS; case 'm': print_bi_dram(bd); return CMD_RET_SUCCESS; -- cgit v1.3.1