From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] console: honour OF current-speed property if available
Date: Thu, 1 Aug 2024 09:09:18 +0200 [thread overview]
Message-ID: <20240801070918.1667337-1-a.fatoum@pengutronix.de> (raw)
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@pengutronix.de>
---
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
next reply other threads:[~2024-08-01 7:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-01 7:09 Ahmad Fatoum [this message]
2024-08-01 11:36 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240801070918.1667337-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox