Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <dianders@chromium.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20200507130644.v4.10.If2deff9679a62c1ce1b8f2558a8635dc837adf8c@changeid
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>

authored by

Douglas Anderson and committed by
Daniel Thompson
205b5bdd a4912303

+32
+32
drivers/tty/serial/qcom_geni_serial.c
··· 1090 1090 __qcom_geni_serial_console_write(&dev->port, s, n); 1091 1091 } 1092 1092 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 + 1093 1123 static int __init qcom_geni_serial_earlycon_setup(struct earlycon_device *dev, 1094 1124 const char *opt) 1095 1125 { ··· 1166 1136 1167 1137 dev->con->write = qcom_geni_serial_earlycon_write; 1168 1138 dev->con->setup = NULL; 1139 + qcom_geni_serial_enable_early_read(&se, dev->con); 1140 + 1169 1141 return 0; 1170 1142 } 1171 1143 OF_EARLYCON_DECLARE(qcom_geni, "qcom,geni-debug-uart",