Skip to content

Commit b8d20e0

Browse files
masahir0ygregkh
authored andcommitted
serial: 8250_uniphier: add earlycon support
This reuses the code of drivers/tty/serial/8250/8250_early.c except - Overwrite device->port.iotype and device->port.regshift for UPIO_MEM32 because of_setup_earlycon() has set them for UPIO_MEM. - Set device->baud to zero to prevent early8250_setup() from initializing the divisor register because port->uartclk does not match the frequency expected by this hardware. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent d72d391 commit b8d20e0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

drivers/tty/serial/8250/8250_uniphier.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
#include <linux/clk.h>
16+
#include <linux/console.h>
1617
#include <linux/io.h>
1718
#include <linux/module.h>
1819
#include <linux/of.h>
@@ -34,6 +35,29 @@ struct uniphier8250_priv {
3435
spinlock_t atomic_write_lock;
3536
};
3637

38+
#ifdef CONFIG_SERIAL_8250_CONSOLE
39+
static int __init uniphier_early_console_setup(struct earlycon_device *device,
40+
const char *options)
41+
{
42+
if (!device->port.membase)
43+
return -ENODEV;
44+
45+
/* This hardware always expects MMIO32 register interface. */
46+
device->port.iotype = UPIO_MEM32;
47+
device->port.regshift = 2;
48+
49+
/*
50+
* Do not touch the divisor register in early_serial8250_setup();
51+
* we assume it has been initialized by a boot loader.
52+
*/
53+
device->baud = 0;
54+
55+
return early_serial8250_setup(device, options);
56+
}
57+
OF_EARLYCON_DECLARE(uniphier, "socionext,uniphier-uart",
58+
uniphier_early_console_setup);
59+
#endif
60+
3761
/*
3862
* The register map is slightly different from that of 8250.
3963
* IO callbacks must be overridden for correct access to FCR, LCR, and MCR.

0 commit comments

Comments
 (0)