From dac65f99e8bf1fbe2e15fa96ef901623bb49dc89 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 26 Nov 2013 13:08:28 +0100 Subject: console: Set Linux console parameter automatically Linux specifies the linux,stdout-path property in the /chosen node in the devicetree. Unfortunately this is ignored in most cases. For cases in which barebox uses this property for its own use we translate this into a Linux boot arg with: - the console name provided by the serial driver - the the instance from the 'serial' alias - the baudrate from the actual baudrate. So with this it's for devicetee enabled boards no longer necessary to manually assign a console= parameter. Should a user not want to use the automatically assigned parameter it should do: global.linux.bootargs.console= in the environment. Signed-off-by: Sascha Hauer --- common/console.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'common/console.c') diff --git a/common/console.c b/common/console.c index 329bc72493..aa9e3ce0f5 100644 --- a/common/console.c +++ b/common/console.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include #include @@ -140,6 +142,26 @@ static void console_init_early(void) initialized = CONSOLE_INITIALIZED_BUFFER; } +static void console_set_stdoutpath(struct console_device *cdev) +{ + int id; + char *str; + + if (!cdev->linux_console_name) + return; + + id = of_alias_get_id(cdev->dev->device_node, "serial"); + if (id < 0) + return; + + str = asprintf("console=%s%d,%dn8", cdev->linux_console_name, + id, cdev->baudrate); + + globalvar_add_simple("linux.bootargs.console", str); + + free(str); +} + int console_register(struct console_device *newcdev) { struct device_d *dev = &newcdev->class_dev; @@ -169,8 +191,10 @@ int console_register(struct console_device *newcdev) activate = 1; } - if (newcdev->dev && of_device_is_stdout_path(newcdev->dev)) + if (newcdev->dev && of_device_is_stdout_path(newcdev->dev)) { activate = 1; + console_set_stdoutpath(newcdev); + } list_add_tail(&newcdev->list, &console_list); @@ -357,3 +381,6 @@ int ctrlc (void) } EXPORT_SYMBOL(ctrlc); #endif /* ARCH_HAS_CTRC */ + +BAREBOX_MAGICVAR_NAMED(global_linux_bootargs_console, global.linux.bootargs.console, + "console= argument for Linux from the linux,stdout-path property in /chosen node"); -- cgit v1.2.3