From: Peng Fang <peng....@nxp.com>

Signed-off-by: Peng Fang <peng....@nxp.com>
Signed-off-by: Claudio Scordino <clau...@evidence.eu.com>
---
 hypervisor/arch/arm-common/Kbuild             |  2 +-
 hypervisor/arch/arm-common/dbg-write.c        |  2 +
 hypervisor/arch/arm-common/include/asm/uart.h |  2 +-
 hypervisor/arch/arm-common/uart-imx.c         | 39 +++++++++++++++++
 include/jailhouse/cell-config.h               |  1 +
 inmates/lib/arm-common/Makefile.lib           |  2 +-
 inmates/lib/arm-common/include/uart.h         |  1 +
 inmates/lib/arm-common/printk.c               |  2 +
 inmates/lib/arm-common/uart-imx.c             | 63 +++++++++++++++++++++++++++
 9 files changed, 111 insertions(+), 3 deletions(-)
 create mode 100644 hypervisor/arch/arm-common/uart-imx.c
 create mode 100644 inmates/lib/arm-common/uart-imx.c

diff --git a/hypervisor/arch/arm-common/Kbuild 
b/hypervisor/arch/arm-common/Kbuild
index 7132312..08cc454 100644
--- a/hypervisor/arch/arm-common/Kbuild
+++ b/hypervisor/arch/arm-common/Kbuild
@@ -17,7 +17,7 @@ ccflags-$(CONFIG_JAILHOUSE_GCOV) += -fprofile-arcs 
-ftest-coverage
 
 OBJS-y += dbg-write.o lib.o psci.o control.o paging.o mmu_cell.o setup.o
 OBJS-y += irqchip.o pci.o ivshmem.o uart-pl011.o uart-xuartps.o uart-mvebu.o
-OBJS-y += uart-hscif.o uart-scifa.o
+OBJS-y += uart-hscif.o uart-scifa.o uart-imx.o
 OBJS-y += gic-v2.o gic-v3.o
 
 COMMON_OBJECTS = $(addprefix ../arm-common/,$(OBJS-y))
diff --git a/hypervisor/arch/arm-common/dbg-write.c 
b/hypervisor/arch/arm-common/dbg-write.c
index 4056778..e9e1467 100644
--- a/hypervisor/arch/arm-common/dbg-write.c
+++ b/hypervisor/arch/arm-common/dbg-write.c
@@ -36,6 +36,8 @@ void arch_dbg_write_init(void)
                uart = &uart_hscif_ops;
        else if (con_type == JAILHOUSE_CON1_TYPE_SCIFA)
                uart = &uart_scifa_ops;
+       else if (con_type == JAILHOUSE_CON1_TYPE_IMX)
+               uart = &uart_imx_ops;
 
        if (uart) {
                uart->debug_console = &system_config->debug_console;
diff --git a/hypervisor/arch/arm-common/include/asm/uart.h 
b/hypervisor/arch/arm-common/include/asm/uart.h
index 6301549..9317446 100644
--- a/hypervisor/arch/arm-common/include/asm/uart.h
+++ b/hypervisor/arch/arm-common/include/asm/uart.h
@@ -11,4 +11,4 @@
  */
 
 extern struct uart_chip uart_pl011_ops, uart_xuartps_ops, uart_mvebu_ops,
-                       uart_hscif_ops, uart_scifa_ops;
+                       uart_hscif_ops, uart_scifa_ops, uart_imx_ops;
diff --git a/hypervisor/arch/arm-common/uart-imx.c 
b/hypervisor/arch/arm-common/uart-imx.c
new file mode 100644
index 0000000..849f8fc
--- /dev/null
+++ b/hypervisor/arch/arm-common/uart-imx.c
@@ -0,0 +1,39 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Copyright 2017 NXP
+ *
+ * Authors:
+ *  Peng Fan <peng....@nxp.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+#include <jailhouse/mmio.h>
+#include <jailhouse/uart.h>
+
+#define UTS                    0xb4
+#define UTXD                   0x40
+#define UTS_TXEMPTY            (1 << 6)
+
+static void uart_init(struct uart_chip *chip)
+{
+       /* Initialization currently done by Linux */
+}
+
+static bool uart_is_busy(struct uart_chip *chip)
+{
+       return !(mmio_read32(chip->virt_base + UTS) & UTS_TXEMPTY);
+}
+
+static void uart_write_char(struct uart_chip *chip, char c)
+{
+       mmio_write32(chip->virt_base + UTXD, c);
+}
+
+struct uart_chip uart_imx_ops = {
+       .init = uart_init,
+       .is_busy = uart_is_busy,
+       .write_char = uart_write_char,
+};
diff --git a/include/jailhouse/cell-config.h b/include/jailhouse/cell-config.h
index f1810c9..15ed7cd 100644
--- a/include/jailhouse/cell-config.h
+++ b/include/jailhouse/cell-config.h
@@ -190,6 +190,7 @@ struct jailhouse_iommu {
 #define JAILHOUSE_CON1_TYPE_MVEBU      0x0005
 #define JAILHOUSE_CON1_TYPE_HSCIF      0x0006
 #define JAILHOUSE_CON1_TYPE_SCIFA      0x0007
+#define JAILHOUSE_CON1_TYPE_IMX                0x0008
 #define JAILHOUSE_CON1_TYPE_MASK       0x000f
 
 #define CON1_TYPE(flags) ((flags) & JAILHOUSE_CON1_TYPE_MASK)
diff --git a/inmates/lib/arm-common/Makefile.lib 
b/inmates/lib/arm-common/Makefile.lib
index c820199..323cabb 100644
--- a/inmates/lib/arm-common/Makefile.lib
+++ b/inmates/lib/arm-common/Makefile.lib
@@ -41,7 +41,7 @@ GCOV_PROFILE := n
 OBJS-y := ../string.o ../cmdline.o
 OBJS-y += printk.o gic.o timer.o
 OBJS-y += uart-jailhouse.o uart-pl011.o uart-8250.o uart-8250-8.o
-OBJS-y += uart-xuartps.o uart-mvebu.o uart-hscif.o uart-scifa.o
+OBJS-y += uart-xuartps.o uart-mvebu.o uart-hscif.o uart-scifa.o uart-imx.o
 OBJS-y += gic-v2.o gic-v3.o
 
 COMMON_OBJECTS = $(addprefix ../arm-common/,$(OBJS-y))
diff --git a/inmates/lib/arm-common/include/uart.h 
b/inmates/lib/arm-common/include/uart.h
index bc65861..abe211e 100644
--- a/inmates/lib/arm-common/include/uart.h
+++ b/inmates/lib/arm-common/include/uart.h
@@ -57,3 +57,4 @@ extern struct uart_chip uart_xuartps_ops;
 extern struct uart_chip uart_mvebu_ops;
 extern struct uart_chip uart_hscif_ops;
 extern struct uart_chip uart_scifa_ops;
+extern struct uart_chip uart_imx_ops;
diff --git a/inmates/lib/arm-common/printk.c b/inmates/lib/arm-common/printk.c
index 2a4b27a..73091c3 100644
--- a/inmates/lib/arm-common/printk.c
+++ b/inmates/lib/arm-common/printk.c
@@ -98,6 +98,8 @@ static void console_init(void)
                chip = &uart_hscif_ops;
        else if (!strcmp(type, "SCIFA"))
                chip = &uart_scifa_ops;
+       else if (!strcmp(type, "IMX-UART"))
+               chip = &uart_imx_ops;
 
        if (!chip)
                return;
diff --git a/inmates/lib/arm-common/uart-imx.c 
b/inmates/lib/arm-common/uart-imx.c
new file mode 100644
index 0000000..830a9cd
--- /dev/null
+++ b/inmates/lib/arm-common/uart-imx.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2017 NXP
+ *
+ * Authors:
+ *  Peng Fan <peng....@nxp.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ *
+ * Alternatively, you can use or redistribute this file under the following
+ * BSD license:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <inmate.h>
+#include <uart.h>
+
+#define UTS                    0xb4
+#define UTXD                   0x40
+#define UTS_TXEMPTY            (1 << 6)
+
+static void uart_init(struct uart_chip *chip)
+{
+       /* Initialization currently done by Linux. */
+}
+
+static bool uart_is_busy(struct uart_chip *chip)
+{
+       return !(mmio_read32(chip->base + UTS) & UTS_TXEMPTY);
+}
+
+static void uart_write(struct uart_chip *chip, char c)
+{
+       mmio_write32(chip->base + UTXD, c);
+}
+
+struct uart_chip uart_imx_ops = {
+       .init = uart_init,
+       .is_busy = uart_is_busy,
+       .write = uart_write,
+};
-- 
2.7.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jailhouse-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to