Commit 6596b48ccdfe420c7e4862cb0ea315750f002ba8
1 parent
8ece41f15c
Exists in
smarc-8m-android-10.0.0_2.6.0
and in
1 other branch
MLK-18577-4 serial: add simple xen debug output
Add simple debug output when uboot runs in a VM. Needs DM_SERIAL disabled, and XEN_DEBUG_SERIAL enabled. Signed-off-by: Peng Fan <peng.fan@nxp.com> (cherry picked from commit b41475b83c8d7c83bd6069f4fea05d3405e81e50) (cherry picked from commit 695ae513cdf6c671cda5c32e4a2974e3119450d0) (cherry picked from commit d4189c87bbd3a5fd0abc74f7e9ce12a2f86c0de0)
Showing 4 changed files with 79 additions and 0 deletions Side-by-side Diff
drivers/serial/Kconfig
drivers/serial/Makefile
... | ... | @@ -70,6 +70,7 @@ |
70 | 70 | obj-$(CONFIG_OMAP_SERIAL) += serial_omap.o |
71 | 71 | obj-$(CONFIG_MTK_SERIAL) += serial_mtk.o |
72 | 72 | obj-$(CONFIG_SIFIVE_SERIAL) += serial_sifive.o |
73 | +obj-$(CONFIG_XEN_DEBUG_SERIAL) += serial_xen.o | |
73 | 74 | |
74 | 75 | ifndef CONFIG_SPL_BUILD |
75 | 76 | obj-$(CONFIG_USB_TTY) += usbtty.o |
drivers/serial/serial.c
... | ... | @@ -126,6 +126,7 @@ |
126 | 126 | serial_initfunc(pxa_serial_initialize); |
127 | 127 | serial_initfunc(sh_serial_initialize); |
128 | 128 | serial_initfunc(mtk_serial_initialize); |
129 | +serial_initfunc(xen_debug_serial_initialize); | |
129 | 130 | |
130 | 131 | /** |
131 | 132 | * serial_register() - Register serial driver with serial driver core |
... | ... | @@ -180,6 +181,7 @@ |
180 | 181 | pxa_serial_initialize(); |
181 | 182 | sh_serial_initialize(); |
182 | 183 | mtk_serial_initialize(); |
184 | + xen_debug_serial_initialize(); | |
183 | 185 | |
184 | 186 | serial_assign(default_serial_console()->name); |
185 | 187 | } |
drivers/serial/serial_xen.c
1 | +/* | |
2 | + * Copyright 2018 NXP | |
3 | + * | |
4 | + * SPDX-License-Identifier: GPL-2.0+ | |
5 | + */ | |
6 | + | |
7 | +#include <common.h> | |
8 | +#include <dm.h> | |
9 | +#include <errno.h> | |
10 | +#include <serial.h> | |
11 | + | |
12 | +extern void xenprintf(const char *buf); | |
13 | +extern void xenprintc(const char c); | |
14 | +#ifndef CONFIG_DM_SERIAL | |
15 | + | |
16 | +static void xen_debug_serial_putc(const char c) | |
17 | +{ | |
18 | + /* If \n, also do \r */ | |
19 | + if (c == '\n') | |
20 | + serial_putc('\r'); | |
21 | + | |
22 | + xenprintc(c); | |
23 | +} | |
24 | + | |
25 | +static void xen_debug_serial_puts(const char *buf) | |
26 | +{ | |
27 | + xenprintf(buf); | |
28 | +} | |
29 | + | |
30 | +static int xen_debug_serial_start(void) | |
31 | +{ | |
32 | + return 0; | |
33 | +} | |
34 | + | |
35 | +static void xen_debug_serial_setbrg(void) | |
36 | +{ | |
37 | + | |
38 | +} | |
39 | + | |
40 | +static int xen_debug_serial_getc(void) | |
41 | +{ | |
42 | + return 0; | |
43 | +} | |
44 | + | |
45 | +static int xen_debug_serial_tstc(void) | |
46 | +{ | |
47 | + return 0; | |
48 | +} | |
49 | + | |
50 | +static struct serial_device xen_debug_serial_drv = { | |
51 | + .name = "xen_debug_serial", | |
52 | + .start = xen_debug_serial_start, | |
53 | + .stop = NULL, | |
54 | + .setbrg = xen_debug_serial_setbrg, | |
55 | + .putc = xen_debug_serial_putc, | |
56 | + .puts = xen_debug_serial_puts, | |
57 | + .getc = xen_debug_serial_getc, | |
58 | + .tstc = xen_debug_serial_tstc, | |
59 | +}; | |
60 | + | |
61 | +void xen_debug_serial_initialize(void) | |
62 | +{ | |
63 | + serial_register(&xen_debug_serial_drv); | |
64 | +} | |
65 | + | |
66 | +__weak struct serial_device *default_serial_console(void) | |
67 | +{ | |
68 | + return &xen_debug_serial_drv; | |
69 | +} | |
70 | +#endif |