AMBA PL011 looks like PL010 with a minor change in the registers. I'd like to move both to amba-pl01x-earlycon.c but I cannot because the EARLYCON_START() macro always uses the same symbol name. Signed-off-by: Domenico Andreoli --- drivers/tty/serial/amba-pl011.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) Index: b/drivers/tty/serial/amba-pl011.c =================================================================== --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -2020,6 +2021,46 @@ static void __exit pl011_exit(void) arch_initcall(pl011_init); module_exit(pl011_exit); +static int __earlyconinit pl011_earlycon_probe(struct earlycon_drv *drv) +{ + volatile uint32_t *cr; + + /* this driver doesn't support probing of the base address */ + if (!drv->base) + return -EINVAL; + + cr = (volatile uint32_t *) (drv->base + UART011_CR); + return (*cr & UART01x_CR_UARTEN) ? 0 : -1; +} + +static void __earlyconinit pl011_earlycon_putc(struct earlycon_drv *drv, int ch) +{ + volatile uint32_t *fr, *dr; + + fr = (volatile uint32_t *) (drv->base + UART01x_FR); + while (*fr & UART01x_FR_TXFF) + barrier(); + + dr = (volatile uint32_t *) (drv->base + UART01x_DR); + *dr = ch; +} + +static void __earlyconinit pl011_earlycon_flush(struct earlycon_drv *drv) +{ + volatile uint32_t *fr; + + fr = (volatile uint32_t *) (drv->base + UART01x_FR); + while (*fr & UART01x_FR_BUSY) + barrier(); +} + + +EARLYCON_START("amba-pl011") + .probe = pl011_earlycon_probe, + .putc = pl011_earlycon_putc, + .flush = pl011_earlycon_flush, +EARLYCON_END + MODULE_AUTHOR("ARM Ltd/Deep Blue Solutions Ltd"); MODULE_DESCRIPTION("ARM AMBA serial port driver"); MODULE_LICENSE("GPL");