[PATCH 10/30] leon, apbuart: Inherit HW parameters on sysconsole
Daniel Hellstrom
daniel at gaisler.com
Thu Apr 13 19:31:19 UTC 2017
From: Martin Aberg <maberg at gaisler.com>
The cons layer decides which of the registered console device is granted as
system console. When a device specific console driver performs its first_open,
it inherits UART parameters from boot loader only if it is the system console.
---
c/src/lib/libbsp/sparc/shared/include/cons.h | 8 +++++---
c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c | 10 ++++++----
c/src/lib/libbsp/sparc/shared/uart/cons.c | 4 ++++
3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/c/src/lib/libbsp/sparc/shared/include/cons.h b/c/src/lib/libbsp/sparc/shared/include/cons.h
index 9a26a26..c30e41c 100644
--- a/c/src/lib/libbsp/sparc/shared/include/cons.h
+++ b/c/src/lib/libbsp/sparc/shared/include/cons.h
@@ -20,12 +20,14 @@
struct console_dev;
-#define CONSOLE_FLAG_SYSCON 0x01
+#define CONSOLE_FLAG_SYSCON 0x01
+#define CONSOLE_FLAG_SYSCON_GRANT 0x02
struct console_dev {
rtems_termios_device_context base;
- /* Set to CONSOLE_FLAG_SYSCON if this UART should be system console and/or
- * debug console.
+ /* Set CONSOLE_FLAG_SYSCON to request this device to be system console
+ * and/or debug console. CONSOLE_FLAG_SYSCON_GRANT will be set on the
+ * device which was selected as system console.
*/
int flags;
char *fsname; /* File system prefix */
diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
index 1547e78..379d9ff 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart_cons.c
@@ -440,10 +440,12 @@ static bool first_open(
uart->tty = tty;
- /* Preserve values set by bootloader */
- get_attributes(base, term);
- term->c_oflag |= ONLCR;
- set_attributes(base, term);
+ /* Inherit UART hardware parameters from bootloader on system console */
+ if (uart->condev.flags & CONSOLE_FLAG_SYSCON_GRANT) {
+ get_attributes(base, term);
+ term->c_oflag |= ONLCR;
+ set_attributes(base, term);
+ }
/* Enable TX/RX */
uart->regs->ctrl |= APBUART_CTRL_RE | APBUART_CTRL_TE;
diff --git a/c/src/lib/libbsp/sparc/shared/uart/cons.c b/c/src/lib/libbsp/sparc/shared/uart/cons.c
index 8426add..37f448c 100644
--- a/c/src/lib/libbsp/sparc/shared/uart/cons.c
+++ b/c/src/lib/libbsp/sparc/shared/uart/cons.c
@@ -89,6 +89,10 @@ void console_dev_register(struct console_dev *dev)
/* Not enough console structures */
return;
}
+ dev->flags &= ~CONSOLE_FLAG_SYSCON_GRANT;
+ if (con->flags & FLAG_SYSCON) {
+ dev->flags |= CONSOLE_FLAG_SYSCON_GRANT;
+ }
/* Assign Console */
con->dev = dev;
--
2.7.4
More information about the devel
mailing list