Re: [PATCH 10/18] bdinfo: Show information about the serial port

2023-05-15 Thread Bin Meng
On Sat, Apr 29, 2023 at 3:20 AM Simon Glass  wrote:
>
> It is useful to see the detailed setting of the serial port, e.g. to
> allow setting up earlycon or console for Linux. Add this output to the
> 'bdinfo' command.
>
> Signed-off-by: Simon Glass 
> ---
>
>  cmd/bdinfo.c | 21 +
>  1 file changed, 21 insertions(+)
>

Reviewed-by: Bin Meng 


[PATCH 10/18] bdinfo: Show information about the serial port

2023-04-28 Thread Simon Glass
It is useful to see the detailed setting of the serial port, e.g. to
allow setting up earlycon or console for Linux. Add this output to the
'bdinfo' command.

Signed-off-by: Simon Glass 
---

 cmd/bdinfo.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c
index f709904c516..af68c06696a 100644
--- a/cmd/bdinfo.c
+++ b/cmd/bdinfo.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -103,6 +104,25 @@ static void show_video_info(void)
}
 }
 
+static void print_serial(struct udevice *dev)
+{
+   struct serial_device_info info;
+   int ret;
+
+   if (!dev || !IS_ENABLED(CONFIG_DM_SERIAL))
+   return;
+
+   ret = serial_getinfo(dev, );
+   if (ret)
+   return;
+
+   bdinfo_print_num_l("serial addr", info.addr);
+   bdinfo_print_num_l(" width", info.reg_width);
+   bdinfo_print_num_l(" shift", info.reg_shift);
+   bdinfo_print_num_l(" offset", info.reg_offset);
+   bdinfo_print_num_l(" clock", info.clock);
+}
+
 int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
struct bd_info *bd = gd->bd;
@@ -144,6 +164,7 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
if (IS_ENABLED(CONFIG_OF_REAL))
printf("devicetree  = %s\n", fdtdec_get_srcname());
}
+   print_serial(gd->cur_serial_dev);
 
arch_print_bdinfo();
 
-- 
2.40.1.495.gc816e09b53d-goog