* [Qemu-devel] [PATCH v2 0/6] Add the ZynqMP PMU and IPI
@ 2017-09-01 21:00 Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 1/6] xlnx-zynqmp-pmu: Initial commit of the ZynqMP PMU Alistair Francis
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: Alistair Francis @ 2017-09-01 21:00 UTC (permalink / raw)
To: qemu-devel, edgar.iglesias, edgar.iglesias
Cc: alistair.francis, alistair23, qemu-arm
This series adds the ZynqMP Power Management Unit (PMU) machine with basic
functionality.
The machine only has the CPU and memory connected, but that is enough
to run some of the ROM code on the machine.
The series also adds the IPI device and connects it to the ZynqMP ARM
side and the ZynqMP PMU. These IPI devices don't connect between the ARM
and MicroBlaze instances though.
The PMU machine is missing an interrupt controller, which needs to be
added later on.
Alistair Francis (6):
xlnx-zynqmp-pmu: Initial commit of the ZynqMP PMU
xlnx-zynqmp-pmu: Add the CPU and memory
aarch64-softmmu.mak: Use an ARM specific config
xlnx-zynqmp-ipi: Initial version of the Xilinx IPI device
xlnx-zynqmp-pmu: Connect the IPI device to the PMU
xlnx-zynqmp: Connect the IPI device to the ZynqMP SoC
default-configs/aarch64-softmmu.mak | 1 +
default-configs/microblaze-softmmu.mak | 1 +
hw/arm/Makefile.objs | 2 +-
hw/arm/xlnx-zynqmp.c | 14 ++
hw/display/Makefile.objs | 2 +-
hw/dma/Makefile.objs | 2 +-
hw/intc/Makefile.objs | 1 +
hw/intc/xlnx-zynqmp-ipi.c | 377 +++++++++++++++++++++++++++++++++
hw/microblaze/Makefile.objs | 1 +
hw/microblaze/xlnx-zynqmp-pmu.c | 172 +++++++++++++++
include/hw/arm/xlnx-zynqmp.h | 2 +
include/hw/intc/xlnx-zynqmp-ipi.h | 57 +++++
12 files changed, 629 insertions(+), 3 deletions(-)
create mode 100644 hw/intc/xlnx-zynqmp-ipi.c
create mode 100644 hw/microblaze/xlnx-zynqmp-pmu.c
create mode 100644 include/hw/intc/xlnx-zynqmp-ipi.h
--
2.11.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH v2 1/6] xlnx-zynqmp-pmu: Initial commit of the ZynqMP PMU
2017-09-01 21:00 [Qemu-devel] [PATCH v2 0/6] Add the ZynqMP PMU and IPI Alistair Francis
@ 2017-09-01 21:00 ` Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 2/6] xlnx-zynqmp-pmu: Add the CPU and memory Alistair Francis
` (4 subsequent siblings)
5 siblings, 0 replies; 11+ messages in thread
From: Alistair Francis @ 2017-09-01 21:00 UTC (permalink / raw)
To: qemu-devel, edgar.iglesias, edgar.iglesias
Cc: alistair.francis, alistair23, qemu-arm
The Xilinx ZynqMP SoC has two main processing systems in it. The ARM
processing system (which is already modeled in QEMU) and the MicroBlaze
Power Management Unit (PMU). This is the inital work for adding support
for the PMU.
The PMU susbsystem runs along side the ARM system on hardware, but due
to architecture limitations in QEMU the two instances are seperate for
the time being.
Let's follow the same setup we do with the ARM system, where there is an
SoC device and a ZCU102 board. Although the PMU is less board specific
we are still going to follow the same split as maybe in future we can
connect the PMU device to the ARM ZCU102 board. As the machine will be
fairly small let's keep them both together in one file.
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---
hw/microblaze/Makefile.objs | 1 +
hw/microblaze/xlnx-zynqmp-pmu.c | 83 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 84 insertions(+)
create mode 100644 hw/microblaze/xlnx-zynqmp-pmu.c
diff --git a/hw/microblaze/Makefile.objs b/hw/microblaze/Makefile.objs
index b2517d87fe..ae9fd40de7 100644
--- a/hw/microblaze/Makefile.objs
+++ b/hw/microblaze/Makefile.objs
@@ -1,3 +1,4 @@
obj-y += petalogix_s3adsp1800_mmu.o
obj-y += petalogix_ml605_mmu.o
+obj-y += xlnx-zynqmp-pmu.o
obj-y += boot.o
diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c
new file mode 100644
index 0000000000..fc3c8b236f
--- /dev/null
+++ b/hw/microblaze/xlnx-zynqmp-pmu.c
@@ -0,0 +1,83 @@
+/*
+ * Xilinx Zynq MPSoC PMU (Power Management Unit) emulation
+ *
+ * Copyright (C) 2017 Xilinx Inc
+ * Written by Alistair Francis <alistair.francis@xilinx.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "qemu-common.h"
+#include "hw/boards.h"
+#include "cpu.h"
+
+/* Define the PMU device */
+
+#define TYPE_XLNX_ZYNQMP_PMU "xlnx,zynqmp-pmu"
+#define XLNX_ZYNQMP_PMU(obj) OBJECT_CHECK(XlnxZynqMPPMUState, (obj), \
+ TYPE_XLNX_ZYNQMP_PMU)
+
+typedef struct XlnxZynqMPPMUState {
+ /*< private >*/
+ DeviceState parent_obj;
+
+ /*< public >*/
+} XlnxZynqMPPMUState;
+
+static void xlnx_zynqmp_pmu_init(Object *obj)
+{
+
+}
+
+static void xlnx_zynqmp_pmu_realize(DeviceState *dev, Error **errp)
+{
+
+}
+
+static void xlnx_zynqmp_pmu_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+
+ dc->realize = xlnx_zynqmp_pmu_realize;
+}
+
+static const TypeInfo xlnx_zynqmp_pmu_type_info = {
+ .name = TYPE_XLNX_ZYNQMP_PMU,
+ .parent = TYPE_DEVICE,
+ .instance_size = sizeof(XlnxZynqMPPMUState),
+ .instance_init = xlnx_zynqmp_pmu_init,
+ .class_init = xlnx_zynqmp_pmu_class_init,
+};
+
+static void xlnx_zynqmp_pmu_register_types(void)
+{
+ type_register_static(&xlnx_zynqmp_pmu_type_info);
+}
+
+type_init(xlnx_zynqmp_pmu_register_types)
+
+/* Define the PMU Machine */
+
+static void xlnx_zcu102_pmu_init(MachineState *machine)
+{
+
+}
+
+static void xlnx_zcu102_pmu_machine_init(MachineClass *mc)
+{
+ mc->desc = "Xilinx ZynqMP ZCU102 PMU machine";
+ mc->init = xlnx_zcu102_pmu_init;
+}
+
+DEFINE_MACHINE("xlnx-zcu102-pmu", xlnx_zcu102_pmu_machine_init)
+
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH v2 2/6] xlnx-zynqmp-pmu: Add the CPU and memory
2017-09-01 21:00 [Qemu-devel] [PATCH v2 0/6] Add the ZynqMP PMU and IPI Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 1/6] xlnx-zynqmp-pmu: Initial commit of the ZynqMP PMU Alistair Francis
@ 2017-09-01 21:00 ` Alistair Francis
2017-09-04 7:32 ` Igor Mammedov
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 3/6] aarch64-softmmu.mak: Use an ARM specific config Alistair Francis
` (3 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Alistair Francis @ 2017-09-01 21:00 UTC (permalink / raw)
To: qemu-devel, edgar.iglesias, edgar.iglesias
Cc: alistair.francis, alistair23, qemu-arm
Connect the MicroBlaze CPU and the ROM and RAM memory regions.
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---
hw/microblaze/xlnx-zynqmp-pmu.c | 65 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 63 insertions(+), 2 deletions(-)
diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c
index fc3c8b236f..33584cfa4d 100644
--- a/hw/microblaze/xlnx-zynqmp-pmu.c
+++ b/hw/microblaze/xlnx-zynqmp-pmu.c
@@ -18,8 +18,11 @@
#include "qemu/osdep.h"
#include "qapi/error.h"
#include "qemu-common.h"
+#include "exec/address-spaces.h"
#include "hw/boards.h"
+#include "hw/qdev-properties.h"
#include "cpu.h"
+#include "boot.h"
/* Define the PMU device */
@@ -27,21 +30,51 @@
#define XLNX_ZYNQMP_PMU(obj) OBJECT_CHECK(XlnxZynqMPPMUState, (obj), \
TYPE_XLNX_ZYNQMP_PMU)
+#define XLNX_ZYNQMP_PMU_ROM_SIZE 0x8000
+#define XLNX_ZYNQMP_PMU_ROM_ADDR 0xFFD00000
+#define XLNX_ZYNQMP_PMU_RAM_ADDR 0xFFDC0000
+
typedef struct XlnxZynqMPPMUState {
/*< private >*/
DeviceState parent_obj;
/*< public >*/
+ MicroBlazeCPU cpu;
} XlnxZynqMPPMUState;
static void xlnx_zynqmp_pmu_init(Object *obj)
{
+ XlnxZynqMPPMUState *s = XLNX_ZYNQMP_PMU(obj);
+ object_initialize(&s->cpu, sizeof(s->cpu),
+ TYPE_MICROBLAZE_CPU);
+ object_property_add_child(obj, "pmu-cpu[*]", OBJECT(&s->cpu),
+ &error_abort);
}
static void xlnx_zynqmp_pmu_realize(DeviceState *dev, Error **errp)
{
-
+ XlnxZynqMPPMUState *s = XLNX_ZYNQMP_PMU(dev);
+
+ object_property_set_uint(OBJECT(&s->cpu), XLNX_ZYNQMP_PMU_ROM_ADDR,
+ "base-vectors", &error_abort);
+ object_property_set_bool(OBJECT(&s->cpu), true, "use-stack-protection",
+ &error_abort);
+ object_property_set_uint(OBJECT(&s->cpu), 0, "use-fpu", &error_abort);
+ object_property_set_uint(OBJECT(&s->cpu), 0, "use-hw-mul", &error_abort);
+ object_property_set_bool(OBJECT(&s->cpu), true, "use-barrel",
+ &error_abort);
+ object_property_set_bool(OBJECT(&s->cpu), true, "use-msr-instr",
+ &error_abort);
+ object_property_set_bool(OBJECT(&s->cpu), true, "use-pcmp-instr",
+ &error_abort);
+ object_property_set_bool(OBJECT(&s->cpu), false, "use-mmu", &error_abort);
+ object_property_set_bool(OBJECT(&s->cpu), true, "endianness",
+ &error_abort);
+ object_property_set_str(OBJECT(&s->cpu), "8.40.b", "version",
+ &error_abort);
+ object_property_set_uint(OBJECT(&s->cpu), 0, "pvr", &error_abort);
+ object_property_set_bool(OBJECT(&s->cpu), true, "realized", &error_fatal);
}
static void xlnx_zynqmp_pmu_class_init(ObjectClass *oc, void *data)
@@ -70,7 +103,35 @@ type_init(xlnx_zynqmp_pmu_register_types)
static void xlnx_zcu102_pmu_init(MachineState *machine)
{
-
+ XlnxZynqMPPMUState *pmu = g_new0(XlnxZynqMPPMUState, 1);
+ MemoryRegion *address_space_mem = get_system_memory();
+ MemoryRegion *pmu_rom = g_new(MemoryRegion, 1);
+ MemoryRegion *pmu_ram = g_new(MemoryRegion, 1);
+
+ /* Create the ROM */
+ memory_region_init_rom(pmu_rom, NULL, "xlnx-zcu102-pmu.rom",
+ XLNX_ZYNQMP_PMU_ROM_SIZE, &error_fatal);
+ memory_region_add_subregion(address_space_mem, XLNX_ZYNQMP_PMU_ROM_ADDR,
+ pmu_rom);
+
+ /* Create the RAM */
+ memory_region_init_ram(pmu_ram, NULL, "xlnx-zcu102-pmu.ram",
+ machine->ram_size, &error_fatal);
+ memory_region_add_subregion(address_space_mem, XLNX_ZYNQMP_PMU_RAM_ADDR,
+ pmu_ram);
+
+ /* Create the PMU device */
+ object_initialize(pmu, sizeof(XlnxZynqMPPMUState), TYPE_XLNX_ZYNQMP_PMU);
+ object_property_add_child(OBJECT(machine), "pmu", OBJECT(pmu),
+ &error_abort);
+ object_property_set_bool(OBJECT(pmu), true, "realized", &error_fatal);
+
+ /* Load the kernel */
+ microblaze_load_kernel(&pmu->cpu, XLNX_ZYNQMP_PMU_RAM_ADDR,
+ machine->ram_size,
+ machine->kernel_filename,
+ machine->dtb,
+ NULL);
}
static void xlnx_zcu102_pmu_machine_init(MachineClass *mc)
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH v2 3/6] aarch64-softmmu.mak: Use an ARM specific config
2017-09-01 21:00 [Qemu-devel] [PATCH v2 0/6] Add the ZynqMP PMU and IPI Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 1/6] xlnx-zynqmp-pmu: Initial commit of the ZynqMP PMU Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 2/6] xlnx-zynqmp-pmu: Add the CPU and memory Alistair Francis
@ 2017-09-01 21:00 ` Alistair Francis
2017-09-14 12:50 ` Peter Maydell
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 4/6] xlnx-zynqmp-ipi: Initial version of the Xilinx IPI device Alistair Francis
` (2 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Alistair Francis @ 2017-09-01 21:00 UTC (permalink / raw)
To: qemu-devel, edgar.iglesias, edgar.iglesias
Cc: alistair.francis, alistair23, qemu-arm
In preperation for having an ARM and MicroBlaze ZynqMP machine let's
split out the current ARM specific config options.
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---
default-configs/aarch64-softmmu.mak | 1 +
hw/arm/Makefile.objs | 2 +-
hw/display/Makefile.objs | 2 +-
hw/dma/Makefile.objs | 2 +-
4 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/default-configs/aarch64-softmmu.mak b/default-configs/aarch64-softmmu.mak
index 24494832cf..9ddccf855e 100644
--- a/default-configs/aarch64-softmmu.mak
+++ b/default-configs/aarch64-softmmu.mak
@@ -7,3 +7,4 @@ CONFIG_AUX=y
CONFIG_DDC=y
CONFIG_DPCD=y
CONFIG_XLNX_ZYNQMP=y
+CONFIG_XLNX_ZYNQMP_ARM=y
diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
index a2e56ecaae..95daa67836 100644
--- a/hw/arm/Makefile.objs
+++ b/hw/arm/Makefile.objs
@@ -13,7 +13,7 @@ obj-y += omap1.o omap2.o strongarm.o
obj-$(CONFIG_ALLWINNER_A10) += allwinner-a10.o cubieboard.o
obj-$(CONFIG_RASPI) += bcm2835_peripherals.o bcm2836.o raspi.o
obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o
-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o
+obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx-zynqmp.o xlnx-ep108.o
obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o
obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o
diff --git a/hw/display/Makefile.objs b/hw/display/Makefile.objs
index 551c050a6a..d3a4cb396e 100644
--- a/hw/display/Makefile.objs
+++ b/hw/display/Makefile.objs
@@ -40,4 +40,4 @@ virtio-gpu.o-libs += $(VIRGL_LIBS)
virtio-gpu-3d.o-cflags := $(VIRGL_CFLAGS)
virtio-gpu-3d.o-libs += $(VIRGL_LIBS)
obj-$(CONFIG_DPCD) += dpcd.o
-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx_dp.o
+obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx_dp.o
diff --git a/hw/dma/Makefile.objs b/hw/dma/Makefile.objs
index 087c8e6855..be98d5d3d8 100644
--- a/hw/dma/Makefile.objs
+++ b/hw/dma/Makefile.objs
@@ -9,7 +9,7 @@ common-obj-$(CONFIG_ZYNQ_DEVCFG) += xlnx-zynq-devcfg.o
common-obj-$(CONFIG_ETRAXFS) += etraxfs_dma.o
common-obj-$(CONFIG_STP2000) += sparc32_dma.o
common-obj-$(CONFIG_SUN4M) += sun4m_iommu.o
-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx_dpdma.o
+obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx_dpdma.o
obj-$(CONFIG_OMAP) += omap_dma.o soc_dma.o
obj-$(CONFIG_PXA2XX) += pxa2xx_dma.o
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH v2 4/6] xlnx-zynqmp-ipi: Initial version of the Xilinx IPI device
2017-09-01 21:00 [Qemu-devel] [PATCH v2 0/6] Add the ZynqMP PMU and IPI Alistair Francis
` (2 preceding siblings ...)
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 3/6] aarch64-softmmu.mak: Use an ARM specific config Alistair Francis
@ 2017-09-01 21:00 ` Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 5/6] xlnx-zynqmp-pmu: Connect the IPI device to the PMU Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 6/6] xlnx-zynqmp: Connect the IPI device to the ZynqMP SoC Alistair Francis
5 siblings, 0 replies; 11+ messages in thread
From: Alistair Francis @ 2017-09-01 21:00 UTC (permalink / raw)
To: qemu-devel, edgar.iglesias, edgar.iglesias
Cc: alistair.francis, alistair23, qemu-arm
This is the initial version of the Inter Processor Interrupt device.
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---
default-configs/microblaze-softmmu.mak | 1 +
hw/intc/Makefile.objs | 1 +
hw/intc/xlnx-zynqmp-ipi.c | 377 +++++++++++++++++++++++++++++++++
include/hw/intc/xlnx-zynqmp-ipi.h | 57 +++++
4 files changed, 436 insertions(+)
create mode 100644 hw/intc/xlnx-zynqmp-ipi.c
create mode 100644 include/hw/intc/xlnx-zynqmp-ipi.h
diff --git a/default-configs/microblaze-softmmu.mak b/default-configs/microblaze-softmmu.mak
index ce2630818a..7fca8e4c99 100644
--- a/default-configs/microblaze-softmmu.mak
+++ b/default-configs/microblaze-softmmu.mak
@@ -9,3 +9,4 @@ CONFIG_XILINX_SPI=y
CONFIG_XILINX_ETHLITE=y
CONFIG_SSI=y
CONFIG_SSI_M25P80=y
+CONFIG_XLNX_ZYNQMP=y
diff --git a/hw/intc/Makefile.objs b/hw/intc/Makefile.objs
index 78426a7daf..be3a1873d1 100644
--- a/hw/intc/Makefile.objs
+++ b/hw/intc/Makefile.objs
@@ -3,6 +3,7 @@ common-obj-$(CONFIG_I8259) += i8259_common.o i8259.o
common-obj-$(CONFIG_PL190) += pl190.o
common-obj-$(CONFIG_PUV3) += puv3_intc.o
common-obj-$(CONFIG_XILINX) += xilinx_intc.o
+common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-ipi.o
common-obj-$(CONFIG_ETRAXFS) += etraxfs_pic.o
common-obj-$(CONFIG_IMX) += imx_avic.o
common-obj-$(CONFIG_LM32) += lm32_pic.o
diff --git a/hw/intc/xlnx-zynqmp-ipi.c b/hw/intc/xlnx-zynqmp-ipi.c
new file mode 100644
index 0000000000..6203b27e56
--- /dev/null
+++ b/hw/intc/xlnx-zynqmp-ipi.c
@@ -0,0 +1,377 @@
+/*
+ * QEMU model of the IPI Inter Processor Interrupt block
+ *
+ * Copyright (c) 2014 Xilinx Inc.
+ *
+ * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com>
+ * Written by Alistair Francis <alistair.francis@xilinx.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/sysbus.h"
+#include "hw/register.h"
+#include "qemu/bitops.h"
+#include "qemu/log.h"
+#include "hw/intc/xlnx-zynqmp-ipi.h"
+
+#ifndef XLNX_ZYNQMP_IPI_ERR_DEBUG
+#define XLNX_ZYNQMP_IPI_ERR_DEBUG 0
+#endif
+
+#define DB_PRINT_L(lvl, fmt, args...) do {\
+ if (XLNX_ZYNQMP_IPI_ERR_DEBUG >= lvl) {\
+ qemu_log(TYPE_XLNX_ZYNQMP_IPI ": %s:" fmt, __func__, ## args);\
+ } \
+} while (0);
+
+#define DB_PRINT(fmt, args...) DB_PRINT_L(1, fmt, ## args)
+
+REG32(IPI_TRIG, 0x0)
+ FIELD(IPI_TRIG, PL_3, 27, 1)
+ FIELD(IPI_TRIG, PL_2, 26, 1)
+ FIELD(IPI_TRIG, PL_1, 25, 1)
+ FIELD(IPI_TRIG, PL_0, 24, 1)
+ FIELD(IPI_TRIG, PMU_3, 19, 1)
+ FIELD(IPI_TRIG, PMU_2, 18, 1)
+ FIELD(IPI_TRIG, PMU_1, 17, 1)
+ FIELD(IPI_TRIG, PMU_0, 16, 1)
+ FIELD(IPI_TRIG, RPU_1, 9, 1)
+ FIELD(IPI_TRIG, RPU_0, 8, 1)
+ FIELD(IPI_TRIG, APU, 0, 1)
+REG32(IPI_OBS, 0x4)
+ FIELD(IPI_OBS, PL_3, 27, 1)
+ FIELD(IPI_OBS, PL_2, 26, 1)
+ FIELD(IPI_OBS, PL_1, 25, 1)
+ FIELD(IPI_OBS, PL_0, 24, 1)
+ FIELD(IPI_OBS, PMU_3, 19, 1)
+ FIELD(IPI_OBS, PMU_2, 18, 1)
+ FIELD(IPI_OBS, PMU_1, 17, 1)
+ FIELD(IPI_OBS, PMU_0, 16, 1)
+ FIELD(IPI_OBS, RPU_1, 9, 1)
+ FIELD(IPI_OBS, RPU_0, 8, 1)
+ FIELD(IPI_OBS, APU, 0, 1)
+REG32(IPI_ISR, 0x10)
+ FIELD(IPI_ISR, PL_3, 27, 1)
+ FIELD(IPI_ISR, PL_2, 26, 1)
+ FIELD(IPI_ISR, PL_1, 25, 1)
+ FIELD(IPI_ISR, PL_0, 24, 1)
+ FIELD(IPI_ISR, PMU_3, 19, 1)
+ FIELD(IPI_ISR, PMU_2, 18, 1)
+ FIELD(IPI_ISR, PMU_1, 17, 1)
+ FIELD(IPI_ISR, PMU_0, 16, 1)
+ FIELD(IPI_ISR, RPU_1, 9, 1)
+ FIELD(IPI_ISR, RPU_0, 8, 1)
+ FIELD(IPI_ISR, APU, 0, 1)
+REG32(IPI_IMR, 0x14)
+ FIELD(IPI_IMR, PL_3, 27, 1)
+ FIELD(IPI_IMR, PL_2, 26, 1)
+ FIELD(IPI_IMR, PL_1, 25, 1)
+ FIELD(IPI_IMR, PL_0, 24, 1)
+ FIELD(IPI_IMR, PMU_3, 19, 1)
+ FIELD(IPI_IMR, PMU_2, 18, 1)
+ FIELD(IPI_IMR, PMU_1, 17, 1)
+ FIELD(IPI_IMR, PMU_0, 16, 1)
+ FIELD(IPI_IMR, RPU_1, 9, 1)
+ FIELD(IPI_IMR, RPU_0, 8, 1)
+ FIELD(IPI_IMR, APU, 0, 1)
+REG32(IPI_IER, 0x18)
+ FIELD(IPI_IER, PL_3, 27, 1)
+ FIELD(IPI_IER, PL_2, 26, 1)
+ FIELD(IPI_IER, PL_1, 25, 1)
+ FIELD(IPI_IER, PL_0, 24, 1)
+ FIELD(IPI_IER, PMU_3, 19, 1)
+ FIELD(IPI_IER, PMU_2, 18, 1)
+ FIELD(IPI_IER, PMU_1, 17, 1)
+ FIELD(IPI_IER, PMU_0, 16, 1)
+ FIELD(IPI_IER, RPU_1, 9, 1)
+ FIELD(IPI_IER, RPU_0, 8, 1)
+ FIELD(IPI_IER, APU, 0, 1)
+REG32(IPI_IDR, 0x1c)
+ FIELD(IPI_IDR, PL_3, 27, 1)
+ FIELD(IPI_IDR, PL_2, 26, 1)
+ FIELD(IPI_IDR, PL_1, 25, 1)
+ FIELD(IPI_IDR, PL_0, 24, 1)
+ FIELD(IPI_IDR, PMU_3, 19, 1)
+ FIELD(IPI_IDR, PMU_2, 18, 1)
+ FIELD(IPI_IDR, PMU_1, 17, 1)
+ FIELD(IPI_IDR, PMU_0, 16, 1)
+ FIELD(IPI_IDR, RPU_1, 9, 1)
+ FIELD(IPI_IDR, RPU_0, 8, 1)
+ FIELD(IPI_IDR, APU, 0, 1)
+
+/* APU
+ * RPU_0
+ * RPU_1
+ * PMU_0
+ * PMU_1
+ * PMU_2
+ * PMU_3
+ * PL_0
+ * PL_1
+ * PL_2
+ * PL_3
+ */
+int index_array[NUM_IPIS] = {0, 8, 9, 16, 17, 18, 19, 24, 25, 26, 27};
+static const char *index_array_names[NUM_IPIS] = {"APU", "RPU_0", "RPU_1",
+ "PMU_0", "PMU_1", "PMU_2",
+ "PMU_3", "PL_0", "PL_1",
+ "PL_2", "PL_3"};
+
+static void xlnx_zynqmp_ipi_set_trig(XlnxZynqMPIPI *s, uint32_t val)
+{
+ int i, ipi_index, ipi_mask;
+
+ for (i = 0; i < NUM_IPIS; i++) {
+ ipi_index = index_array[i];
+ ipi_mask = (1 << ipi_index);
+ DB_PRINT("Setting %s=%d\n", index_array_names[i],
+ !!(val & ipi_mask));
+ qemu_set_irq(s->irq_trig_out[i], !!(val & ipi_mask));
+ }
+}
+
+static void xlnx_zynqmp_ipi_set_obs(XlnxZynqMPIPI *s, uint32_t val)
+{
+ int i, ipi_index, ipi_mask;
+
+ for (i = 0; i < NUM_IPIS; i++) {
+ ipi_index = index_array[i];
+ ipi_mask = (1 << ipi_index);
+ DB_PRINT("Setting %s=%d\n", index_array_names[i],
+ !!(val & ipi_mask));
+ qemu_set_irq(s->irq_obs_out[i], !!(val & ipi_mask));
+ }
+}
+
+static void xlnx_zynqmp_ipi_update_irq(XlnxZynqMPIPI *s)
+{
+ bool pending = s->regs[R_IPI_ISR] & ~s->regs[R_IPI_IMR];
+
+ DB_PRINT("irq=%d isr=%x mask=%x\n",
+ pending, s->regs[R_IPI_ISR], s->regs[R_IPI_IMR]);
+ qemu_set_irq(s->irq, pending);
+}
+
+static uint64_t xlnx_zynqmp_ipi_trig_prew(RegisterInfo *reg, uint64_t val64)
+{
+ XlnxZynqMPIPI *s = XLNX_ZYNQMP_IPI(reg->opaque);
+
+ xlnx_zynqmp_ipi_set_trig(s, val64);
+
+ return val64;
+}
+
+static void xlnx_zynqmp_ipi_trig_postw(RegisterInfo *reg, uint64_t val64)
+{
+ XlnxZynqMPIPI *s = XLNX_ZYNQMP_IPI(reg->opaque);
+
+ /* TRIG generates a pulse on the outbound signals. We use the
+ * post-write callback to bring the signal back-down.
+ */
+ s->regs[R_IPI_TRIG] = 0;
+
+ xlnx_zynqmp_ipi_set_trig(s, 0);
+}
+
+static uint64_t xlnx_zynqmp_ipi_isr_prew(RegisterInfo *reg, uint64_t val64)
+{
+ XlnxZynqMPIPI *s = XLNX_ZYNQMP_IPI(reg->opaque);
+
+ xlnx_zynqmp_ipi_set_obs(s, val64);
+
+ return val64;
+}
+
+static void xlnx_zynqmp_ipi_isr_postw(RegisterInfo *reg, uint64_t val64)
+{
+ XlnxZynqMPIPI *s = XLNX_ZYNQMP_IPI(reg->opaque);
+
+ xlnx_zynqmp_ipi_update_irq(s);
+}
+
+static uint64_t xlnx_zynqmp_ipi_ier_prew(RegisterInfo *reg, uint64_t val64)
+{
+ XlnxZynqMPIPI *s = XLNX_ZYNQMP_IPI(reg->opaque);
+ uint32_t val = val64;
+
+ s->regs[R_IPI_IMR] &= ~val;
+ xlnx_zynqmp_ipi_update_irq(s);
+ return 0;
+}
+
+static uint64_t xlnx_zynqmp_ipi_idr_prew(RegisterInfo *reg, uint64_t val64)
+{
+ XlnxZynqMPIPI *s = XLNX_ZYNQMP_IPI(reg->opaque);
+ uint32_t val = val64;
+
+ s->regs[R_IPI_IMR] |= val;
+ xlnx_zynqmp_ipi_update_irq(s);
+ return 0;
+}
+
+static const RegisterAccessInfo xlnx_zynqmp_ipi_regs_info[] = {
+ { .name = "IPI_TRIG", .addr = A_IPI_TRIG,
+ .rsvd = 0xf0f0fcfe,
+ .ro = 0xf0f0fcfe,
+ .pre_write = xlnx_zynqmp_ipi_trig_prew,
+ .post_write = xlnx_zynqmp_ipi_trig_postw,
+ },{ .name = "IPI_OBS", .addr = A_IPI_OBS,
+ .rsvd = 0xf0f0fcfe,
+ .ro = 0xffffffff,
+ },{ .name = "IPI_ISR", .addr = A_IPI_ISR,
+ .rsvd = 0xf0f0fcfe,
+ .ro = 0xf0f0fcfe,
+ .w1c = 0xf0f0301,
+ .pre_write = xlnx_zynqmp_ipi_isr_prew,
+ .post_write = xlnx_zynqmp_ipi_isr_postw,
+ },{ .name = "IPI_IMR", .addr = A_IPI_IMR,
+ .reset = 0xf0f0301,
+ .rsvd = 0xf0f0fcfe,
+ .ro = 0xffffffff,
+ },{ .name = "IPI_IER", .addr = A_IPI_IER,
+ .rsvd = 0xf0f0fcfe,
+ .ro = 0xf0f0fcfe,
+ .pre_write = xlnx_zynqmp_ipi_ier_prew,
+ },{ .name = "IPI_IDR", .addr = A_IPI_IDR,
+ .rsvd = 0xf0f0fcfe,
+ .ro = 0xf0f0fcfe,
+ .pre_write = xlnx_zynqmp_ipi_idr_prew,
+ }
+};
+
+static void xlnx_zynqmp_ipi_reset(DeviceState *dev)
+{
+ XlnxZynqMPIPI *s = XLNX_ZYNQMP_IPI(dev);
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) {
+ register_reset(&s->regs_info[i]);
+ }
+
+ xlnx_zynqmp_ipi_update_irq(s);
+}
+
+static void xlnx_zynqmp_ipi_handler(void *opaque, int n, int level)
+{
+ XlnxZynqMPIPI *s = XLNX_ZYNQMP_IPI(opaque);
+ uint32_t val = (!!level) << n;
+
+ DB_PRINT("IPI input irq[%d]=%d\n", n, level);
+
+ s->regs[R_IPI_ISR] |= val;
+ xlnx_zynqmp_ipi_set_obs(s, s->regs[R_IPI_ISR]);
+ xlnx_zynqmp_ipi_update_irq(s);
+}
+
+static void xlnx_zynqmp_obs_handler(void *opaque, int n, int level)
+{
+ XlnxZynqMPIPI *s = XLNX_ZYNQMP_IPI(opaque);
+
+ DB_PRINT("OBS input irq[%d]=%d\n", n, level);
+
+ s->regs[R_IPI_OBS] &= ~(1ULL << n);
+ s->regs[R_IPI_OBS] |= (level << n);
+}
+
+static const MemoryRegionOps xlnx_zynqmp_ipi_ops = {
+ .read = register_read_memory,
+ .write = register_write_memory,
+ .endianness = DEVICE_LITTLE_ENDIAN,
+ .valid = {
+ .min_access_size = 4,
+ .max_access_size = 4,
+ },
+};
+
+static void xlnx_zynqmp_ipi_realize(DeviceState *dev, Error **errp)
+{
+ qdev_init_gpio_in_named(dev, xlnx_zynqmp_ipi_handler, "IPI_INPUTS", 32);
+ qdev_init_gpio_in_named(dev, xlnx_zynqmp_obs_handler, "OBS_INPUTS", 32);
+}
+
+static void xlnx_zynqmp_ipi_init(Object *obj)
+{
+ XlnxZynqMPIPI *s = XLNX_ZYNQMP_IPI(obj);
+ DeviceState *dev = DEVICE(obj);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+ RegisterInfoArray *reg_array;
+ char *irq_name;
+ int i;
+
+ memory_region_init(&s->iomem, obj, TYPE_XLNX_ZYNQMP_IPI,
+ R_XLNX_ZYNQMP_IPI_MAX * 4);
+ reg_array =
+ register_init_block32(DEVICE(obj), xlnx_zynqmp_ipi_regs_info,
+ ARRAY_SIZE(xlnx_zynqmp_ipi_regs_info),
+ s->regs_info, s->regs,
+ &xlnx_zynqmp_ipi_ops,
+ XLNX_ZYNQMP_IPI_ERR_DEBUG,
+ R_XLNX_ZYNQMP_IPI_MAX * 4);
+ memory_region_add_subregion(&s->iomem,
+ 0x0,
+ ®_array->mem);
+ sysbus_init_mmio(sbd, &s->iomem);
+ sysbus_init_irq(sbd, &s->irq);
+
+ for (i = 0; i < NUM_IPIS; i++) {
+ qdev_init_gpio_out_named(dev, &s->irq_trig_out[i],
+ index_array_names[i], 1);
+
+ irq_name = g_strdup_printf("OBS_%s", index_array_names[i]);
+ qdev_init_gpio_out_named(dev, &s->irq_obs_out[i],
+ irq_name, 1);
+ g_free(irq_name);
+ }
+}
+
+static const VMStateDescription vmstate_zynqmp_pmu_ipi = {
+ .name = TYPE_XLNX_ZYNQMP_IPI,
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT32_ARRAY(regs, XlnxZynqMPIPI, R_XLNX_ZYNQMP_IPI_MAX),
+ VMSTATE_END_OF_LIST(),
+ }
+};
+
+static void xlnx_zynqmp_ipi_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ dc->reset = xlnx_zynqmp_ipi_reset;
+ dc->realize = xlnx_zynqmp_ipi_realize;
+ dc->vmsd = &vmstate_zynqmp_pmu_ipi;
+}
+
+static const TypeInfo xlnx_zynqmp_ipi_info = {
+ .name = TYPE_XLNX_ZYNQMP_IPI,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(XlnxZynqMPIPI),
+ .class_init = xlnx_zynqmp_ipi_class_init,
+ .instance_init = xlnx_zynqmp_ipi_init,
+};
+
+static void xlnx_zynqmp_ipi_register_types(void)
+{
+ type_register_static(&xlnx_zynqmp_ipi_info);
+}
+
+type_init(xlnx_zynqmp_ipi_register_types)
diff --git a/include/hw/intc/xlnx-zynqmp-ipi.h b/include/hw/intc/xlnx-zynqmp-ipi.h
new file mode 100644
index 0000000000..4afa4ff313
--- /dev/null
+++ b/include/hw/intc/xlnx-zynqmp-ipi.h
@@ -0,0 +1,57 @@
+/*
+ * QEMU model of the IPI Inter Processor Interrupt block
+ *
+ * Copyright (c) 2014 Xilinx Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef XLNX_ZYNQMP_IPI_H
+#define XLNX_ZYNQMP_IPI_H
+
+#include "qemu/osdep.h"
+#include "hw/sysbus.h"
+#include "hw/register.h"
+
+#define TYPE_XLNX_ZYNQMP_IPI "xlnx.zynqmp_ipi"
+
+#define XLNX_ZYNQMP_IPI(obj) \
+ OBJECT_CHECK(XlnxZynqMPIPI, (obj), TYPE_XLNX_ZYNQMP_IPI)
+
+/* This is R_IPI_IDR + 1 */
+#define R_XLNX_ZYNQMP_IPI_MAX ((0x1c / 4) + 1)
+
+#define NUM_IPIS 11
+
+typedef struct XlnxZynqMPIPI {
+ /* Private */
+ SysBusDevice parent_obj;
+
+ /* Public */
+ MemoryRegion iomem;
+ qemu_irq irq;
+
+ qemu_irq irq_trig_out[NUM_IPIS];
+ qemu_irq irq_obs_out[NUM_IPIS];
+
+ uint32_t regs[R_XLNX_ZYNQMP_IPI_MAX];
+ RegisterInfo regs_info[R_XLNX_ZYNQMP_IPI_MAX];
+} XlnxZynqMPIPI;
+
+#endif /* XLNX_ZYNQMP_IPI_H */
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH v2 5/6] xlnx-zynqmp-pmu: Connect the IPI device to the PMU
2017-09-01 21:00 [Qemu-devel] [PATCH v2 0/6] Add the ZynqMP PMU and IPI Alistair Francis
` (3 preceding siblings ...)
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 4/6] xlnx-zynqmp-ipi: Initial version of the Xilinx IPI device Alistair Francis
@ 2017-09-01 21:00 ` Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 6/6] xlnx-zynqmp: Connect the IPI device to the ZynqMP SoC Alistair Francis
5 siblings, 0 replies; 11+ messages in thread
From: Alistair Francis @ 2017-09-01 21:00 UTC (permalink / raw)
To: qemu-devel, edgar.iglesias, edgar.iglesias
Cc: alistair.francis, alistair23, qemu-arm
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---
hw/microblaze/xlnx-zynqmp-pmu.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c
index 33584cfa4d..a6c14495ec 100644
--- a/hw/microblaze/xlnx-zynqmp-pmu.c
+++ b/hw/microblaze/xlnx-zynqmp-pmu.c
@@ -24,6 +24,8 @@
#include "cpu.h"
#include "boot.h"
+#include "hw/intc/xlnx-zynqmp-ipi.h"
+
/* Define the PMU device */
#define TYPE_XLNX_ZYNQMP_PMU "xlnx,zynqmp-pmu"
@@ -34,27 +36,42 @@
#define XLNX_ZYNQMP_PMU_ROM_ADDR 0xFFD00000
#define XLNX_ZYNQMP_PMU_RAM_ADDR 0xFFDC0000
+#define XLNX_ZYNQMP_PMU_NUM_IPIS 4
+
+static const uint64_t ipi_addr[XLNX_ZYNQMP_PMU_NUM_IPIS] = {
+ 0xFF340000, 0xFF350000, 0xFF360000, 0xFF370000,
+};
+
typedef struct XlnxZynqMPPMUState {
/*< private >*/
DeviceState parent_obj;
/*< public >*/
MicroBlazeCPU cpu;
+ XlnxZynqMPIPI ipi[XLNX_ZYNQMP_PMU_NUM_IPIS];
} XlnxZynqMPPMUState;
static void xlnx_zynqmp_pmu_init(Object *obj)
{
XlnxZynqMPPMUState *s = XLNX_ZYNQMP_PMU(obj);
+ int i;
object_initialize(&s->cpu, sizeof(s->cpu),
TYPE_MICROBLAZE_CPU);
object_property_add_child(obj, "pmu-cpu[*]", OBJECT(&s->cpu),
&error_abort);
+
+ for (i = 0; i < XLNX_ZYNQMP_PMU_NUM_IPIS; i++) {
+ object_initialize(&s->ipi[i], sizeof(s->ipi[i]), TYPE_XLNX_ZYNQMP_IPI);
+ qdev_set_parent_bus(DEVICE(&s->ipi[i]), sysbus_get_default());
+ }
}
static void xlnx_zynqmp_pmu_realize(DeviceState *dev, Error **errp)
{
XlnxZynqMPPMUState *s = XLNX_ZYNQMP_PMU(dev);
+ Error *err = NULL;
+ int i;
object_property_set_uint(OBJECT(&s->cpu), XLNX_ZYNQMP_PMU_ROM_ADDR,
"base-vectors", &error_abort);
@@ -75,6 +92,17 @@ static void xlnx_zynqmp_pmu_realize(DeviceState *dev, Error **errp)
&error_abort);
object_property_set_uint(OBJECT(&s->cpu), 0, "pvr", &error_abort);
object_property_set_bool(OBJECT(&s->cpu), true, "realized", &error_fatal);
+
+ for (i = 0; i < XLNX_ZYNQMP_PMU_NUM_IPIS; i++) {
+ object_property_set_bool(OBJECT(&s->ipi[i]), true, "realized", &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
+ }
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->ipi[i]), 0, ipi_addr[i]);
+ /* Need to connect this to an interrupt controller */
+ }
+
}
static void xlnx_zynqmp_pmu_class_init(ObjectClass *oc, void *data)
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH v2 6/6] xlnx-zynqmp: Connect the IPI device to the ZynqMP SoC
2017-09-01 21:00 [Qemu-devel] [PATCH v2 0/6] Add the ZynqMP PMU and IPI Alistair Francis
` (4 preceding siblings ...)
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 5/6] xlnx-zynqmp-pmu: Connect the IPI device to the PMU Alistair Francis
@ 2017-09-01 21:00 ` Alistair Francis
5 siblings, 0 replies; 11+ messages in thread
From: Alistair Francis @ 2017-09-01 21:00 UTC (permalink / raw)
To: qemu-devel, edgar.iglesias, edgar.iglesias
Cc: alistair.francis, alistair23, qemu-arm
Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
---
hw/arm/xlnx-zynqmp.c | 14 ++++++++++++++
include/hw/arm/xlnx-zynqmp.h | 2 ++
2 files changed, 16 insertions(+)
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
index 9eceadbdc8..1988cb47f4 100644
--- a/hw/arm/xlnx-zynqmp.c
+++ b/hw/arm/xlnx-zynqmp.c
@@ -46,6 +46,9 @@
#define DPDMA_ADDR 0xfd4c0000
#define DPDMA_IRQ 116
+#define IPI_ADDR 0xFF300000
+#define IPI_IRQ 64
+
static const uint64_t gem_addr[XLNX_ZYNQMP_NUM_GEMS] = {
0xFF0B0000, 0xFF0C0000, 0xFF0D0000, 0xFF0E0000,
};
@@ -179,6 +182,9 @@ static void xlnx_zynqmp_init(Object *obj)
object_initialize(&s->dpdma, sizeof(s->dpdma), TYPE_XLNX_DPDMA);
qdev_set_parent_bus(DEVICE(&s->dpdma), sysbus_get_default());
+
+ object_initialize(&s->ipi, sizeof(s->ipi), TYPE_XLNX_ZYNQMP_IPI);
+ qdev_set_parent_bus(DEVICE(&s->ipi), sysbus_get_default());
}
static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
@@ -427,6 +433,14 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)
&error_abort);
sysbus_mmio_map(SYS_BUS_DEVICE(&s->dpdma), 0, DPDMA_ADDR);
sysbus_connect_irq(SYS_BUS_DEVICE(&s->dpdma), 0, gic_spi[DPDMA_IRQ]);
+
+ object_property_set_bool(OBJECT(&s->ipi), true, "realized", &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
+ }
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->ipi), 0, IPI_ADDR);
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->ipi), 0, gic_spi[IPI_IRQ]);
}
static Property xlnx_zynqmp_props[] = {
diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h
index c2931bf39c..02a89766e8 100644
--- a/include/hw/arm/xlnx-zynqmp.h
+++ b/include/hw/arm/xlnx-zynqmp.h
@@ -28,6 +28,7 @@
#include "hw/ssi/xilinx_spips.h"
#include "hw/dma/xlnx_dpdma.h"
#include "hw/display/xlnx_dp.h"
+#include "hw/intc/xlnx-zynqmp-ipi.h"
#define TYPE_XLNX_ZYNQMP "xlnx,zynqmp"
#define XLNX_ZYNQMP(obj) OBJECT_CHECK(XlnxZynqMPState, (obj), \
@@ -85,6 +86,7 @@ typedef struct XlnxZynqMPState {
XilinxSPIPS spi[XLNX_ZYNQMP_NUM_SPIS];
XlnxDPState dp;
XlnxDPDMAState dpdma;
+ XlnxZynqMPIPI ipi;
char *boot_cpu;
ARMCPU *boot_cpu_ptr;
--
2.11.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/6] xlnx-zynqmp-pmu: Add the CPU and memory
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 2/6] xlnx-zynqmp-pmu: Add the CPU and memory Alistair Francis
@ 2017-09-04 7:32 ` Igor Mammedov
2017-09-05 17:36 ` Alistair Francis
0 siblings, 1 reply; 11+ messages in thread
From: Igor Mammedov @ 2017-09-04 7:32 UTC (permalink / raw)
To: Alistair Francis
Cc: qemu-devel, edgar.iglesias, edgar.iglesias, alistair23, qemu-arm
On Fri, 1 Sep 2017 14:00:37 -0700
Alistair Francis <alistair.francis@xilinx.com> wrote:
> Connect the MicroBlaze CPU and the ROM and RAM memory regions.
>
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
> ---
>
> hw/microblaze/xlnx-zynqmp-pmu.c | 65 +++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 63 insertions(+), 2 deletions(-)
>
> diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c
> index fc3c8b236f..33584cfa4d 100644
> --- a/hw/microblaze/xlnx-zynqmp-pmu.c
> +++ b/hw/microblaze/xlnx-zynqmp-pmu.c
> @@ -18,8 +18,11 @@
> #include "qemu/osdep.h"
> #include "qapi/error.h"
> #include "qemu-common.h"
> +#include "exec/address-spaces.h"
> #include "hw/boards.h"
> +#include "hw/qdev-properties.h"
> #include "cpu.h"
> +#include "boot.h"
>
> /* Define the PMU device */
>
> @@ -27,21 +30,51 @@
> #define XLNX_ZYNQMP_PMU(obj) OBJECT_CHECK(XlnxZynqMPPMUState, (obj), \
> TYPE_XLNX_ZYNQMP_PMU)
>
> +#define XLNX_ZYNQMP_PMU_ROM_SIZE 0x8000
> +#define XLNX_ZYNQMP_PMU_ROM_ADDR 0xFFD00000
> +#define XLNX_ZYNQMP_PMU_RAM_ADDR 0xFFDC0000
> +
> typedef struct XlnxZynqMPPMUState {
> /*< private >*/
> DeviceState parent_obj;
>
> /*< public >*/
> + MicroBlazeCPU cpu;
> } XlnxZynqMPPMUState;
>
> static void xlnx_zynqmp_pmu_init(Object *obj)
> {
> + XlnxZynqMPPMUState *s = XLNX_ZYNQMP_PMU(obj);
>
> + object_initialize(&s->cpu, sizeof(s->cpu),
> + TYPE_MICROBLAZE_CPU);
> + object_property_add_child(obj, "pmu-cpu[*]", OBJECT(&s->cpu),
^^^ why do you use this syntax here?
> + &error_abort);
> }
>
> static void xlnx_zynqmp_pmu_realize(DeviceState *dev, Error **errp)
> {
> -
> + XlnxZynqMPPMUState *s = XLNX_ZYNQMP_PMU(dev);
> +
> + object_property_set_uint(OBJECT(&s->cpu), XLNX_ZYNQMP_PMU_ROM_ADDR,
> + "base-vectors", &error_abort);
> + object_property_set_bool(OBJECT(&s->cpu), true, "use-stack-protection",
> + &error_abort);
> + object_property_set_uint(OBJECT(&s->cpu), 0, "use-fpu", &error_abort);
> + object_property_set_uint(OBJECT(&s->cpu), 0, "use-hw-mul", &error_abort);
> + object_property_set_bool(OBJECT(&s->cpu), true, "use-barrel",
> + &error_abort);
> + object_property_set_bool(OBJECT(&s->cpu), true, "use-msr-instr",
> + &error_abort);
> + object_property_set_bool(OBJECT(&s->cpu), true, "use-pcmp-instr",
> + &error_abort);
> + object_property_set_bool(OBJECT(&s->cpu), false, "use-mmu", &error_abort);
> + object_property_set_bool(OBJECT(&s->cpu), true, "endianness",
> + &error_abort);
> + object_property_set_str(OBJECT(&s->cpu), "8.40.b", "version",
> + &error_abort);
> + object_property_set_uint(OBJECT(&s->cpu), 0, "pvr", &error_abort);
> + object_property_set_bool(OBJECT(&s->cpu), true, "realized", &error_fatal);
I'd replace error_fatal here with errp
> }
>
> static void xlnx_zynqmp_pmu_class_init(ObjectClass *oc, void *data)
> @@ -70,7 +103,35 @@ type_init(xlnx_zynqmp_pmu_register_types)
>
> static void xlnx_zcu102_pmu_init(MachineState *machine)
> {
> -
> + XlnxZynqMPPMUState *pmu = g_new0(XlnxZynqMPPMUState, 1);
> + MemoryRegion *address_space_mem = get_system_memory();
> + MemoryRegion *pmu_rom = g_new(MemoryRegion, 1);
> + MemoryRegion *pmu_ram = g_new(MemoryRegion, 1);
> +
> + /* Create the ROM */
> + memory_region_init_rom(pmu_rom, NULL, "xlnx-zcu102-pmu.rom",
> + XLNX_ZYNQMP_PMU_ROM_SIZE, &error_fatal);
> + memory_region_add_subregion(address_space_mem, XLNX_ZYNQMP_PMU_ROM_ADDR,
> + pmu_rom);
> +
> + /* Create the RAM */
> + memory_region_init_ram(pmu_ram, NULL, "xlnx-zcu102-pmu.ram",
> + machine->ram_size, &error_fatal);
> + memory_region_add_subregion(address_space_mem, XLNX_ZYNQMP_PMU_RAM_ADDR,
> + pmu_ram);
> +
> + /* Create the PMU device */
> + object_initialize(pmu, sizeof(XlnxZynqMPPMUState), TYPE_XLNX_ZYNQMP_PMU);
> + object_property_add_child(OBJECT(machine), "pmu", OBJECT(pmu),
> + &error_abort);
> + object_property_set_bool(OBJECT(pmu), true, "realized", &error_fatal);
> +
> + /* Load the kernel */
> + microblaze_load_kernel(&pmu->cpu, XLNX_ZYNQMP_PMU_RAM_ADDR,
> + machine->ram_size,
> + machine->kernel_filename,
> + machine->dtb,
> + NULL);
> }
>
> static void xlnx_zcu102_pmu_machine_init(MachineClass *mc)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/6] xlnx-zynqmp-pmu: Add the CPU and memory
2017-09-04 7:32 ` Igor Mammedov
@ 2017-09-05 17:36 ` Alistair Francis
0 siblings, 0 replies; 11+ messages in thread
From: Alistair Francis @ 2017-09-05 17:36 UTC (permalink / raw)
To: Igor Mammedov
Cc: Alistair Francis, qemu-devel@nongnu.org Developers,
Edgar Iglesias, Edgar Iglesias, qemu-arm
On Mon, Sep 4, 2017 at 12:32 AM, Igor Mammedov <imammedo@redhat.com> wrote:
> On Fri, 1 Sep 2017 14:00:37 -0700
> Alistair Francis <alistair.francis@xilinx.com> wrote:
>
>> Connect the MicroBlaze CPU and the ROM and RAM memory regions.
>>
>> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
>> ---
>>
>> hw/microblaze/xlnx-zynqmp-pmu.c | 65 +++++++++++++++++++++++++++++++++++++++--
>> 1 file changed, 63 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c
>> index fc3c8b236f..33584cfa4d 100644
>> --- a/hw/microblaze/xlnx-zynqmp-pmu.c
>> +++ b/hw/microblaze/xlnx-zynqmp-pmu.c
>> @@ -18,8 +18,11 @@
>> #include "qemu/osdep.h"
>> #include "qapi/error.h"
>> #include "qemu-common.h"
>> +#include "exec/address-spaces.h"
>> #include "hw/boards.h"
>> +#include "hw/qdev-properties.h"
>> #include "cpu.h"
>> +#include "boot.h"
>>
>> /* Define the PMU device */
>>
>> @@ -27,21 +30,51 @@
>> #define XLNX_ZYNQMP_PMU(obj) OBJECT_CHECK(XlnxZynqMPPMUState, (obj), \
>> TYPE_XLNX_ZYNQMP_PMU)
>>
>> +#define XLNX_ZYNQMP_PMU_ROM_SIZE 0x8000
>> +#define XLNX_ZYNQMP_PMU_ROM_ADDR 0xFFD00000
>> +#define XLNX_ZYNQMP_PMU_RAM_ADDR 0xFFDC0000
>> +
>> typedef struct XlnxZynqMPPMUState {
>> /*< private >*/
>> DeviceState parent_obj;
>>
>> /*< public >*/
>> + MicroBlazeCPU cpu;
>> } XlnxZynqMPPMUState;
>>
>> static void xlnx_zynqmp_pmu_init(Object *obj)
>> {
>> + XlnxZynqMPPMUState *s = XLNX_ZYNQMP_PMU(obj);
>>
>> + object_initialize(&s->cpu, sizeof(s->cpu),
>> + TYPE_MICROBLAZE_CPU);
>> + object_property_add_child(obj, "pmu-cpu[*]", OBJECT(&s->cpu),
> ^^^ why do you use this syntax here?
>
Woops, that was a left over from the ARM ZynqMP. I'll remove the '[*]'
>> + &error_abort);
>> }
>>
>> static void xlnx_zynqmp_pmu_realize(DeviceState *dev, Error **errp)
>> {
>> -
>> + XlnxZynqMPPMUState *s = XLNX_ZYNQMP_PMU(dev);
>> +
>> + object_property_set_uint(OBJECT(&s->cpu), XLNX_ZYNQMP_PMU_ROM_ADDR,
>> + "base-vectors", &error_abort);
>> + object_property_set_bool(OBJECT(&s->cpu), true, "use-stack-protection",
>> + &error_abort);
>> + object_property_set_uint(OBJECT(&s->cpu), 0, "use-fpu", &error_abort);
>> + object_property_set_uint(OBJECT(&s->cpu), 0, "use-hw-mul", &error_abort);
>> + object_property_set_bool(OBJECT(&s->cpu), true, "use-barrel",
>> + &error_abort);
>> + object_property_set_bool(OBJECT(&s->cpu), true, "use-msr-instr",
>> + &error_abort);
>> + object_property_set_bool(OBJECT(&s->cpu), true, "use-pcmp-instr",
>> + &error_abort);
>> + object_property_set_bool(OBJECT(&s->cpu), false, "use-mmu", &error_abort);
>> + object_property_set_bool(OBJECT(&s->cpu), true, "endianness",
>> + &error_abort);
>> + object_property_set_str(OBJECT(&s->cpu), "8.40.b", "version",
>> + &error_abort);
>> + object_property_set_uint(OBJECT(&s->cpu), 0, "pvr", &error_abort);
>> + object_property_set_bool(OBJECT(&s->cpu), true, "realized", &error_fatal);
> I'd replace error_fatal here with errp
Will do.
Thanks,
Alistair
>
>> }
>>
>> static void xlnx_zynqmp_pmu_class_init(ObjectClass *oc, void *data)
>> @@ -70,7 +103,35 @@ type_init(xlnx_zynqmp_pmu_register_types)
>>
>> static void xlnx_zcu102_pmu_init(MachineState *machine)
>> {
>> -
>> + XlnxZynqMPPMUState *pmu = g_new0(XlnxZynqMPPMUState, 1);
>> + MemoryRegion *address_space_mem = get_system_memory();
>> + MemoryRegion *pmu_rom = g_new(MemoryRegion, 1);
>> + MemoryRegion *pmu_ram = g_new(MemoryRegion, 1);
>> +
>> + /* Create the ROM */
>> + memory_region_init_rom(pmu_rom, NULL, "xlnx-zcu102-pmu.rom",
>> + XLNX_ZYNQMP_PMU_ROM_SIZE, &error_fatal);
>> + memory_region_add_subregion(address_space_mem, XLNX_ZYNQMP_PMU_ROM_ADDR,
>> + pmu_rom);
>> +
>> + /* Create the RAM */
>> + memory_region_init_ram(pmu_ram, NULL, "xlnx-zcu102-pmu.ram",
>> + machine->ram_size, &error_fatal);
>> + memory_region_add_subregion(address_space_mem, XLNX_ZYNQMP_PMU_RAM_ADDR,
>> + pmu_ram);
>> +
>> + /* Create the PMU device */
>> + object_initialize(pmu, sizeof(XlnxZynqMPPMUState), TYPE_XLNX_ZYNQMP_PMU);
>> + object_property_add_child(OBJECT(machine), "pmu", OBJECT(pmu),
>> + &error_abort);
>> + object_property_set_bool(OBJECT(pmu), true, "realized", &error_fatal);
>> +
>> + /* Load the kernel */
>> + microblaze_load_kernel(&pmu->cpu, XLNX_ZYNQMP_PMU_RAM_ADDR,
>> + machine->ram_size,
>> + machine->kernel_filename,
>> + machine->dtb,
>> + NULL);
>> }
>>
>> static void xlnx_zcu102_pmu_machine_init(MachineClass *mc)
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/6] aarch64-softmmu.mak: Use an ARM specific config
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 3/6] aarch64-softmmu.mak: Use an ARM specific config Alistair Francis
@ 2017-09-14 12:50 ` Peter Maydell
2017-09-14 20:34 ` Alistair Francis
0 siblings, 1 reply; 11+ messages in thread
From: Peter Maydell @ 2017-09-14 12:50 UTC (permalink / raw)
To: Alistair Francis
Cc: QEMU Developers, Edgar Iglesias, Edgar E. Iglesias,
Alistair Francis, qemu-arm
On 1 September 2017 at 22:00, Alistair Francis
<alistair.francis@xilinx.com> wrote:
> In preperation for having an ARM and MicroBlaze ZynqMP machine let's
> split out the current ARM specific config options.
>
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Acked-by: Peter Maydell <peter.maydell@linaro.org>
I'm assuming this series is going be reviewed and go into
master via a microblaze tree, not the arm one...
thanks
-- PMM
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [PATCH v2 3/6] aarch64-softmmu.mak: Use an ARM specific config
2017-09-14 12:50 ` Peter Maydell
@ 2017-09-14 20:34 ` Alistair Francis
0 siblings, 0 replies; 11+ messages in thread
From: Alistair Francis @ 2017-09-14 20:34 UTC (permalink / raw)
To: Peter Maydell
Cc: Alistair Francis, QEMU Developers, Edgar Iglesias,
Edgar E. Iglesias, qemu-arm
On Thu, Sep 14, 2017 at 5:50 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 1 September 2017 at 22:00, Alistair Francis
> <alistair.francis@xilinx.com> wrote:
>> In preperation for having an ARM and MicroBlaze ZynqMP machine let's
>> split out the current ARM specific config options.
>>
>> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
>
> Acked-by: Peter Maydell <peter.maydell@linaro.org>
Thanks Peter.
>
> I'm assuming this series is going be reviewed and go into
> master via a microblaze tree, not the arm one...
I talked to Edgar and that is the plan.
Thanks,
Alistair
>
> thanks
> -- PMM
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2017-09-14 20:35 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-01 21:00 [Qemu-devel] [PATCH v2 0/6] Add the ZynqMP PMU and IPI Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 1/6] xlnx-zynqmp-pmu: Initial commit of the ZynqMP PMU Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 2/6] xlnx-zynqmp-pmu: Add the CPU and memory Alistair Francis
2017-09-04 7:32 ` Igor Mammedov
2017-09-05 17:36 ` Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 3/6] aarch64-softmmu.mak: Use an ARM specific config Alistair Francis
2017-09-14 12:50 ` Peter Maydell
2017-09-14 20:34 ` Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 4/6] xlnx-zynqmp-ipi: Initial version of the Xilinx IPI device Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 5/6] xlnx-zynqmp-pmu: Connect the IPI device to the PMU Alistair Francis
2017-09-01 21:00 ` [Qemu-devel] [PATCH v2 6/6] xlnx-zynqmp: Connect the IPI device to the ZynqMP SoC Alistair Francis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.