[PATCH] console: honour OF current-speed property if available

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

 



current-speed describes the current baud rate the device operates at.
It's not used often in DT, but we should honour it if available.

This gives boards the ability to configure consoles that are activated
early (e.g. ACTIVATE_ALL) with the correct baud rate from the beginning
instead of activating it at CONFIG_BAUDRATE and then switching the
baudrate at environment load time.

Additionally, this can be used to work around following bug:

 - Console is added, but not activated automatically
 - NV sets cs0.active="ioe" cs0.baudrate="4000000"
 - .active parameter is applied first, so CONFIG_BAUDRATE is configured
 - .baudrate parameter is applied second, so baudrate switch happens
 - System hangs until Enter is pressed:
   ## Switch baudrate on console serial1 to 4000000 bps and press ENTER

until it's resolved in a cleaner manner.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 common/console.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/common/console.c b/common/console.c
index 9db994220e67..310959eeb8b4 100644
--- a/common/console.c
+++ b/common/console.c
@@ -331,7 +331,7 @@ int console_register(struct console_device *newcdev)
 	struct device_node *serdev_node = console_is_serdev_node(newcdev);
 	struct device *dev = &newcdev->class_dev;
 	int activate = 0, ret;
-	unsigned baudrate = CONFIG_BAUDRATE;
+	unsigned of_baudrate = 0, baudrate = CONFIG_BAUDRATE;
 
 	if (!serdev_node && initialized == CONSOLE_UNINITIALIZED)
 		console_init_early();
@@ -367,6 +367,11 @@ int console_register(struct console_device *newcdev)
 		console_set_stdoutpath(newcdev, baudrate);
 	}
 
+	/* Honour the previous baudrate if it is set to a non-zero value */
+	of_property_read_u32(dev->of_node, "current-speed", &of_baudrate);
+	if (of_baudrate)
+		baudrate = of_baudrate;
+
 	console_add_earlycon_param(newcdev, baudrate);
 
 	if (newcdev->setbrg) {
-- 
2.39.2





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

  Powered by Linux