[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH v2 19/27] i.MX: Add code to emulate SDMA IP block
From: |
Andrey Smirnov |
Subject: |
[Qemu-arm] [PATCH v2 19/27] i.MX: Add code to emulate SDMA IP block |
Date: |
Mon, 23 Oct 2017 13:10:47 -0700 |
Add minimal code needed to allow upstream Linux guest to boot.
Cc: Peter Maydell <address@hidden>
Cc: Jason Wang <address@hidden>
Cc: Philippe Mathieu-Daudé <address@hidden>
Cc: address@hidden
Cc: address@hidden
Cc: address@hidden
Signed-off-by: Andrey Smirnov <address@hidden>
---
hw/dma/Makefile.objs | 1 +
hw/dma/imx_sdma.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++
include/hw/dma/imx_sdma.h | 22 +++++++++++
3 files changed, 122 insertions(+)
create mode 100644 hw/dma/imx_sdma.c
create mode 100644 include/hw/dma/imx_sdma.h
diff --git a/hw/dma/Makefile.objs b/hw/dma/Makefile.objs
index 087c8e6855..3cee0b1047 100644
--- a/hw/dma/Makefile.objs
+++ b/hw/dma/Makefile.objs
@@ -14,3 +14,4 @@ obj-$(CONFIG_XLNX_ZYNQMP) += xlnx_dpdma.o
obj-$(CONFIG_OMAP) += omap_dma.o soc_dma.o
obj-$(CONFIG_PXA2XX) += pxa2xx_dma.o
obj-$(CONFIG_RASPI) += bcm2835_dma.o
+obj-$(CONFIG_IMX) += imx_sdma.o
diff --git a/hw/dma/imx_sdma.c b/hw/dma/imx_sdma.c
new file mode 100644
index 0000000000..0776e41b9a
--- /dev/null
+++ b/hw/dma/imx_sdma.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2017, Impinj, Inc.
+ *
+ * i.MX7 IOMUXC block emulation code
+ *
+ * Author: Andrey Smirnov <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/dma/imx_sdma.h"
+#include "qemu/log.h"
+
+static void imx_sdma_reset(DeviceState *dev)
+{
+ IMXSDMAState *s = IMX_SDMA(dev);
+
+ memset(s->regs, 0, sizeof(s->regs));
+}
+
+static uint64_t imx_sdma_read(void *opaque, hwaddr offset,
+ unsigned size)
+{
+ IMXSDMAState *s = opaque;
+ return s->regs[offset / sizeof(uint32_t)];
+}
+
+static void imx_sdma_write(void *opaque, hwaddr offset,
+ uint64_t value, unsigned size)
+{
+ IMXSDMAState *s = opaque;
+ s->regs[offset / sizeof(uint32_t)] = value;
+}
+
+static const struct MemoryRegionOps imx_sdma_ops = {
+ .read = imx_sdma_read,
+ .write = imx_sdma_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+ .impl = {
+ /*
+ * Our device would not work correctly if the guest was doing
+ * unaligned access. This might not be a limitation on the real
+ * device but in practice there is no reason for a guest to access
+ * this device unaligned.
+ */
+ .min_access_size = 4,
+ .max_access_size = 4,
+ .unaligned = false,
+ },
+};
+
+static void imx_sdma_init(Object *obj)
+{
+ SysBusDevice *sd = SYS_BUS_DEVICE(obj);
+ IMXSDMAState *s = IMX_SDMA(obj);
+
+ memory_region_init_io(&s->iomem,
+ obj,
+ &imx_sdma_ops,
+ s,
+ TYPE_IMX_SDMA ".iomem",
+ sizeof(s->regs));
+ sysbus_init_mmio(sd, &s->iomem);
+}
+
+static const VMStateDescription vmstate_imx_sdma = {
+ .name = TYPE_IMX_SDMA,
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT32_ARRAY(regs, IMXSDMAState, SDMA_NUM),
+ VMSTATE_END_OF_LIST()
+ },
+};
+
+static void imx_sdma_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ dc->reset = imx_sdma_reset;
+ dc->vmsd = &vmstate_imx_sdma;
+ dc->desc = "i.MX IOMUXC Module";
+}
+
+static const TypeInfo imx_sdma_info = {
+ .name = TYPE_IMX_SDMA,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(IMXSDMAState),
+ .instance_init = imx_sdma_init,
+ .class_init = imx_sdma_class_init,
+};
+
+static void imx_sdma_register_type(void)
+{
+ type_register_static(&imx_sdma_info);
+}
+type_init(imx_sdma_register_type)
diff --git a/include/hw/dma/imx_sdma.h b/include/hw/dma/imx_sdma.h
new file mode 100644
index 0000000000..13c5be7a00
--- /dev/null
+++ b/include/hw/dma/imx_sdma.h
@@ -0,0 +1,22 @@
+#ifndef IMX_SDMA_H
+#define IMX_SDMA_H
+
+#include "hw/sysbus.h"
+
+enum IMXSDMARegisters {
+ SDMA_NUM = 0x300 / sizeof(uint32_t) + 1,
+};
+
+typedef struct IMXSDMAState {
+ /*< private >*/
+ SysBusDevice parent_obj;
+
+ /*< public >*/
+ MemoryRegion iomem;
+ uint32_t regs[SDMA_NUM];
+} IMXSDMAState;
+
+#define TYPE_IMX_SDMA "imx-sdma"
+#define IMX_SDMA(obj) OBJECT_CHECK(IMXSDMAState, (obj), TYPE_IMX_SDMA)
+
+#endif /* IMX_SDMA_H */
--
2.13.5
- [Qemu-arm] [PATCH v2 07/27] imx_fec: Add support for multiple Tx DMA rings, (continued)
- [Qemu-arm] [PATCH v2 07/27] imx_fec: Add support for multiple Tx DMA rings, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 08/27] imx_fec: Use correct length for packet size, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 09/27] imx_fec: Fix a typo in imx_enet_receive(), Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 10/27] imx_fec: Reserve full 4K page for the register file, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 14/27] i.MX: Add code to emulate i.MX2 watchdog IP block, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 11/27] sdhci: Add i.MX specific subtype of SDHCI, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 12/27] sdhci: Implement write method of ACMD12ERRSTS register, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 15/27] i.MX: Add code to emulate i.MX7 SNVS IP-block, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 13/27] i.MX: Add code to emulate i.MX7 CCM, PMU and ANALOG IP blocks, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 16/27] i.MX: Add code to emulate GPCv2 IP block, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 19/27] i.MX: Add code to emulate SDMA IP block,
Andrey Smirnov <=
- [Qemu-arm] [PATCH v2 21/27] i.MX: Add implementation of i.MX7 GPR IP block, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 24/27] i.MX: Add code to emulate i.MX7 ADC IP block, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 20/27] i.MX: Add code to emulate FlexCAN IP block, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 17/27] i.MX: Add code to emulate i.MX7 IOMUXC IP block, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 26/27] i.MX: Add i.MX7 SOC implementation., Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 23/27] i.MX: Add code to emulate i.MX7 USBMISC IP block, Andrey Smirnov, 2017/10/23
- [Qemu-arm] [PATCH v2 22/27] pci: Add support for Designware IP block, Andrey Smirnov, 2017/10/23