[PATCH 4/4] hw/arm/stellaris: Add missing QOM 'SoC' parent

Philippe Mathieu-Daudé posted 4 patches 10 months ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>
There is a newer version of this series
[PATCH 4/4] hw/arm/stellaris: Add missing QOM 'SoC' parent
Posted by Philippe Mathieu-Daudé 10 months ago
QDev objects created with qdev_new() need to manually add
their parent relationship with object_property_add_child().

Since we don't model the SoC, just use a QOM container.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/arm/stellaris.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
index bb88b3ebde..e349981308 100644
--- a/hw/arm/stellaris.c
+++ b/hw/arm/stellaris.c
@@ -1018,6 +1018,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
      * 400fe000 system control
      */
 
+    Object *soc_container;
     DeviceState *gpio_dev[7], *nvic;
     qemu_irq gpio_in[7][8];
     qemu_irq gpio_out[7][8];
@@ -1038,6 +1039,9 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
     flash_size = (((board->dc0 & 0xffff) + 1) << 1) * 1024;
     sram_size = ((board->dc0 >> 18) + 1) * 1024;
 
+    soc_container = object_new("container");
+    object_property_add_child(OBJECT(ms), "soc", soc_container);
+
     /* Flash programming is done via the SCU, so pretend it is ROM.  */
     memory_region_init_rom(flash, NULL, "stellaris.flash", flash_size,
                            &error_fatal);
@@ -1052,6 +1056,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
      * need its sysclk output.
      */
     ssys_dev = qdev_new(TYPE_STELLARIS_SYS);
+    object_property_add_child(soc_container, "sys", OBJECT(ssys_dev));
     /* Most devices come preprogrammed with a MAC address in the user data. */
     macaddr = nd_table[0].macaddr.a;
     qdev_prop_set_uint32(ssys_dev, "user0",
@@ -1068,6 +1073,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
     sysbus_realize_and_unref(SYS_BUS_DEVICE(ssys_dev), &error_fatal);
 
     nvic = qdev_new(TYPE_ARMV7M);
+    object_property_add_child(soc_container, "v7m", OBJECT(nvic));
     qdev_prop_set_uint32(nvic, "num-irq", NUM_IRQ_LINES);
     qdev_prop_set_uint8(nvic, "num-prio-bits", NUM_PRIO_BITS);
     qdev_prop_set_string(nvic, "cpu-type", ms->cpu_type);
@@ -1101,6 +1107,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
 
             dev = qdev_new(TYPE_STELLARIS_GPTM);
             sbd = SYS_BUS_DEVICE(dev);
+            object_property_add_child(soc_container, "gptm[*]", OBJECT(dev));
             qdev_connect_clock_in(dev, "clk",
                                   qdev_get_clock_out(ssys_dev, "SYSCLK"));
             sysbus_realize_and_unref(sbd, &error_fatal);
@@ -1114,7 +1121,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
 
     if (board->dc1 & (1 << 3)) { /* watchdog present */
         dev = qdev_new(TYPE_LUMINARY_WATCHDOG);
-
+        object_property_add_child(soc_container, "wdg", OBJECT(dev));
         qdev_connect_clock_in(dev, "WDOGCLK",
                               qdev_get_clock_out(ssys_dev, "SYSCLK"));
 
@@ -1154,6 +1161,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
             SysBusDevice *sbd;
 
             dev = qdev_new("pl011_luminary");
+            object_property_add_child(soc_container, "uart[*]", OBJECT(dev));
             sbd = SYS_BUS_DEVICE(dev);
             qdev_prop_set_chr(dev, "chardev", serial_hd(i));
             sysbus_realize_and_unref(sbd, &error_fatal);
@@ -1276,6 +1284,7 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
         qemu_check_nic_model(&nd_table[0], "stellaris");
 
         enet = qdev_new("stellaris_enet");
+        object_property_add_child(soc_container, "enet", OBJECT(enet));
         qdev_set_nic_properties(enet, &nd_table[0]);
         sysbus_realize_and_unref(SYS_BUS_DEVICE(enet), &error_fatal);
         sysbus_mmio_map(SYS_BUS_DEVICE(enet), 0, 0x40048000);
-- 
2.41.0


Re: [PATCH 4/4] hw/arm/stellaris: Add missing QOM 'SoC' parent
Posted by Peter Maydell 9 months, 4 weeks ago
On Tue, 30 Jan 2024 at 19:03, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> QDev objects created with qdev_new() need to manually add
> their parent relationship with object_property_add_child().
>
> Since we don't model the SoC, just use a QOM container.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---

Ah, this is where the other qdev_new() calls are sorted.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

I wonder if we should add a variant on qdev_new() that
you can pass in the parent object to?

thanks
-- PMM
Re: [PATCH 4/4] hw/arm/stellaris: Add missing QOM 'SoC' parent
Posted by Philippe Mathieu-Daudé 9 months, 2 weeks ago
On 1/2/24 17:46, Peter Maydell wrote:
> On Tue, 30 Jan 2024 at 19:03, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> QDev objects created with qdev_new() need to manually add
>> their parent relationship with object_property_add_child().
>>
>> Since we don't model the SoC, just use a QOM container.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
> 
> Ah, this is where the other qdev_new() calls are sorted.
> 
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> 
> I wonder if we should add a variant on qdev_new() that
> you can pass in the parent object to?

Yes, this is what we discussed with Markus. In order to
stop using the "/unattached" container from pre-QOM,
qdev_new() must take a QOM parent. I tried to do it but hit
some problem with some odd use in PPC or S390 (discussed
with Cédric so likely PPC, I need to go back to it).

Re: [PATCH 4/4] hw/arm/stellaris: Add missing QOM 'SoC' parent
Posted by Cédric Le Goater 9 months, 2 weeks ago
On 2/13/24 16:36, Philippe Mathieu-Daudé wrote:
> On 1/2/24 17:46, Peter Maydell wrote:
>> On Tue, 30 Jan 2024 at 19:03, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>>
>>> QDev objects created with qdev_new() need to manually add
>>> their parent relationship with object_property_add_child().
>>>
>>> Since we don't model the SoC, just use a QOM container.
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>
>> Ah, this is where the other qdev_new() calls are sorted.
>>
>> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>>
>> I wonder if we should add a variant on qdev_new() that
>> you can pass in the parent object to?
> 
> Yes, this is what we discussed with Markus. In order to
> stop using the "/unattached" container from pre-QOM,
> qdev_new() must take a QOM parent. I tried to do it but hit
> some problem with some odd use in PPC or S390 (discussed
> with Cédric so likely PPC, I need to go back to it).

Can you remind what this was about ?


Thanks,

C.