Skip to content

Commit 205b5bd

Browse files
diandersDaniel Thompson
authored andcommitted
serial: qcom_geni_serial: 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: Douglas Anderson <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Link: https://lore.kernel.org/r/20200507130644.v4.10.If2deff9679a62c1ce1b8f2558a8635dc837adf8c@changeid Signed-off-by: Daniel Thompson <[email protected]>
1 parent a491230 commit 205b5bd

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

drivers/tty/serial/qcom_geni_serial.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,36 @@ static void qcom_geni_serial_earlycon_write(struct console *con,
10901090
__qcom_geni_serial_console_write(&dev->port, s, n);
10911091
}
10921092

1093+
#ifdef CONFIG_CONSOLE_POLL
1094+
static int qcom_geni_serial_earlycon_read(struct console *con,
1095+
char *s, unsigned int n)
1096+
{
1097+
struct earlycon_device *dev = con->data;
1098+
struct uart_port *uport = &dev->port;
1099+
int num_read = 0;
1100+
int ch;
1101+
1102+
while (num_read < n) {
1103+
ch = qcom_geni_serial_get_char(uport);
1104+
if (ch == NO_POLL_CHAR)
1105+
break;
1106+
s[num_read++] = ch;
1107+
}
1108+
1109+
return num_read;
1110+
}
1111+
1112+
static void __init qcom_geni_serial_enable_early_read(struct geni_se *se,
1113+
struct console *con)
1114+
{
1115+
geni_se_setup_s_cmd(se, UART_START_READ, 0);
1116+
con->read = qcom_geni_serial_earlycon_read;
1117+
}
1118+
#else
1119+
static inline void qcom_geni_serial_enable_early_read(struct geni_se *se,
1120+
struct console *con) { }
1121+
#endif
1122+
10931123
static int __init qcom_geni_serial_earlycon_setup(struct earlycon_device *dev,
10941124
const char *opt)
10951125
{
@@ -1136,6 +1166,8 @@ static int __init qcom_geni_serial_earlycon_setup(struct earlycon_device *dev,
11361166

11371167
dev->con->write = qcom_geni_serial_earlycon_write;
11381168
dev->con->setup = NULL;
1169+
qcom_geni_serial_enable_early_read(&se, dev->con);
1170+
11391171
return 0;
11401172
}
11411173
OF_EARLYCON_DECLARE(qcom_geni, "qcom,geni-debug-uart",

0 commit comments

Comments
 (0)