summaryrefslogtreecommitdiff
path: root/tools/kwboot.c
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2021-09-25 00:07:06 +0300
committerStefan Roese <sr@denx.de>2021-10-01 12:07:13 +0300
commit93b55636b09faaa0ab809d4110a07dfd982a48b6 (patch)
tree2b0745a3dabb843c0d2b225f0a492f541850e5c8 /tools/kwboot.c
parentca272041c00f7f260259d3318c7832c80a874b8e (diff)
downloadu-boot-93b55636b09faaa0ab809d4110a07dfd982a48b6.tar.xz
tools: kwboot: Allow any baudrate on Linux
The A38x platform supports more baudrates than just those defined by the Bn constants, and some of them are higher than the highest Bn baudrate (the highest is 4 MBd while A38x support 5.15 MBd). On Linux, add support for arbitrary baudrates. (Since there is no standard POSIX API to specify arbitrary baudrate for a tty device, this change is Linux-specific.) We need to use raw TCGETS2/TCSETS2 or TCGETS/TCSETS ioctls with the BOTHER flag in struct termios2/termios, defined in Linux headers <asm/ioctls.h> (included by <sys/ioctl.h>) and <asm/termbits.h>. Since these headers conflict with glibc's header file <termios.h>, it is not possible to use libc's termios functions and we need to reimplement them via ioctl() calls. Note that the Bnnn constants from <termios.h> need not be compatible with Bnnn constants from <asm/termbits.h>. Signed-off-by: Pali Rohár <pali@kernel.org> [ termios macros rewritten to static inline functions (for type control) and moved to tools/termios_linux.h ] Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'tools/kwboot.c')
-rw-r--r--tools/kwboot.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/tools/kwboot.c b/tools/kwboot.c
index ba2fd10ff6..7ccab2993f 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -23,10 +23,15 @@
#include <errno.h>
#include <unistd.h>
#include <stdint.h>
-#include <termios.h>
#include <time.h>
#include <sys/stat.h>
+#ifdef __linux__
+#include "termios_linux.h"
+#else
+#include <termios.h>
+#endif
+
/*
* Marvell BootROM UART Sensing
*/
@@ -554,7 +559,11 @@ kwboot_tty_baudrate_to_speed(int baudrate)
return B50;
#endif
default:
+#ifdef BOTHER
+ return BOTHER;
+#else
return B0;
+#endif
}
}
@@ -575,6 +584,11 @@ kwboot_tty_change_baudrate(int fd, int baudrate)
return -1;
}
+#ifdef BOTHER
+ if (speed == BOTHER)
+ tio.c_ospeed = tio.c_ispeed = baudrate;
+#endif
+
rc = cfsetospeed(&tio, speed);
if (rc)
return rc;