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

tty: serial: cpm_uart: Add udbg support for enabling xmon

In order to use xmon with powerpc 8xx, the serial driver
must provide udbg_putc() and udpb_getc().

Provide them via cpm_put_poll_char() and cpm_get_poll_char().

This requires CONFIG_CONSOLE_POLL.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/e4471bf81089252470efb3eed735d71a5b32adbd.1608716197.git.christophe.leroy@csgroup.eu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Christophe Leroy and committed by
Greg Kroah-Hartman
a6052609 345523fa

+39 -1
+39 -1
drivers/tty/serial/cpm_uart/cpm_uart_core.c
··· 1107 1107 ch[0] = (char)c; 1108 1108 cpm_uart_early_write(pinfo, ch, 1, false); 1109 1109 } 1110 + 1111 + static struct uart_port *udbg_port; 1112 + 1113 + static void udbg_cpm_putc(char c) 1114 + { 1115 + if (c == '\n') 1116 + cpm_put_poll_char(udbg_port, '\r'); 1117 + cpm_put_poll_char(udbg_port, c); 1118 + } 1119 + 1120 + static int udbg_cpm_getc_poll(void) 1121 + { 1122 + int c = cpm_get_poll_char(udbg_port); 1123 + 1124 + return c == NO_POLL_CHAR ? -1 : c; 1125 + } 1126 + 1127 + static int udbg_cpm_getc(void) 1128 + { 1129 + int c; 1130 + 1131 + while ((c = udbg_cpm_getc_poll()) == -1) 1132 + cpu_relax(); 1133 + return c; 1134 + } 1135 + 1110 1136 #endif /* CONFIG_CONSOLE_POLL */ 1111 1137 1112 1138 static const struct uart_ops cpm_uart_pops = { ··· 1263 1237 } 1264 1238 1265 1239 #ifdef CONFIG_PPC_EARLY_DEBUG_CPM 1266 - udbg_putc = NULL; 1240 + #ifdef CONFIG_CONSOLE_POLL 1241 + if (!udbg_port) 1242 + #endif 1243 + udbg_putc = NULL; 1267 1244 #endif 1268 1245 1269 1246 return cpm_uart_request_port(&pinfo->port); ··· 1386 1357 1387 1358 uart_set_options(port, co, baud, parity, bits, flow); 1388 1359 cpm_line_cr_cmd(pinfo, CPM_CR_RESTART_TX); 1360 + 1361 + #ifdef CONFIG_CONSOLE_POLL 1362 + if (!udbg_port) { 1363 + udbg_port = &pinfo->port; 1364 + udbg_putc = udbg_cpm_putc; 1365 + udbg_getc = udbg_cpm_getc; 1366 + udbg_getc_poll = udbg_cpm_getc_poll; 1367 + } 1368 + #endif 1389 1369 1390 1370 return 0; 1391 1371 }