From: Michel Pollet <buserror@gmail.com>
To: qemu-devel@nongnu.org
Cc: Michel Pollet <buserror@gmail.com>
Subject: [Qemu-devel] [PATCH 06/13] mxs/imx23: Add digctl driver
Date: Wed, 11 Dec 2013 13:56:25 +0000 [thread overview]
Message-ID: <1386770192-19585-7-git-send-email-buserror@gmail.com> (raw)
In-Reply-To: <1386770192-19585-1-git-send-email-buserror@gmail.com>
This implements just enough of the digctl IO block to allow
linux to believe it's running on (currently only) an imx23.
Signed-off-by: Michel Pollet <buserror@gmail.com>
---
hw/arm/Makefile.objs | 1 +
hw/arm/imx23_digctl.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 111 insertions(+)
create mode 100644 hw/arm/imx23_digctl.c
diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs
index 78b5614..9adcb96 100644
--- a/hw/arm/Makefile.objs
+++ b/hw/arm/Makefile.objs
@@ -5,3 +5,4 @@ obj-y += tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o
obj-y += armv7m.o exynos4210.o pxa2xx.o pxa2xx_gpio.o pxa2xx_pic.o
obj-y += omap1.o omap2.o strongarm.o
+obj-$(CONFIG_MXS) += imx23_digctl.o
diff --git a/hw/arm/imx23_digctl.c b/hw/arm/imx23_digctl.c
new file mode 100644
index 0000000..b7cd1ff
--- /dev/null
+++ b/hw/arm/imx23_digctl.c
@@ -0,0 +1,110 @@
+/*
+ * imx23_digctl.c
+ *
+ * Copyright: Michel Pollet <buserror@gmail.com>
+ *
+ * QEMU Licence
+ */
+
+/*
+ * This module implements a very basic IO block for the digctl of the imx23
+ * Basically there is no real logic, just constant registers return, the most
+ * used one bing the "chip id" that is used by the various linux drivers
+ * to differentiate between imx23 and 28.
+ *
+ * The module consists mostly of read/write registers that the bootloader and
+ * kernel are quite happy to 'set' to whatever value they believe they set...
+ */
+
+#include "hw/sysbus.h"
+#include "hw/arm/mxs.h"
+
+enum {
+ HW_DIGCTL_RAMCTL = 0x3,
+ HW_DIGCTL_CHIPID = 0x31,
+};
+
+typedef struct imx23_digctl_state {
+ SysBusDevice busdev;
+ MemoryRegion iomem;
+
+ uint32_t reg[0x2000 / 4];
+} imx23_digctl_state;
+
+static uint64_t imx23_digctl_read(
+ void *opaque, hwaddr offset, unsigned size)
+{
+ imx23_digctl_state *s = (imx23_digctl_state *)opaque;
+ uint32_t res = 0;
+
+ switch (offset >> 4) {
+ case 0 ... 0x2000/4:
+ res = s->reg[offset >> 4];
+ break;
+ default:
+ qemu_log_mask(LOG_GUEST_ERROR,
+ "%s: bad offset 0x%x\n", __func__, (int)offset);
+ return 0;
+ }
+ return res;
+}
+
+static void imx23_digctl_write(
+ void *opaque, hwaddr offset, uint64_t value, unsigned size)
+{
+ imx23_digctl_state *s = (imx23_digctl_state *) opaque;
+ uint32_t * dst = NULL;
+
+ switch (offset >> 4) {
+ case 0 ... 0x2000 / 4:
+ dst = &s->reg[(offset >> 4)];
+ break;
+ default:
+ qemu_log_mask(LOG_GUEST_ERROR,
+ "%s: bad offset 0x%x\n", __func__, (int) offset);
+ return;
+ }
+ if (!dst) {
+ return;
+ }
+ mxs_write(dst, offset, value, size);
+}
+
+static const MemoryRegionOps imx23_digctl_ops = {
+ .read = imx23_digctl_read,
+ .write = imx23_digctl_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+};
+
+static int imx23_digctl_init(SysBusDevice *dev)
+{
+ imx23_digctl_state *s = OBJECT_CHECK(imx23_digctl_state, dev, "imx23_digctl");
+
+ memory_region_init_io(&s->iomem, OBJECT(s), &imx23_digctl_ops, s,
+ "imx23_digctl", 0x2000);
+ sysbus_init_mmio(dev, &s->iomem);
+ s->reg[HW_DIGCTL_RAMCTL] = 0x6d676953; /* default reset value */
+ s->reg[HW_DIGCTL_CHIPID] = 0x37800000; /* i.mX233 */
+ return 0;
+}
+
+static void imx23_digctl_class_init(ObjectClass *klass, void *data)
+{
+ SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
+
+ sdc->init = imx23_digctl_init;
+}
+
+static TypeInfo digctl_info = {
+ .name = "imx23_digctl",
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(imx23_digctl_state),
+ .class_init = imx23_digctl_class_init,
+};
+
+static void imx23_digctl_register(void)
+{
+ type_register_static(&digctl_info);
+}
+
+type_init(imx23_digctl_register)
--
1.8.5.1
next prev parent reply other threads:[~2013-12-11 13:49 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-11 13:56 [Qemu-devel] [PATCH 00/13] Freescale mxs/imx23 + Olimex Olinuxino support Michel Pollet
2013-12-11 13:56 ` [Qemu-devel] [PATCH 01/13] mxs/imx23: Add main header file Michel Pollet
2013-12-11 13:56 ` [Qemu-devel] [PATCH 02/13] mxs: Add CONFIG_MXS to the arm-softmmu config Michel Pollet
2014-01-06 15:08 ` Peter Maydell
2013-12-11 13:56 ` [Qemu-devel] [PATCH 03/13] mxs/imx23: Add uart driver Michel Pollet
2014-01-06 15:19 ` Peter Maydell
2014-01-11 7:39 ` Peter Crosthwaite
2013-12-11 13:56 ` [Qemu-devel] [PATCH 04/13] mxs/imx23: Add DMA driver Michel Pollet
2014-01-06 15:35 ` Peter Maydell
2014-01-10 0:52 ` Peter Crosthwaite
2014-01-10 0:54 ` Peter Crosthwaite
2014-01-10 10:55 ` Peter Maydell
2013-12-11 13:56 ` [Qemu-devel] [PATCH 05/13] mxs/imx23: Add the interrupt collector Michel Pollet
2014-01-06 15:41 ` Peter Maydell
2014-01-11 8:29 ` Peter Crosthwaite
2013-12-11 13:56 ` Michel Pollet [this message]
2014-01-06 15:46 ` [Qemu-devel] [PATCH 06/13] mxs/imx23: Add digctl driver Peter Maydell
2014-01-08 18:39 ` M P
2014-01-08 18:55 ` Peter Maydell
2014-01-11 8:44 ` Peter Crosthwaite
2014-01-11 8:39 ` Peter Crosthwaite
2013-12-11 13:56 ` [Qemu-devel] [PATCH 07/13] mxs/imx23: Implements the pin mux, GPIOs Michel Pollet
2014-01-06 15:52 ` Peter Maydell
2014-01-08 18:16 ` M P
2013-12-11 13:56 ` [Qemu-devel] [PATCH 08/13] mxs/imx23: Add SSP/SPI driver Michel Pollet
2014-01-11 9:08 ` Peter Crosthwaite
2013-12-11 13:56 ` [Qemu-devel] [PATCH 09/13] mxs/imx23: Add the RTC block Michel Pollet
2014-01-11 9:16 ` Peter Crosthwaite
2013-12-11 13:56 ` [Qemu-devel] [PATCH 10/13] mxs/imx23: Add the timers Michel Pollet
2013-12-11 13:56 ` [Qemu-devel] [PATCH 11/13] mxs/imx23: Add the USB driver Michel Pollet
2014-01-11 9:57 ` Peter Crosthwaite
2013-12-11 13:56 ` [Qemu-devel] [PATCH 12/13] mxs/imx23: Main core instantiation and minor IO blocks Michel Pollet
2013-12-11 13:56 ` [Qemu-devel] [PATCH 13/13] mxs/imx23: Adds support for an Olinuxino board Michel Pollet
2013-12-13 12:53 ` [Qemu-devel] [PATCH 00/13] Freescale mxs/imx23 + Olimex Olinuxino support M P
2013-12-13 13:29 ` Peter Maydell
2013-12-13 13:45 ` M P
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1386770192-19585-7-git-send-email-buserror@gmail.com \
--to=buserror@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).