Current state of the driver leads to garbled output after divisor configuration, likely due to wrong clock rate. We so far blissfully ignored proper clock handling in barebox instead relying on firmware and fixed clocks. As the VideoCore firmware can already setup the mini-uart, we can continue wearing the blinders and just disable baudrate changes for the BCM2711 for now to fix console on the Raspberry Pi 4. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- drivers/serial/serial_ns16550.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c index e936711bf816..82acb76793cb 100644 --- a/drivers/serial/serial_ns16550.c +++ b/drivers/serial/serial_ns16550.c @@ -153,6 +153,12 @@ static void ns16550_write(struct console_device *cdev, uint32_t val, priv->write_reg(priv, val, off << plat->shift); } +static bool ns16550_has_fixed_brg(struct console_device *cdev) +{ + /* We don't yet support baudrate switching on Rpi 4 */ + return IS_ENABLED(CONFIG_MACH_RPI_COMMON) && of_machine_is_compatible("brcm,bcm2711"); +} + /** * @brief Compute the divisor for a baud rate * @@ -250,7 +256,9 @@ static void rpi_init_port(struct console_device *cdev) * (instead of 8 required by the BCM2835 peripheral manual) */ priv->plat.clock = priv->plat.clock*2; - ns16550_serial_init_port(cdev); + + if (!ns16550_has_fixed_brg(cdev)) + ns16550_serial_init_port(cdev); } /*********** Exposed Functions **********************************/ @@ -490,10 +498,12 @@ static int ns16550_probe(struct device_d *dev) cdev->tstc = ns16550_tstc; cdev->putc = ns16550_putc; cdev->getc = ns16550_getc; - cdev->setbrg = ns16550_setbaudrate; cdev->flush = ns16550_flush; cdev->linux_console_name = devtype->linux_console_name; + if (!ns16550_has_fixed_brg(cdev)) + cdev->setbrg = ns16550_setbaudrate; + priv->fcrval = FCRVAL; devtype->init_port(cdev); -- 2.30.2 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox