Commit 42fe8e59abe6c0f30c71bf4e80d5ac311522bd2f

Authored by Filip Navara
1 parent 44b66891

AT91 interrupt shim

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
... ... @@ -432,7 +432,7 @@ obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
432 432 obj-arm-y += syborg_serial.o syborg_timer.o syborg_pointer.o syborg_rtc.o
433 433 obj-arm-y += syborg_virtio.o
434 434 obj-arm-y += at91_aic.o at91_dbgu.o at91_pio.o at91_pit.o at91_pmc.o at91_rtt.o
435   -obj-arm-y += at91_rstc.o
  435 +obj-arm-y += at91_rstc.o at91_intor.o
436 436 obj-arm-y += gpio_rotary.o gpio_keypad.o
437 437  
438 438 ifeq ($(TARGET_BASE_ARCH), arm)
... ...
hw/at91_intor.c 0 → 100644
  1 +/*
  2 + * AT91 Interrupt Logic OR
  3 + *
  4 + * Copyright (c) 2009 Filip Navara
  5 + *
  6 + * Permission is hereby granted, free of charge, to any person obtaining a copy
  7 + * of this software and associated documentation files (the "Software"), to deal
  8 + * in the Software without restriction, including without limitation the rights
  9 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10 + * copies of the Software, and to permit persons to whom the Software is
  11 + * furnished to do so, subject to the following conditions:
  12 + *
  13 + * The above copyright notice and this permission notice shall be included in
  14 + * all copies or substantial portions of the Software.
  15 + *
  16 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22 + * THE SOFTWARE.
  23 + */
  24 +
  25 +#include "sysbus.h"
  26 +
  27 +typedef struct IntOrState {
  28 + SysBusDevice busdev;
  29 + qemu_irq parent_irq;
  30 + uint32_t sources;
  31 +} IntOrState;
  32 +
  33 +static void at91_intor_set_irq(void *opaque, int irq, int level)
  34 +{
  35 + IntOrState *s = opaque;
  36 +
  37 + if (level) {
  38 + s->sources |= 1 << irq;
  39 + } else {
  40 + s->sources &= ~(1 << irq);
  41 + }
  42 + qemu_set_irq(s->parent_irq, !!s->sources);
  43 +}
  44 +
  45 +static void at91_intor_save(QEMUFile *f, void *opaque)
  46 +{
  47 + IntOrState *s = opaque;
  48 +
  49 + qemu_put_be32(f, s->sources);
  50 +}
  51 +
  52 +static int at91_intor_load(QEMUFile *f, void *opaque, int version_id)
  53 +{
  54 + IntOrState *s = opaque;
  55 +
  56 + if (version_id != 1)
  57 + return -EINVAL;
  58 +
  59 + s->sources = qemu_get_be32(f);
  60 + return 0;
  61 +}
  62 +
  63 +static void at91_intor_reset(void *opaque)
  64 +{
  65 + IntOrState *s = opaque;
  66 +
  67 + s->sources = 0;
  68 +}
  69 +
  70 +static void at91_intor_init(SysBusDevice *dev)
  71 +{
  72 + IntOrState *s = FROM_SYSBUS(typeof (*s), dev);
  73 +
  74 + qdev_init_gpio_in(&dev->qdev, at91_intor_set_irq, 32);
  75 + sysbus_init_irq(dev, &s->parent_irq);
  76 +
  77 + qemu_register_reset(at91_intor_reset, s);
  78 +
  79 + register_savevm("at91_intor", -1, 1, at91_intor_save, at91_intor_load, s);
  80 +}
  81 +
  82 +static void at91_intor_register(void)
  83 +{
  84 + sysbus_register_dev("at91,intor", sizeof(IntOrState), at91_intor_init);
  85 +}
  86 +
  87 +device_init(at91_intor_register)
... ...