Commit c5e7467d authored by Douglas Anderson's avatar Douglas Anderson Committed by Daniel Thompson

serial: 8250_early: Support kgdboc_earlycon

Implement the read() function in the early console driver.  With
recent kgdb patches this allows you to use kgdb to debug fairly early
into the system boot.

We only bother implementing this if polling is enabled since kgdb
can't be enabled without that.
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Link: https://lore.kernel.org/r/20200507130644.v4.11.I8f668556c244776523320a95b09373a86eda11b7@changeidSigned-off-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
parent 205b5bdd
......@@ -109,6 +109,28 @@ static void early_serial8250_write(struct console *console,
uart_console_write(port, s, count, serial_putc);
}
#ifdef CONFIG_CONSOLE_POLL
static int early_serial8250_read(struct console *console,
char *s, unsigned int count)
{
struct earlycon_device *device = console->data;
struct uart_port *port = &device->port;
unsigned int status;
int num_read = 0;
while (num_read < count) {
status = serial8250_early_in(port, UART_LSR);
if (!(status & UART_LSR_DR))
break;
s[num_read++] = serial8250_early_in(port, UART_RX);
}
return num_read;
}
#else
#define early_serial8250_read NULL
#endif
static void __init init_port(struct earlycon_device *device)
{
struct uart_port *port = &device->port;
......@@ -149,6 +171,7 @@ int __init early_serial8250_setup(struct earlycon_device *device,
init_port(device);
device->con->write = early_serial8250_write;
device->con->read = early_serial8250_read;
return 0;
}
EARLYCON_DECLARE(uart8250, early_serial8250_setup);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment