From: Filip Navara <filip.navara@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 10/14] AT91 interrupt shim
Date: Wed, 15 Jul 09 16:52:27 Central Europe Standard Time [thread overview]
Message-ID: <E1MR5qQ-0006df-OT@lists.gnu.org> (raw)
The system controller in AT91 is composed of several devices and they are all
connected to single IRQ pin on the Advanced Interrupt Controller. This pseudo-
device allows multiplexing an IRQ pin by sending logic OR of all the inputs
to a single output pin.
Signed-off-by: Filip Navara <filip.navara@gmail.com>
---
Makefile.target | 2 +-
hw/at91_intor.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 79 insertions(+), 1 deletions(-)
create mode 100644 hw/at91_intor.c
diff --git a/Makefile.target b/Makefile.target
index 40a4adb..8ca1c1e 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -667,7 +667,7 @@ obj-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
obj-y += syborg_serial.o syborg_timer.o syborg_pointer.o syborg_rtc.o
obj-y += syborg_virtio.o
obj-y += at91_aic.o at91_dbgu.o at91_pio.o at91_pit.o at91_pmc.o at91_rtt.o
-obj-y += at91_rstc.o
+obj-y += at91_rstc.o at91_intor.o
obj-y += gpio_rotary.o gpio_keypad.o
CPPFLAGS += -DHAS_AUDIO
endif
diff --git a/hw/at91_intor.c b/hw/at91_intor.c
new file mode 100644
index 0000000..154d149
--- /dev/null
+++ b/hw/at91_intor.c
@@ -0,0 +1,78 @@
+/*
+ * AT91 Interrupt Logic OR
+ *
+ * Copyright (c) 2009 Filip Navara
+ *
+ * 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 "sysbus.h"
+
+typedef struct IntOrState {
+ SysBusDevice busdev;
+ qemu_irq parent_irq;
+ uint32_t sources;
+} IntOrState;
+
+static void at91_intor_set_irq(void *opaque, int irq, int level)
+{
+ IntOrState *s = opaque;
+
+ if (level) {
+ s->sources |= 1 << irq;
+ } else {
+ s->sources &= ~(1 << irq);
+ }
+ qemu_set_irq(s->parent_irq, !!s->sources);
+}
+
+static void at91_intor_save(QEMUFile *f, void *opaque)
+{
+ IntOrState *s = opaque;
+
+ qemu_put_be32(f, s->sources);
+}
+
+static int at91_intor_load(QEMUFile *f, void *opaque, int version_id)
+{
+ IntOrState *s = opaque;
+
+ if (version_id != 1)
+ return -EINVAL;
+
+ s->sources = qemu_get_be32(f);
+ return 0;
+}
+
+static void at91_intor_init(SysBusDevice *dev)
+{
+ IntOrState *s = FROM_SYSBUS(typeof (*s), dev);
+
+ qdev_init_gpio_in(&dev->qdev, at91_intor_set_irq, 32);
+ sysbus_init_irq(dev, &s->parent_irq);
+
+ register_savevm("at91_intor", -1, 1, at91_intor_save, at91_intor_load, s);
+}
+
+static void at91_intor_register(void)
+{
+ sysbus_register_dev("at91,intor", sizeof(IntOrState), at91_intor_init);
+}
+
+device_init(at91_intor_register)
--
1.6.3.msysgit.0
reply other threads:[~2009-07-15 14:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=E1MR5qQ-0006df-OT@lists.gnu.org \
--to=filip.navara@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).