Commit 695ae513cdf6c671cda5c32e4a2974e3119450d0

Authored by Peng Fan
Committed by Ye Li
1 parent aea7115085

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)

Showing 4 changed files with 79 additions and 0 deletions Side-by-side Diff

drivers/serial/Kconfig
... ... @@ -643,5 +643,11 @@
643 643 depends on MPC8XX_CONS
644 644 default 0
645 645  
  646 +config XEN_DEBUG_SERIAL
  647 + bool "XEN debug serial support"
  648 + depends on XEN
  649 + help
  650 + This is not pv console, it needs CONFIG_VERBOSE_DEBUG in XEN.
  651 +
646 652 endmenu
drivers/serial/Makefile
... ... @@ -51,6 +51,7 @@
51 51 obj-$(CONFIG_MVEBU_A3700_UART) += serial_mvebu_a3700.o
52 52 obj-$(CONFIG_MPC8XX_CONS) += serial_mpc8xx.o
53 53 obj-$(CONFIG_NULLDEV_SERIAL) += serial_nulldev.o
  54 +obj-$(CONFIG_XEN_DEBUG_SERIAL) += serial_xen.o
54 55  
55 56 ifndef CONFIG_SPL_BUILD
56 57 obj-$(CONFIG_USB_TTY) += usbtty.o
drivers/serial/serial.c
... ... @@ -150,6 +150,7 @@
150 150 serial_initfunc(sh_serial_initialize);
151 151 serial_initfunc(stm32_serial_initialize);
152 152 serial_initfunc(uartlite_serial_initialize);
  153 +serial_initfunc(xen_debug_serial_initialize);
153 154 serial_initfunc(zynq_serial_initialize);
154 155  
155 156 /**
... ... @@ -237,6 +238,7 @@
237 238 sh_serial_initialize();
238 239 stm32_serial_initialize();
239 240 uartlite_serial_initialize();
  241 + xen_debug_serial_initialize();
240 242 zynq_serial_initialize();
241 243  
242 244 serial_assign(default_serial_console()->name);
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