From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MR5qU-0006mh-RL for qemu-devel@nongnu.org; Wed, 15 Jul 2009 10:52:34 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MR5qQ-0006df-OT for qemu-devel@nongnu.org; Wed, 15 Jul 2009 10:52:34 -0400 Received: from [199.232.76.173] (port=53479 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MR5qQ-0006d6-GH for qemu-devel@nongnu.org; Wed, 15 Jul 2009 10:52:30 -0400 Received: from [82.113.48.144] (port=4820 helo=FilipNavara-PC) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1MR5qP-0000cE-Sf for qemu-devel@nongnu.org; Wed, 15 Jul 2009 10:52:30 -0400 Date: Wed, 15 Jul 09 16:52:27 Central Europe Standard Time From: Filip Navara Sender: Filip Navara MIME-Version: 1.0 Content-Type: text/plain; Message-Id: Subject: [Qemu-devel] [PATCH 10/14] AT91 interrupt shim List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- 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