diff mbox series

[RFC,3/3] hw/net/can: WIP CTU CAN FD add parameter to specify IRQ controller on command line

Message ID 2756d5a4999239f5ba9bd07237ab88230e7b7855.1733783500.git.pisa@cmp.felk.cvut.cz (mailing list archive)
State New
Headers show
Series WIP CTU CAN FD IP core mapping to the platform bus | expand

Commit Message

Pavel Pisa Dec. 9, 2024, 11:32 p.m. UTC
From: Pavel Pisa <pisa@cmp.felk.cvut.cz>

Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
---
 hw/net/can/ctucan_mm.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/hw/net/can/ctucan_mm.c b/hw/net/can/ctucan_mm.c
index 6d6b8aecb8..e599df18be 100644
--- a/hw/net/can/ctucan_mm.c
+++ b/hw/net/can/ctucan_mm.c
@@ -59,7 +59,8 @@  struct CtuCanMmState {
 
     struct {
         uint64_t    iobase;
-        uint32_t    irq;
+        uint32_t    irqnum;
+        char        *irqctrl;
     } cfg;
 
     MemoryRegion    ctucan_io_region;
@@ -144,9 +145,16 @@  static void ctucan_mm_realize(DeviceState *dev, Error **errp)
     if (d->cfg.iobase != 0) {
         sysbus_mmio_map(sbd, 0, d->cfg.iobase);
     }
-    if (d->cfg.irq != 0) {
+    if (d->cfg.irqnum != 0) {
         //const char *id = "/machine/unattached/device[3]/gic";
-        const char *id = "/machine/unattached/device[3]";
+        //const char *id = "/machine/unattached/device[3]";
+        char *id = d->cfg.irqctrl;
+
+        if (!id) {
+            error_setg(errp, "irqctrl object path is mandatory when irqnum is specified");
+            return;
+        }
+
         Object *obj = object_resolve_path_at(container_get(qdev_get_machine(), "/peripheral"), id);
         DeviceState *gicdev;
         if (!obj) {
@@ -158,7 +166,7 @@  static void ctucan_mm_realize(DeviceState *dev, Error **errp)
             error_setg(errp, "%s is not a hotpluggable device", id);
             return;
         }
-        sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(gicdev, d->cfg.irq));
+        sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(gicdev, d->cfg.irqnum));
     }
     for (i = 0 ; i < CTUCAN_MM_CORE_COUNT; i++) {
         ctucan_init(&d->ctucan_state[i], d->irq);
@@ -243,7 +251,8 @@  static Property ctucan_mm_properties[] = {
     //DEFINE_PROP_UNSIGNED_NODEFAULT("base", CtuCanMmState, cfg.base,
     //                               qdev_prop_uint64, uint64_t),
     DEFINE_PROP_UINT64("iobase", CtuCanMmState, cfg.iobase, 0),
-    DEFINE_PROP_UINT32("irq", CtuCanMmState, cfg.irq, 0),
+    DEFINE_PROP_UINT32("irqnum", CtuCanMmState, cfg.irqnum, 0),
+    DEFINE_PROP_STRING("irqctrl", CtuCanMmState, cfg.irqctrl),
     DEFINE_PROP_END_OF_LIST(),
 };