Skip to content

Commit 195867f

Browse files
b49020Daniel Thompson
authored andcommitted
serial: amba-pl011: Support kgdboc_earlycon
Implement the read() function in the early console driver. With recently added kgdboc_earlycon feature, 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: Sumit Garg <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Signed-off-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/20200507130644.v4.12.I8ee0811f0e0816dd8bfe7f2f5540b3dba074fae8@changeid Signed-off-by: Daniel Thompson <[email protected]>
1 parent c5e7467 commit 195867f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

drivers/tty/serial/amba-pl011.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,6 +2435,37 @@ static void pl011_early_write(struct console *con, const char *s, unsigned n)
24352435
uart_console_write(&dev->port, s, n, pl011_putc);
24362436
}
24372437

2438+
#ifdef CONFIG_CONSOLE_POLL
2439+
static int pl011_getc(struct uart_port *port)
2440+
{
2441+
if (readl(port->membase + UART01x_FR) & UART01x_FR_RXFE)
2442+
return NO_POLL_CHAR;
2443+
2444+
if (port->iotype == UPIO_MEM32)
2445+
return readl(port->membase + UART01x_DR);
2446+
else
2447+
return readb(port->membase + UART01x_DR);
2448+
}
2449+
2450+
static int pl011_early_read(struct console *con, char *s, unsigned int n)
2451+
{
2452+
struct earlycon_device *dev = con->data;
2453+
int ch, num_read = 0;
2454+
2455+
while (num_read < n) {
2456+
ch = pl011_getc(&dev->port);
2457+
if (ch == NO_POLL_CHAR)
2458+
break;
2459+
2460+
s[num_read++] = ch;
2461+
}
2462+
2463+
return num_read;
2464+
}
2465+
#else
2466+
#define pl011_early_read NULL
2467+
#endif
2468+
24382469
/*
24392470
* On non-ACPI systems, earlycon is enabled by specifying
24402471
* "earlycon=pl011,<address>" on the kernel command line.
@@ -2454,6 +2485,7 @@ static int __init pl011_early_console_setup(struct earlycon_device *device,
24542485
return -ENODEV;
24552486

24562487
device->con->write = pl011_early_write;
2488+
device->con->read = pl011_early_read;
24572489

24582490
return 0;
24592491
}

0 commit comments

Comments
 (0)