serial: Call flush() before changing baudrate

Changing baudrate is a sensitive operation. To ensure that U-Boot messages
printed before changing baudrate are not lost, call new U-Boot console
flush() function.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Pali Rohár 2022-09-05 11:31:20 +02:00 committed by Tom Rini
parent 78b5243182
commit 989cc40f80
2 changed files with 6 additions and 0 deletions

View File

@ -83,6 +83,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int flag, int argc,
printf("## Switch baudrate to %d bps and press ENTER ...\n",
load_baudrate);
udelay(50000);
flush();
gd->baudrate = load_baudrate;
serial_setbrg();
udelay(50000);
@ -126,6 +127,7 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int flag, int argc,
printf("## Switch baudrate to %d bps and press ESC ...\n",
current_baudrate);
udelay(50000);
flush();
gd->baudrate = current_baudrate;
serial_setbrg();
udelay(50000);
@ -317,6 +319,7 @@ int do_save_serial(struct cmd_tbl *cmdtp, int flag, int argc,
printf("## Switch baudrate to %d bps and press ESC ...\n",
(int)current_baudrate);
udelay(50000);
flush();
gd->baudrate = current_baudrate;
serial_setbrg();
udelay(50000);
@ -471,6 +474,7 @@ static int do_load_serial_bin(struct cmd_tbl *cmdtp, int flag, int argc,
printf("## Switch baudrate to %d bps and press ENTER ...\n",
load_baudrate);
udelay(50000);
flush();
gd->baudrate = load_baudrate;
serial_setbrg();
udelay(50000);
@ -533,6 +537,7 @@ static int do_load_serial_bin(struct cmd_tbl *cmdtp, int flag, int argc,
printf("## Switch baudrate to %d bps and press ESC ...\n",
current_baudrate);
udelay(50000);
flush();
gd->baudrate = current_baudrate;
serial_setbrg();
udelay(50000);

View File

@ -476,6 +476,7 @@ static int on_baudrate(const char *name, const char *value, enum env_op op,
printf("## Switch baudrate to %d bps and press ENTER ...\n",
baudrate);
udelay(50000);
flush();
}
gd->baudrate = baudrate;