leon3: use qdev gpio facilities for the PIL
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Wed, 20 Nov 2019 13:38:51 +0000 (17:38 +0400)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 7 Jan 2020 13:24:29 +0000 (17:24 +0400)
As Peter Maydell once said:
"Creating a gpio pin on some object that isn't yourself
looks a bit odd, but all this leon3 code is modifying
the CPU object from the outside anyway. Someday we might
tidy it up, but not today."

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
hw/sparc/leon3.c
target/sparc/cpu.h

index cac987373e165b91d5389802c420531986c2d852..8038887ff7cf6ce21390cf069e2ed3485b5d6fc3 100644 (file)
@@ -230,8 +230,10 @@ static void leon3_generic_hw_init(MachineState *machine)
 
     /* Allocate IRQ manager */
     dev = qdev_create(NULL, TYPE_GRLIB_IRQMP);
-    env->pil_irq = qemu_allocate_irq(leon3_set_pil_in, env, 0);
-    qdev_connect_gpio_out_named(dev, "grlib-irq", 0, env->pil_irq);
+    qdev_init_gpio_in_named_with_opaque(DEVICE(cpu), leon3_set_pil_in,
+                                        env, "pil", 1);
+    qdev_connect_gpio_out_named(dev, "grlib-irq", 0,
+                                qdev_get_gpio_in_named(DEVICE(cpu), "pil", 0));
     qdev_init_nofail(dev);
     sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, LEON3_IRQMP_OFFSET);
     env->irq_manager = dev;
index e70fec01339a3c32beba7ac19bcf59b731e4e649..ae97c7d9f7998a94c4a1c4d8ebfde379bc2e2ecb 100644 (file)
@@ -541,7 +541,6 @@ struct CPUSPARCState {
 #endif
     sparc_def_t def;
 
-    qemu_irq pil_irq;
     void *irq_manager;
     void (*qemu_irq_ack)(CPUSPARCState *env, void *irq_manager, int intno);