[PATCH 1/3] console: Add plumbing to expose earlycon/bootconsole parameter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Similar to what we already do to kernel's "console" parameter, add
code to allow serial drivers to expose their "earlycon"
setting. Unlike the plumbing for "console", "earlycon" is not
automatically added to kernel command line and has to be enabled by
the user.

Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
---
 Documentation/user/variables.rst |  1 +
 common/console.c                 | 25 +++++++++++++++++++++++++
 include/console.h                |  1 +
 3 files changed, 27 insertions(+)

diff --git a/Documentation/user/variables.rst b/Documentation/user/variables.rst
index ddfd48574..f3bcaa3a8 100644
--- a/Documentation/user/variables.rst
+++ b/Documentation/user/variables.rst
@@ -114,5 +114,6 @@ of all variables with special meaning along with a short description:
   bootsource                       The source barebox has been booted from
   bootsource_instance              The instance of the source barebox has been booted from
   global.boot.default              default boot order
+  global.linux.bootconsole         current console's "earlycon" setting for Linux kernel
   ...
 
diff --git a/common/console.c b/common/console.c
index 47ccf2e54..29d0f2779 100644
--- a/common/console.c
+++ b/common/console.c
@@ -253,6 +253,30 @@ static void console_set_stdoutpath(struct console_device *cdev)
 	free(str);
 }
 
+static void console_set_boot_stdoutpath(struct console_device *cdev)
+{
+	char *str;
+
+	if (!cdev->linux_bootconsole_name)
+		return;
+
+	str = basprintf("earlycon=%s,%dn8", cdev->linux_bootconsole_name,
+			cdev->baudrate);
+	/*
+	 * linux.bootconsole is used instead of
+	 * linux.bootargs.bootconsole in orger to make this feature
+	 * optional. To enable, add
+	 *
+	 *     global linux.bootargs.bootconsole
+	 *     global.linux.bootargs.bootconsole=${global.linux.bootconsole}
+	 *
+	 * somwhere in your boot scripts
+	 */
+	globalvar_add_simple("linux.bootconsole", str);
+
+	free(str);
+}
+
 static int __console_puts(struct console_device *cdev, const char *s)
 {
 	int n = 0;
@@ -360,6 +384,7 @@ int console_register(struct console_device *newcdev)
 	if (newcdev->dev && of_device_is_stdout_path(newcdev->dev)) {
 		activate = 1;
 		console_set_stdoutpath(newcdev);
+		console_set_boot_stdoutpath(newcdev);
 	}
 
 	list_add_tail(&newcdev->list, &console_list);
diff --git a/include/console.h b/include/console.h
index 673921331..09d7ebae5 100644
--- a/include/console.h
+++ b/include/console.h
@@ -64,6 +64,7 @@ struct console_device {
 	unsigned int baudrate_param;
 
 	const char *linux_console_name;
+	const char *linux_bootconsole_name;
 
 	struct cdev devfs;
 	struct cdev_operations fops;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux