[PATCH 2/3] earlycon: Print a notice when uartclk is unknown

From: Raul E Rangel
Date: Thu Sep 12 2024 - 13:39:33 EST


When trying to construct an earlycon=uart parameter it's hard to debug
why it's not working. In my specific case it was because the default
uartclk earlycon assumes doesn't match my hardware. This change adds a
notice so that the user is made aware of that this assumption is being
made. This should hopefully lead to them adding a <uartclk> option to
their earlycon parameter.

Booting with `console=uart,mmio32,0xfedc9000,115200n8`:
[ 0.000000] earlycon: uart: Unknown uartclk, assuming 1843200hz
[ 0.000000] earlycon: uart0 at MMIO32 0x00000000fedc9000 (options '115200n8')

Signed-off-by: Raul E Rangel <rrangel@xxxxxxxxxxxx>

---

drivers/tty/serial/earlycon.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index ab9af37f6cda35..5a8fe0cb3b1986 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -145,8 +145,12 @@ static int __init register_earlycon(char *buf, const struct earlycon_id *match)
buf = NULL;

spin_lock_init(&port->lock);
- if (!port->uartclk)
+ if (!port->uartclk) {
port->uartclk = BASE_BAUD * 16;
+ if (early_console_dev.baud)
+ pr_notice("%s: Unknown uartclk, assuming %dhz",
+ match->name, port->uartclk);
+ }
if (port->mapbase)
port->membase = earlycon_map(port->mapbase, 64);

--
2.46.0.662.g92d0881bb0-goog