]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
arm: Add support for Banana Pi board
authorJan Kiszka <jan.kiszka@siemens.com>
Wed, 12 Nov 2014 12:01:43 +0000 (13:01 +0100)
committerJan Kiszka <jan.kiszka@siemens.com>
Thu, 8 Jan 2015 12:01:23 +0000 (13:01 +0100)
The Banana Pi is a cheap ARMv7 board with a dual-core Cortex-A7, thus
with virtualization support. Upstream U-boot and kernel work fine -
ideal conditions. We just lack some IOMMU on that board, but it remains
handy for testing purposes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
13 files changed:
configs/bananapi-gic-demo.c [new file with mode: 0644]
configs/bananapi-uart-demo.c [new file with mode: 0644]
configs/bananapi.c [new file with mode: 0644]
hypervisor/arch/arm/Makefile
hypervisor/arch/arm/include/asm/platform.h
hypervisor/arch/arm/include/asm/uart-8250-dw.h [new file with mode: 0644]
hypervisor/arch/arm/smp-sun7i.c [new file with mode: 0644]
hypervisor/arch/arm/uart-8250-dw.c [new file with mode: 0644]
inmates/lib/arm/Makefile.lib
inmates/lib/arm/include/mach-sun7i/mach/gic_v2.h [new file with mode: 0644]
inmates/lib/arm/include/mach-sun7i/mach/timer.h [new file with mode: 0644]
inmates/lib/arm/include/mach-sun7i/mach/uart.h [new file with mode: 0644]
inmates/lib/arm/uart-8250-dw.c [new file with mode: 0644]

diff --git a/configs/bananapi-gic-demo.c b/configs/bananapi-gic-demo.c
new file mode 100644 (file)
index 0000000..f34a2a4
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Configuration for gic-demo inmate on Banana Pi:
+ * 1 CPU, 64K RAM, serial ports 4-7, CCU+GPIO
+ *
+ * Copyright (c) Siemens AG, 2014
+ *
+ * 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 <linux/types.h>
+#include <jailhouse/cell-config.h>
+
+#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])
+
+struct {
+       struct jailhouse_cell_desc cell;
+       __u64 cpus[1];
+       struct jailhouse_memory mem_regions[3];
+} __attribute__((packed)) config = {
+       .cell = {
+               .name = "bananapi-gic-demo",
+               .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
+
+               .cpu_set_size = sizeof(config.cpus),
+               .num_memory_regions = ARRAY_SIZE(config.mem_regions),
+       },
+
+       .cpus = {
+               0x2,
+       },
+
+       .mem_regions = {
+               /* CCU, Ints, GPIO, Timer */ {
+                       .phys_start = 0x01c20000,
+                       .virt_start = 0x01c20000,
+                       .size = 0x1000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_IO,
+               },
+               /* UART 4-7 */ {
+                       .phys_start = 0x01c29000,
+                       .virt_start = 0x01c29000,
+                       .size = 0x1000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_IO,
+               },
+               /* RAM */ {
+                       .phys_start = 0x7bfe0000,
+                       .virt_start = 0,
+                       .size = 0x00010000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_LOADABLE,
+               },
+       },
+};
diff --git a/configs/bananapi-uart-demo.c b/configs/bananapi-uart-demo.c
new file mode 100644 (file)
index 0000000..3934d67
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Configuration for uart-demo inmate on Banana Pi:
+ * 1 CPU, 64K RAM, serial ports 4-7, CCU
+ *
+ * Copyright (c) Siemens AG, 2014
+ *
+ * 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 <linux/types.h>
+#include <jailhouse/cell-config.h>
+
+#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])
+
+struct {
+       struct jailhouse_cell_desc cell;
+       __u64 cpus[1];
+       struct jailhouse_memory mem_regions[3];
+} __attribute__((packed)) config = {
+       .cell = {
+               .name = "bananapi-uart-demo",
+               .flags = JAILHOUSE_CELL_PASSIVE_COMMREG,
+
+               .cpu_set_size = sizeof(config.cpus),
+               .num_memory_regions = ARRAY_SIZE(config.mem_regions),
+       },
+
+       .cpus = {
+               0x2,
+       },
+
+       .mem_regions = {
+               /* CCU, Ints, GPIO, Timer */ {
+                       .phys_start = 0x01c20000,
+                       .virt_start = 0x01c20000,
+                       .size = 0x1000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_IO,
+               },
+               /* UART 4-7 */ {
+                       .phys_start = 0x01c29000,
+                       .virt_start = 0x01c29000,
+                       .size = 0x1000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_IO,
+               },
+               /* RAM */ {
+                       .phys_start = 0x7bff0000,
+                       .virt_start = 0,
+                       .size = 0x00010000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_EXECUTE | JAILHOUSE_MEM_LOADABLE,
+               },
+       }
+};
diff --git a/configs/bananapi.c b/configs/bananapi.c
new file mode 100644 (file)
index 0000000..edc6477
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Test configuration for Banana Pi board (A20 dual-core Cortex-A7, 1G RAM)
+ *
+ * Copyright (c) Siemens AG, 2014
+ *
+ * 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 <linux/types.h>
+#include <jailhouse/cell-config.h>
+
+#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])
+
+struct {
+       struct jailhouse_system header;
+       __u64 cpus[1];
+       struct jailhouse_memory mem_regions[10];
+       struct jailhouse_irqchip irqchips[1];
+} __attribute__((packed)) config = {
+       .header = {
+               .hypervisor_memory = {
+                       .phys_start = 0x7c000000,
+                       .size = 0x4000000,
+               },
+               .debug_uart = {
+                       .phys_start = 0x01c28000,
+                       .size = 0x1000,
+                       .flags = JAILHOUSE_MEM_IO,
+               },
+               .root_cell = {
+                       .name = "Banana-Pi",
+
+                       .cpu_set_size = sizeof(config.cpus),
+                       .num_memory_regions = ARRAY_SIZE(config.mem_regions),
+                       .num_irqchips = 1,
+               },
+       },
+
+       .cpus = {
+               0x3,
+       },
+
+       .mem_regions = {
+               /* SPI */ {
+                       .phys_start = 0x01c05000,
+                       .virt_start = 0x01c05000,
+                       .size = 0x00001000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_IO,
+               },
+               /* MMC */ {
+                       .phys_start = 0x01c0f000,
+                       .virt_start = 0x01c0f000,
+                       .size = 0x00001000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_IO,
+               },
+               /* USB + PMU1 */ {
+                       .phys_start = 0x01c14000,
+                       .virt_start = 0x01c14000,
+                       .size = 0x00001000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_IO,
+               },
+               /* SATA */ {
+                       .phys_start = 0x01c18000,
+                       .virt_start = 0x01c18000,
+                       .size = 0x00001000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_IO,
+               },
+               /* USB + PMU2 */ {
+                       .phys_start = 0x01c1c000,
+                       .virt_start = 0x01c1c000,
+                       .size = 0x00001000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_IO,
+               },
+               /* CCU, Ints, GPIO, Timer */ {
+                       .phys_start = 0x01c20000,
+                       .virt_start = 0x01c20000,
+                       .size = 0x1000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_IO,
+               },
+               /* UART0-3 */ {
+                       .phys_start = 0x01c28000,
+                       .virt_start = 0x01c28000,
+                       .size = 0x1000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_IO,
+               },
+               /* GMAC */ {
+                       .phys_start = 0x01c50000,
+                       .virt_start = 0x01c50000,
+                       .size = 0x00010000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_IO,
+               },
+               /* HSTIMER */ {
+                       .phys_start = 0x01c60000,
+                       .virt_start = 0x01c60000,
+                       .size = 0x00001000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_IO,
+               },
+               /* RAM */ {
+                       .phys_start = 0x40000000,
+                       .virt_start = 0x40000000,
+                       .size = 0x3c000000,
+                       .flags = JAILHOUSE_MEM_READ | JAILHOUSE_MEM_WRITE |
+                               JAILHOUSE_MEM_EXECUTE,
+               },
+       },
+       .irqchips = {
+               /* GIC */ {
+                       .address = 0x2f000000,
+                       .pin_bitmap = 0xffffffffffffffff,
+               },
+       },
+
+};
index 6b6ae4a1ea81a030679ebfcb0e2ca63d25613adf..c9186d348ecc470c30073aea15a48d489f0a1322 100644 (file)
@@ -24,4 +24,6 @@ obj-y += irqchip.o gic-common.o
 obj-$(CONFIG_ARM_GIC_V3) += gic-v3.o
 obj-$(CONFIG_ARM_GIC) += gic-v2.o
 obj-$(CONFIG_SERIAL_AMBA_PL011) += dbg-write-pl011.o
+obj-$(CONFIG_SERIAL_8250_DW) += uart-8250-dw.o
 obj-$(CONFIG_ARCH_VEXPRESS) += smp-vexpress.o
+obj-$(CONFIG_ARCH_SUN7I) += smp-sun7i.o
index 7c4e244a710194c74a2aa7327a64ae1e201454de..1a2d4b3c9754d42a2f596d39b6960ed78f78b195 100644 (file)
 
 #endif /* CONFIG_ARCH_VEXPRESS */
 
+#ifdef CONFIG_ARCH_SUN7I
+
+#  define GICD_BASE    ((void *)0x01c81000)
+#  define GICD_SIZE    0x1000
+#  define GICC_BASE    ((void *)0x01c82000)
+#  define GICC_SIZE    0x2000
+#  define GICH_BASE    ((void *)0x01c84000)
+#  define GICH_SIZE    0x2000
+#  define GICV_BASE    ((void *)0x01c86000)
+#  define GICV_SIZE    0x2000
+
+#  include <asm/gic_v2.h>
+
+# define MAINTENANCE_IRQ 25
+
+#endif /* CONFIG_ARCH_SUN7I */
+
 #define HOTPLUG_SPIN   1
 /*
 #define HOTPLUG_PSCI   1
diff --git a/hypervisor/arch/arm/include/asm/uart-8250-dw.h b/hypervisor/arch/arm/include/asm/uart-8250-dw.h
new file mode 100644 (file)
index 0000000..59eac1e
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Copyright (c) Siemens AG, 2014
+ *
+ * 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/mmio.h>
+#include <jailhouse/processor.h>
+#include <asm/debug.h>
+
+#define UART_TX                        0x0
+#define UART_DLL               0x0
+#define UART_DLM               0x4
+#define UART_LCR               0xc
+#define  UART_LCR_8N1          0x03
+#define  UART_LCR_DLAB         0x80
+#define UART_LSR               0x14
+#define  UART_LSR_THRE         0x20
+
+static void uart_init(struct uart_chip *chip)
+{
+       mmio_write32(chip->virt_base + UART_LCR, UART_LCR_DLAB);
+       mmio_write32(chip->virt_base + UART_DLL, 0x0d);
+       mmio_write32(chip->virt_base + UART_DLM, 0);
+       mmio_write32(chip->virt_base + UART_LCR, UART_LCR_8N1);
+}
+
+static void uart_wait(struct uart_chip *chip)
+{
+       while (!(mmio_read32(chip->virt_base + UART_LSR) & UART_LSR_THRE))
+               cpu_relax();
+}
+
+static void uart_busy(struct uart_chip *chip)
+{
+}
+
+static void uart_write(struct uart_chip *chip, char c)
+{
+       mmio_write32(chip->virt_base + UART_TX, c);
+}
diff --git a/hypervisor/arch/arm/smp-sun7i.c b/hypervisor/arch/arm/smp-sun7i.c
new file mode 100644 (file)
index 0000000..abb52d0
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Copyright (c) Siemens AG, 2014
+ *
+ * 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 <asm/cell.h>
+#include <asm/psci.h>
+#include <asm/smp.h>
+
+static struct smp_ops sun7i_smp_ops = {
+       .type = SMP_SPIN,
+       .init = psci_cell_init,
+       .cpu_spin = psci_emulate_spin,
+};
+
+void register_smp_ops(struct cell *cell)
+{
+       cell->arch.smp = &sun7i_smp_ops;
+}
diff --git a/hypervisor/arch/arm/uart-8250-dw.c b/hypervisor/arch/arm/uart-8250-dw.c
new file mode 100644 (file)
index 0000000..4b2ada9
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+#include <asm/uart-8250-dw.h>
+
+/* All the helpers are in the header, to make them re-usable by the inmates */
+void uart_chip_init(struct uart_chip *chip)
+{
+       chip->wait = uart_wait;
+       chip->busy = uart_busy;
+       chip->write = uart_write;
+
+       uart_init(chip);
+}
index 0992fd55910eb4c0b8c4834e69b4cb65bd19d828..68c4cc2c42002d847dfcf58e93bbd99d27db17c1 100644 (file)
@@ -28,10 +28,12 @@ define DECLARE_TARGETS =
 endef
 
 mach-$(CONFIG_ARCH_VEXPRESS)           := vexpress
+mach-$(CONFIG_ARCH_SUN7I)              := sun7i
 
 gic-$(CONFIG_ARM_GIC)                  := gic-v2.o
 gic-$(CONFIG_ARM_GIC_V3)               := gic-v3.o
 uart-$(CONFIG_SERIAL_AMBA_PL011)       := uart-pl011.o
+uart-$(CONFIG_SERIAL_8250_DW)          := uart-8250-dw.o
 
 MACHINE                                        := mach-$(mach-y)
 DRIVERS                                        := $(gic-y) $(uart-y)
diff --git a/inmates/lib/arm/include/mach-sun7i/mach/gic_v2.h b/inmates/lib/arm/include/mach-sun7i/mach/gic_v2.h
new file mode 100644 (file)
index 0000000..b7181da
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Copyright (c) Siemens AG, 2014
+ *
+ * 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.
+ */
+
+#define GICD_BASE      ((void *)0x01c81000)
+#define GICC_BASE      ((void *)0x01c82000)
diff --git a/inmates/lib/arm/include/mach-sun7i/mach/timer.h b/inmates/lib/arm/include/mach-sun7i/mach/timer.h
new file mode 100644 (file)
index 0000000..78088ae
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Copyright (c) Siemens AG, 2014
+ *
+ * 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.
+ */
+
+#define TIMER_IRQ      27
+#define TIMER_FREQ     24000000
diff --git a/inmates/lib/arm/include/mach-sun7i/mach/uart.h b/inmates/lib/arm/include/mach-sun7i/mach/uart.h
new file mode 100644 (file)
index 0000000..cf4a61d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Jailhouse, a Linux-based partitioning hypervisor
+ *
+ * Copyright (c) Siemens AG, 2014
+ *
+ * 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.
+ */
+
+#define UART_BASE      ((void *)0x01c29c00)
diff --git a/inmates/lib/arm/uart-8250-dw.c b/inmates/lib/arm/uart-8250-dw.c
new file mode 100644 (file)
index 0000000..4f3c223
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+#include <asm/uart-8250-dw.h>
+#include <mach/uart.h>
+
+void uart_chip_init(struct uart_chip *chip)
+{
+       chip->virt_base = UART_BASE;
+       chip->wait = uart_wait;
+       chip->write = uart_write;
+       chip->busy = uart_busy;
+       uart_init(chip);
+}