Skip to contentSkip to conversation

Raspberry PI GPIO interrupt support

PATCH New Davide Berardi 1 participant 1 message Feb 9, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Raspberry PI GPIO interrupt support

The bcm2835 GPIOs now generate interrupts.
This modification enables QTEST clients to trigger interrupt-based interfaces.

---
 hw/arm/bcm2835_peripherals.c   |   2 +
 hw/gpio/bcm2835_gpio.c         | 105 +++++++++++++++++++++++++++++++++
 hw/intc/bcm2835_ic.c           |   2 -
 include/hw/gpio/bcm2835_gpio.h |  12 ++++
 4 files changed, 119 insertions(+), 2 deletions(-)
hw/arm/bcm2835_peripherals.c +2 -0
index dcff13433e..101c3e6fba 100644
@@ -114,6 +114,8 @@ static void bcm2835_peripherals_init(Object *obj)
                                    OBJECT(&s->sdhci.sdbus));
     object_property_add_const_link(OBJECT(&s->gpio), "sdbus-sdhost",
                                    OBJECT(&s->sdhost.sdbus));
+    object_property_add_const_link(OBJECT(&s->gpio), "ic",
+                                   OBJECT(&s->ic));
 
     /* Mphi */
     object_initialize_child(obj, "mphi", &s->mphi, TYPE_BCM2835_MPHI);
hw/gpio/bcm2835_gpio.c +105 -0

175 lines not on this page · raw message

hw/intc/bcm2835_ic.c +0 -2
index 9000d995e8..b381dc6603 100644
@@ -57,7 +57,6 @@ static void bcm2835_ic_update(BCM2835ICState *s)
 static void bcm2835_ic_set_gpu_irq(void *opaque, int irq, int level)
 {
     BCM2835ICState *s = opaque;
-
     assert(irq >= 0 && irq < 64);
     trace_bcm2835_ic_set_gpu_irq(irq, level);
     s->gpu_irq_level = deposit64(s->gpu_irq_level, irq, 1, level != 0);
@@ -67,7 +66,6 @@ static void bcm2835_ic_set_gpu_irq(void *opaque, int irq, int level)
 static void bcm2835_ic_set_arm_irq(void *opaque, int irq, int level)
 {
     BCM2835ICState *s = opaque;
-
     assert(irq >= 0 && irq < 8);
     trace_bcm2835_ic_set_cpu_irq(irq, level);
     s->arm_irq_level = deposit32(s->arm_irq_level, irq, 1, level != 0);
include/hw/gpio/bcm2835_gpio.h +12 -0
index 1c53a05090..cad3e987d3 100644
@@ -7,6 +7,9 @@
  *  Clement Deschamps <[email protected]>
  *  Luc Michel <[email protected]>
  *
+ * GPIO External support
+ *  Davide Berardi <[email protected]>
+ *
  * This work is licensed under the terms of the GNU GPL, version 2 or later.
  * See the COPYING file in the top-level directory.
  */
@@ -17,6 +20,7 @@
 #include "hw/sd/sd.h"
 #include "hw/sysbus.h"
 #include "qom/object.h"
+#include "hw/intc/bcm2835_ic.h"
 
 struct BCM2835GpioState {
     SysBusDevice parent_obj;
@@ -27,11 +31,19 @@ struct BCM2835GpioState {
     SDBus sdbus;
     SDBus *sdbus_sdhci;
     SDBus *sdbus_sdhost;
+    BCM2835ICState *ic;
 
     uint8_t fsel[54];
     uint32_t lev0, lev1;
+    /* Event detection */
+    uint32_t eds0, eds1;
+    /* Edge selector */
+    uint32_t ren0, ren1;
+    uint32_t fen0, fen1;
+
     uint8_t sd_fsel;
     qemu_irq out[54];
+    qemu_irq irq[3];
 };
 
 #define TYPE_BCM2835_GPIO "bcm2835_gpio"
Signature · 1 line
2.30.0