Porting siemens jailhouse to SP7021
Porting siemens jailhouse to SP7021
Project home: GitHub - siemens/jailhouse: Linux-based partitioning hypervisor
U-Boot
1. Add PCSI support
commit a6e96cdbb2ec426f7219a9017dc4617ea88f547d
Author: qinjian <qinjian@sunmedia.com.cn>
Date: Wed Jul 1 15:41:58 2020 +0800
[arm] support arm psci
arch/arm/mach-pentagram/Kconfig | 1 +
arch/arm/mach-pentagram/Makefile | 3 +++
arch/arm/mach-pentagram/cpu.c | 17 +++++++++++++++++
arch/arm/mach-pentagram/nonsec_virt.S | 35 +++++++++++++++++++++++++++++++++++
arch/arm/mach-pentagram/psci.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
board/sunplus/pentagram_board/Makefile | 1 -
board/sunplus/pentagram_board/board.c | 15 ---------------
board/sunplus/pentagram_board/nonsec_virt.S | 35 -----------------------------------
8 files changed, 103 insertions(+), 51 deletions(-)
2. Enable HYP mode
diff --git a/arch/arm/mach-pentagram/Kconfig b/arch/arm/mach-pentagram/Kconfig
index 595187a..0cd8572 100644
--- a/arch/arm/mach-pentagram/Kconfig
+++ b/arch/arm/mach-pentagram/Kconfig
@@ -6,8 +6,8 @@ choice
config TARGET_PENTAGRAM_COMMON
bool "pentagram common board"
select CPU_V7A
- #select CPU_V7_HAS_NONSEC
- #select CPU_V7_HAS_VIRT
+ select CPU_V7_HAS_NONSEC
+ select CPU_V7_HAS_VIRT
select ARCH_SUPPORT_PSCI
select SYS_THUMB_BUILD
3. Adjust fdt loading address from EOM(End of memory, reserved for jailhouse) to a specified address
diff --git a/include/configs/pentagram_common.h b/include/configs/pentagram_common.h
index a60a470..ac45783 100644
--- a/include/configs/pentagram_common.h
+++ b/include/configs/pentagram_common.h
@@ -283,6 +283,7 @@
"stdin=" STDIN_CFG "\0" \
"stdout=" STDOUT_CFG "\0" \
"stderr=" STDOUT_CFG "\0" \
+"fdt_high=0x04000000 \0" \
"bootinfo_base=" __stringify(SP_BOOTINFO_BASE) "\0" \
"addr_src_kernel=" __stringify(CONFIG_SRCADDR_KERNEL) "\0" \
"addr_src_nonos=" __stringify(CONFIG_SRCADDR_NONOS) "\0" \
Linux Kernel
1. Enable PCSI support
commit 00a0c3604d46e388de83a3bf1996c10d17f1ec2c
Author: qinjian <qinjian@sunmedia.com.cn>
Date: Wed Jul 1 15:43:49 2020 +0800
[arm] support arm psci
diff --git a/arch/arm/mach-pentagram/Kconfig b/arch/arm/mach-pentagram/Kconfig
index cbf526f..fd46879 100644
--- a/arch/arm/mach-pentagram/Kconfig
+++ b/arch/arm/mach-pentagram/Kconfig
@@ -49,6 +49,7 @@ config MACH_PENTAGRAM_SP7021_ACHIP
select ARM_GIC
select SP_INTC
select HAVE_SMP
+ select ARM_PSCI
select COMMON_CLK_SP7021
select CLKSRC_SP_TIMER
select PINCTRL
2. Add jailhouse ivshmem drivers
commit 17fba2f99efad0449cff464b193d07c55b793c57
Author: qinjian <qinjian@sunmedia.com.cn>
Date: Wed Jul 8 10:16:39 2020 +0800
[driver] add ivshmem-net & uio_ivshmem driver for jailhouse
drivers/net/Kconfig | 4 +
drivers/net/Makefile | 2 +
drivers/net/ivshmem-net.c | 1097 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
drivers/uio/Kconfig | 8 ++
drivers/uio/Makefile | 1 +
drivers/uio/uio_ivshmem.c | 241 ++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 1353 insertions(+)
3. Modify defconfig & Kconfig
diff --git a/arch/arm/configs/sp7021_chipC_emu_initramfs_defconfig b/arch/arm/configs/sp7021_chipC_emu_initramfs_defconfig
index bff30d6..a4fe9da 100644
--- a/arch/arm/configs/sp7021_chipC_emu_initramfs_defconfig
+++ b/arch/arm/configs/sp7021_chipC_emu_initramfs_defconfig
@@ -25,7 +25,7 @@ CONFIG_ARCH_PENTAGRAM=y
# CONFIG_VDSO is not set
CONFIG_SMP=y
CONFIG_HAVE_ARM_ARCH_TIMER=y
-CONFIG_THUMB2_KERNEL=y
+# CONFIG_THUMB2_KERNEL is not set
CONFIG_HIGHMEM=y
# CONFIG_HIGHPTE is not set
CONFIG_FORCE_MAX_ZONEORDER=12
diff --git a/arch/arm/mach-pentagram/Kconfig b/arch/arm/mach-pentagram/Kconfig
index fd46879..1c2ae47 100644
--- a/arch/arm/mach-pentagram/Kconfig
+++ b/arch/arm/mach-pentagram/Kconfig
@@ -49,6 +49,10 @@ config MACH_PENTAGRAM_SP7021_ACHIP
select ARM_GIC
select SP_INTC
select HAVE_SMP
+ select FORCE_PCI
+ select PCI_HOST_GENERIC
+ select UIO
+ select UIO_IVSHMEM
+ select IVSHMEM_NET
select ARM_PSCI
select COMMON_CLK_SP7021
select CLKSRC_SP_TIMER
4. Modify dts: kernel bootargs, reserved 128MB for jailhouse
diff --git a/arch/arm/boot/dts/sp7021-ev.dts b/arch/arm/boot/dts/sp7021-ev.dts
index de5cebe..5cf7a32 100644
--- a/arch/arm/boot/dts/sp7021-ev.dts
+++ b/arch/arm/boot/dts/sp7021-ev.dts
@@ -6,7 +6,7 @@
model = "SP7021/CA7/Ev";
chosen {
- bootargs = "console=ttyS0,115200 root=/dev/ram rw loglevel=8 user_debug=255 earlyprintk";
+ bootargs = "console=ttyS0,115200 root=/dev/ram rw loglevel=8 user_debug=255 earlyprintk mem=384M";
stdout-path = "serial0:115200n8";
};
5. Modify io_map virt-base to avoid confliction with jailhouse
diff --git a/arch/arm/mach-pentagram/include/mach/io_map_sp7021.h b/arch/arm/mach-pentagram/include/mach/io_map_sp7021.h
index 0eed70a..8b76586 100644
--- a/arch/arm/mach-pentagram/include/mach/io_map_sp7021.h
+++ b/arch/arm/mach-pentagram/include/mach/io_map_sp7021.h
@@ -25,7 +25,7 @@
/*****************
* VA chain
*****************/
-#define VA_B_REG 0xF8000000
+#define VA_B_REG 0xFC000000
#define VA_A_REG (VA_B_REG + SIZE_B_REG)
#define VA_B_SRAM0 (VA_A_REG + SIZE_A_REG)
#define VA_A_WORKMEM_SRAM0 (VA_B_SRAM0 + SIZE_B_SRAM0)
Jailhouse
1. Add SP7021 system/cell configs, uart-sunplus driver
commit 3934d0e7eb0dc671f32ae8c7f78ee24922e7b6a1
Author: qinjian <qinjian@sunmedia.com.cn>
Date: Wed Jul 8 11:23:10 2020 +0800
[sp7021] add sunplus sp7021 support
configs/arm/sp7021-inmate-demo.c | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
configs/arm/sp7021.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
hypervisor/Makefile | 2 +-
hypervisor/arch/arm-common/dbg-write.c | 2 ++
hypervisor/arch/arm-common/include/asm/uart.h | 2 +-
hypervisor/uart-sunplus.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/jailhouse/console.h | 1 +
inmates/lib/arm-common/Makefile.lib | 2 +-
inmates/lib/arm-common/timing.c | 4 ++++
inmates/lib/arm-common/uart-sunplus.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inmates/lib/arm-common/uart.c | 2 ++
11 files changed, 466 insertions(+), 3 deletions(-)
diff --git a/configs/arm/sp7021-inmate-demo.c b/configs/arm/sp7021-inmate-demo.c
new file mode 100644
index 0000000..2cb6cf8
--- /dev/null
+++ b/configs/arm/sp7021-inmate-demo.c
@@ -0,0 +1,138 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Configuration for demo inmate on Sunplus SP7021:
+ * 1 CPU, 64K RAM, serial ports 0-3, GPIO PA
+ *
+ * Copyright (c) Siemens AG, 2014-2016
+ *
+ * Authors:
+ * Jan Kiszka <jan.kiszka@siemens.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/types.h>
+#include <jailhouse/cell-config.h>
+
+struct {
+ struct jailhouse_cell_desc cell;
+ __u64 cpus[1];
+ struct jailhouse_memory mem_regions[9];
+ struct jailhouse_irqchip irqchips[1];
+ struct jailhouse_pci_device pci_devices[1];
+} __attribute__((packed)) config = {
+ .cell = {
+ .signature = JAILHOUSE_CELL_DESC_SIGNATURE,
+ .revision = JAILHOUSE_CONFIG_REVISION,
+ .name = "sp7021-inmate-demo",
+ .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
+
+ .cpu_set_size = sizeof(config.cpus),
+ .num_memory_regions = ARRAY_SIZE(config.mem_regions),
+ .num_irqchips = ARRAY_SIZE(config.irqchips),
+ .num_pci_devices = ARRAY_SIZE(config.pci_devices),
+
+ .vpci_irq_base = 125,
+
+ .console = {
+ .address = 0x9c000900,
+ .type = JAILHOUSE_CON_TYPE_SUNPLUS,
+ .flags = JAILHOUSE_CON_ACCESS_MMIO |
+ JAILHOUSE_CON_REGDIST_4,
+ },
+ },
+
+ .cpus = {
+ 0x8,
+ },
+
+ .mem_regions = {
+ /* IVSHMEM shared memory regions (demo) */
+ {
+ .phys_start = 0x1f6f0000,
+ .virt_start = 0x1f6f0000,
+ .size = 0x1000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
+ },
+ {
+ .phys_start = 0x1f6f1000,
+ .virt_start = 0x1f6f1000,
+ .size = 0x9000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+ JAILHOUSE_MEM_ROOTSHARED,
+ },
+ {
+ .phys_start = 0x1f6fa000,
+ .virt_start = 0x1f6fa000,
+ .size = 0x2000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
+ },
+ {
+ .phys_start = 0x1f6fc000,
+ .virt_start = 0x1f6fc000,
+ .size = 0x2000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+ JAILHOUSE_MEM_ROOTSHARED,
+ },
+ {
+ .phys_start = 0x1f6fe000,
+ .virt_start = 0x1f6fe000,
+ .size = 0x2000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_ROOTSHARED,
+ },
+ /* REG_B */ {
+ .phys_start = 0x9c000000,
+ .virt_start = 0x9c000000,
+ .size = 0x2000000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+ JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32 | JAILHOUSE_MEM_ROOTSHARED,
+ },
+ /* REG_A */ {
+ .phys_start = 0x9ec00000,
+ .virt_start = 0x9ec00000,
+ .size = 0x400000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+ JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32 | JAILHOUSE_MEM_ROOTSHARED,
+ },
+ /* RAM */ {
+ .phys_start = 0x1f600000,
+ .virt_start = 0,
+ .size = 0x00010000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+ JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_LOADABLE,
+ },
+ /* communication region */ {
+ .virt_start = 0x80000000,
+ .size = 0x00001000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+ JAILHOUSE_MEM_COMM_REGION,
+ },
+ },
+
+ .irqchips = {
+ /* GIC */ {
+ .address = 0x9f101000,
+ .pin_base = 32,
+ .pin_bitmap = {
+ 0,
+ 0,
+ 0,
+ 1 << (157-128),
+ },
+ },
+ },
+
+ .pci_devices = {
+ {
+ .type = JAILHOUSE_PCI_TYPE_IVSHMEM,
+ .bdf = 0 << 3,
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
+ .shmem_regions_start = 0,
+ .shmem_dev_id = 1,
+ .shmem_peers = 3,
+ .shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
+ },
+ },
+};
diff --git a/configs/arm/sp7021.c b/configs/arm/sp7021.c
new file mode 100644
index 0000000..e721ced
--- /dev/null
+++ b/configs/arm/sp7021.c
@@ -0,0 +1,163 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Test configuration for Sunplus SP7021 (quad-core Cortex-A7, 512MB RAM)
+ *
+ * Copyright (c) Siemens AG, 2014-2016
+ *
+ * Authors:
+ * Jan Kiszka <jan.kiszka@siemens.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/types.h>
+#include <jailhouse/cell-config.h>
+
+struct {
+ struct jailhouse_system header;
+ __u64 cpus[1];
+ struct jailhouse_memory mem_regions[13];
+ struct jailhouse_irqchip irqchips[1];
+ struct jailhouse_pci_device pci_devices[2];
+} __attribute__((packed)) config = {
+ .header = {
+ .signature = JAILHOUSE_SYSTEM_SIGNATURE,
+ .revision = JAILHOUSE_CONFIG_REVISION,
+ .flags = JAILHOUSE_SYS_VIRTUAL_DEBUG_CONSOLE,
+ .hypervisor_memory = {
+ .phys_start = 0x1f800000,
+ .size = 0x800000 - 0x100000, /* -1MB (PSCI) */
+ },
+ .debug_console = {
+ .address = 0x9c000900,
+ .size = 0x80,
+ .type = JAILHOUSE_CON_TYPE_SUNPLUS,
+ .flags = JAILHOUSE_CON_ACCESS_MMIO |
+ JAILHOUSE_CON_REGDIST_4,
+ },
+ .platform_info = {
+ .pci_mmconfig_base = 0x42000000,
+ .pci_mmconfig_end_bus = 0,
+ .pci_is_virtual = 1,
+ .arm = {
+ .gic_version = 2,
+ .gicd_base = 0x9f101000,
+ .gicc_base = 0x9f102000,
+ .gich_base = 0x9f104000,
+ .gicv_base = 0x9f106000,
+ .maintenance_irq = 25,
+ },
+ },
+ .root_cell = {
+ .name = "Sunplus-SP7021",
+
+ .cpu_set_size = sizeof(config.cpus),
+ .num_memory_regions = ARRAY_SIZE(config.mem_regions),
+ .num_irqchips = ARRAY_SIZE(config.irqchips),
+ .num_pci_devices = ARRAY_SIZE(config.pci_devices),
+
+ .vpci_irq_base = 108,
+ },
+ },
+
+ .cpus = {
+ 0xf,
+ },
+
+ .mem_regions = {
+ /* IVSHMEM shared memory regions (demo) */
+ {
+ .phys_start = 0x1f6f0000,
+ .virt_start = 0x1f6f0000,
+ .size = 0x1000,
+ .flags = JAILHOUSE_MEM_READ,
+ },
+ {
+ .phys_start = 0x1f6f1000,
+ .virt_start = 0x1f6f1000,
+ .size = 0x9000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
+ },
+ {
+ .phys_start = 0x1f6fa000,
+ .virt_start = 0x1f6fa000,
+ .size = 0x2000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE,
+ },
+ {
+ .phys_start = 0x1f6fc000,
+ .virt_start = 0x1f6fc000,
+ .size = 0x2000,
+ .flags = JAILHOUSE_MEM_READ,
+ },
+ {
+ .phys_start = 0x1f6fe000,
+ .virt_start = 0x1f6fe000,
+ .size = 0x2000,
+ .flags = JAILHOUSE_MEM_READ,
+ },
+ /* IVSHMEM shared memory region */
+ JAILHOUSE_SHMEM_NET_REGIONS(0x1f700000, 0),
+ /* REG_A (permissive) */ {
+ .phys_start = 0x9ec00000,
+ .virt_start = 0x9ec00000,
+ .size = 0x400000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+ JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32,
+ },
+ /* REG_B (permissive) */ {
+ .phys_start = 0x9c000000,
+ .virt_start = 0x9c000000,
+ .size = 0x2000000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+ JAILHOUSE_MEM_IO | JAILHOUSE_MEM_IO_32,
+ },
+ /* SRAM (permissive) */ {
+ .phys_start = 0x9e800000,
+ .virt_start = 0x9e800000,
+ .size = 0xa000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+ JAILHOUSE_MEM_EXECUTE,
+ },
+ /* RAM */ {
+ .phys_start = 0x00000000,
+ .virt_start = 0x00000000,
+ .size = 0x1f620000,
+ .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+ JAILHOUSE_MEM_EXECUTE,
+ },
+ },
+
+ .irqchips = {
+ /* GIC */ {
+ .address = 0x9f101000,
+ .pin_base = 32,
+ .pin_bitmap = {
+ 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
+ },
+ },
+ },
+
+ .pci_devices = {
+ {
+ .type = JAILHOUSE_PCI_TYPE_IVSHMEM,
+ .bdf = 0 << 3,
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
+ .shmem_regions_start = 0,
+ .shmem_dev_id = 0,
+ .shmem_peers = 3,
+ .shmem_protocol = JAILHOUSE_SHMEM_PROTO_UNDEFINED,
+ },
+ {
+ .type = JAILHOUSE_PCI_TYPE_IVSHMEM,
+ .bdf = 1 << 3,
+ .bar_mask = JAILHOUSE_IVSHMEM_BAR_MASK_INTX,
+ .shmem_regions_start = 5,
+ .shmem_dev_id = 0,
+ .shmem_peers = 2,
+ .shmem_protocol = JAILHOUSE_SHMEM_PROTO_VETH,
+ },
+ },
+};
diff --git a/hypervisor/Makefile b/hypervisor/Makefile
index 893ead4..5aa8b79 100644
--- a/hypervisor/Makefile
+++ b/hypervisor/Makefile
@@ -37,7 +37,7 @@ KBUILD_CFLAGS += -include $(INC_CONFIG_H)
endif
CORE_OBJECTS = setup.o printk.o paging.o control.o lib.o mmio.o pci.o ivshmem.o
-CORE_OBJECTS += uart.o uart-8250.o
+CORE_OBJECTS += uart.o uart-8250.o uart-sunplus.o
ifdef CONFIG_JAILHOUSE_GCOV
CORE_OBJECTS += gcov.o
diff --git a/hypervisor/arch/arm-common/dbg-write.c b/hypervisor/arch/arm-common/dbg-write.c
index 64dfef2..f9be626 100644
--- a/hypervisor/arch/arm-common/dbg-write.c
+++ b/hypervisor/arch/arm-common/dbg-write.c
@@ -38,6 +38,8 @@ void arch_dbg_write_init(void)
uart = &uart_scifa_ops;
else if (con_type == JAILHOUSE_CON_TYPE_IMX)
uart = &uart_imx_ops;
+ else if (con_type == JAILHOUSE_CON_TYPE_SUNPLUS)
+ uart = &uart_sunplus_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 9317446..b5c666a 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_imx_ops;
+ uart_hscif_ops, uart_scifa_ops, uart_imx_ops, uart_sunplus_ops;
diff --git a/hypervisor/uart-sunplus.c b/hypervisor/uart-sunplus.c
new file mode 100644
index 0000000..c08bedf
--- /dev/null
+++ b/hypervisor/uart-sunplus.c
@@ -0,0 +1,67 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Copyright (c) ARM Limited, 2014
+ * Copyright (c) Siemens AG, 2014-2017
+ *
+ * Authors:
+ * Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
+ * Jan Kiszka <jan.kiszka@siemens.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/control.h>
+#include <jailhouse/mmio.h>
+#include <jailhouse/uart.h>
+
+/* uart register map */
+#define SP_UART_DATA 0x00
+#define SP_UART_LSR 0x04
+#define SP_UART_MSR 0x08
+#define SP_UART_LCR 0x0C
+#define SP_UART_MCR 0x10
+#define SP_UART_DIV_L 0x14
+#define SP_UART_DIV_H 0x18
+#define SP_UART_ISC 0x1C
+
+/* lsr */
+#define SP_UART_LSR_TXE (1 << 6) /* 1: trasmit fifo is empty */
+
+static void reg_out_mmio32(struct uart_chip *chip, unsigned int reg, u32 value)
+{
+ mmio_write32(chip->virt_base + reg, value);
+}
+
+static u32 reg_in_mmio32(struct uart_chip *chip, unsigned int reg)
+{
+ return mmio_read32(chip->virt_base + reg);
+}
+
+static void uart_init(struct uart_chip *chip)
+{
+ /* only initialise if divider is not zero */
+ if (!chip->debug_console->divider)
+ return;
+
+ /* TODO: init uart */
+}
+
+static bool uart_is_busy(struct uart_chip *chip)
+{
+ return !(chip->reg_in(chip, SP_UART_LSR) & SP_UART_LSR_TXE);
+}
+
+static void uart_write_char(struct uart_chip *chip, char c)
+{
+ chip->reg_out(chip, SP_UART_DATA, c);
+}
+
+struct uart_chip uart_sunplus_ops = {
+ .init = uart_init,
+ .is_busy = uart_is_busy,
+ .write_char = uart_write_char,
+ .reg_out = reg_out_mmio32,
+ .reg_in = reg_in_mmio32,
+};
diff --git a/include/jailhouse/console.h b/include/jailhouse/console.h
index a6efd37..521de2b 100644
--- a/include/jailhouse/console.h
+++ b/include/jailhouse/console.h
@@ -49,6 +49,7 @@
#define JAILHOUSE_CON_TYPE_HSCIF 0x0006
#define JAILHOUSE_CON_TYPE_SCIFA 0x0007
#define JAILHOUSE_CON_TYPE_IMX 0x0008
+#define JAILHOUSE_CON_TYPE_SUNPLUS 0x0009
/* Flags: bit 0 is used to select PIO (cleared) or MMIO (set) access */
#define JAILHOUSE_CON_ACCESS_PIO 0x0000
diff --git a/inmates/lib/arm-common/Makefile.lib b/inmates/lib/arm-common/Makefile.lib
index 3d7b335..3049d7f 100644
--- a/inmates/lib/arm-common/Makefile.lib
+++ b/inmates/lib/arm-common/Makefile.lib
@@ -39,7 +39,7 @@
objs-y := ../string.o ../cmdline.o ../setup.o ../alloc.o ../uart-8250.o
objs-y += ../printk.o ../pci.o
objs-y += printk.o gic.o mem.o pci.o timing.o setup.o uart.o
-objs-y += uart-xuartps.o uart-mvebu.o uart-hscif.o uart-scifa.o uart-imx.o
+objs-y += uart-xuartps.o uart-mvebu.o uart-hscif.o uart-scifa.o uart-imx.o uart-sunplus.o
objs-y += uart-pl011.o
objs-y += gic-v2.o gic-v3.o
diff --git a/inmates/lib/arm-common/timing.c b/inmates/lib/arm-common/timing.c
index b8e8c04..238741f 100644
--- a/inmates/lib/arm-common/timing.c
+++ b/inmates/lib/arm-common/timing.c
@@ -43,10 +43,14 @@
unsigned long timer_get_frequency(void)
{
+#if 0
unsigned long freq;
arm_read_sysreg(CNTFRQ_EL0, freq);
return freq;
+#else
+ return 27000000; // SP7021 read CNTFRQ ret 0
+#endif
}
u64 timer_get_ticks(void)
diff --git a/inmates/lib/arm-common/uart-sunplus.c b/inmates/lib/arm-common/uart-sunplus.c
new file mode 100644
index 0000000..3c39c3b
--- /dev/null
+++ b/inmates/lib/arm-common/uart-sunplus.c
@@ -0,0 +1,86 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Copyright (c) ARM Limited, 2014
+ * Copyright (c) Siemens AG, 2014
+ *
+ * Authors:
+ * Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
+ * Jan Kiszka <jan.kiszka@siemens.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>
+
+/* uart register map */
+#define SP_UART_DATA 0x00
+#define SP_UART_LSR 0x04
+#define SP_UART_MSR 0x08
+#define SP_UART_LCR 0x0C
+#define SP_UART_MCR 0x10
+#define SP_UART_DIV_L 0x14
+#define SP_UART_DIV_H 0x18
+#define SP_UART_ISC 0x1C
+
+/* lsr */
+#define SP_UART_LSR_TXE (1 << 6) /* 1: trasmit fifo is empty */
+
+static void reg_out_mmio32(struct uart_chip *chip, unsigned int reg, u32 value)
+{
+ mmio_write32(chip->base + reg, value);
+}
+
+static u32 reg_in_mmio32(struct uart_chip *chip, unsigned int reg)
+{
+ return mmio_read32(chip->base + reg);
+}
+
+static void uart_sunplus_init(struct uart_chip *chip)
+{
+ chip->base = (void *)(u32)cmdline_parse_int("uart", (u32)chip->base);
+ if (chip->divider) {
+ /* TODO: init uart */
+ }
+}
+
+static bool uart_sunplus_is_busy(struct uart_chip *chip)
+{
+ return !(chip->reg_in(chip, SP_UART_LSR) & SP_UART_LSR_TXE);
+}
+
+static void uart_sunplus_write(struct uart_chip *chip, char c)
+{
+ chip->reg_out(chip, SP_UART_DATA, c);
+}
+
+DEFINE_UART_REG(sunplus, "sunplus", JAILHOUSE_CON_TYPE_SUNPLUS,
+ reg_out_mmio32, reg_in_mmio32);
diff --git a/inmates/lib/arm-common/uart.c b/inmates/lib/arm-common/uart.c
index 8855d47..da6de9d 100644
--- a/inmates/lib/arm-common/uart.c
+++ b/inmates/lib/arm-common/uart.c
@@ -45,6 +45,7 @@ DECLARE_UART(imx);
DECLARE_UART(mvebu);
DECLARE_UART(pl011);
DECLARE_UART(scifa);
+DECLARE_UART(sunplus);
DECLARE_UART(xuartps);
struct uart_chip *uart_array[] = {
@@ -54,6 +55,7 @@ struct uart_chip *uart_array[] = {
&UART_OPS_NAME(mvebu),
&UART_OPS_NAME(pl011),
&UART_OPS_NAME(scifa),
+ &UART_OPS_NAME(sunplus),
&UART_OPS_NAME(xuartps),
NULL
};
, multiple selections available,
Related content
Transplant Opencv to SP7021+Raspbian
Transplant Opencv to SP7021+Raspbian
Read with this
Software Package of SP7350 IO Board
Software Package of SP7350 IO Board
More like this
SP7350 Components Support List
SP7350 Components Support List
More like this
In-system Programming Flash Devices
In-system Programming Flash Devices
More like this
Using Secure Boot
Using Secure Boot
More like this
Software Package of C3V-W Dual (LPDDR4) EVB
Software Package of C3V-W Dual (LPDDR4) EVB
More like this