diff mbox series

[v2,07/10] hw/isa/vt82c686: Instantiate PM function in host device

Message ID 20220830190048.67448-8-shentey@gmail.com (mailing list archive)
State New, archived
Headers show
Series Instantiate VT82xx functions in host device | expand

Commit Message

Bernhard Beschow Aug. 30, 2022, 7 p.m. UTC
The PM controller has activity bits which monitor activity of other
built-in devices in the host device.

Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
 hw/isa/vt82c686.c         | 12 ++++++++++++
 hw/mips/fuloong2e.c       |  2 +-
 hw/ppc/pegasos2.c         |  3 +--
 include/hw/isa/vt82c686.h |  2 --
 4 files changed, 14 insertions(+), 5 deletions(-)

Comments

BALATON Zoltan Aug. 30, 2022, 10:39 p.m. UTC | #1
On Tue, 30 Aug 2022, Bernhard Beschow wrote:
> The PM controller has activity bits which monitor activity of other
> built-in devices in the host device.
>
> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
> ---
> hw/isa/vt82c686.c         | 12 ++++++++++++
> hw/mips/fuloong2e.c       |  2 +-
> hw/ppc/pegasos2.c         |  3 +--
> include/hw/isa/vt82c686.h |  2 --
> 4 files changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
> index 6aba7f29de..4e66570655 100644
> --- a/hw/isa/vt82c686.c
> +++ b/hw/isa/vt82c686.c
> @@ -40,6 +40,9 @@
> #define TYPE_VIA_PM "via-pm"
> OBJECT_DECLARE_SIMPLE_TYPE(ViaPMState, VIA_PM)
>
> +#define TYPE_VT82C686B_PM "vt82c686b-pm"
> +#define TYPE_VT8231_PM "vt8231-pm"

These defines should be further down before vt82c686b_pm_init_info and 
vt8231_pm_init_info respectively to keep object class definitions 
together. Here the generic abstract superclass is defined, followed be the 
specific chips so it's too early to define these at this point.

Regards,
BALATON Zoltan

> +
> struct ViaPMState {
>     PCIDevice dev;
>     MemoryRegion io;
> @@ -548,6 +551,7 @@ struct ViaISAState {
>     ViaSuperIOState via_sio;
>     PCIIDEState ide;
>     UHCIState uhci[2];
> +    ViaPMState pm;
> };
>
> static const VMStateDescription vmstate_via = {
> @@ -641,6 +645,12 @@ static void via_isa_realize(PCIDevice *d, Error **errp)
>             return;
>         }
>     }
> +
> +    /* Function 4: Power Management */
> +    qdev_prop_set_int32(DEVICE(&s->pm), "addr", d->devfn + 4);
> +    if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) {
> +        return;
> +    }
> }
>
> /* TYPE_VT82C686B_ISA */
> @@ -683,6 +693,7 @@ static void vt82c686b_init(Object *obj)
>     ViaISAState *s = VIA_ISA(obj);
>
>     object_initialize_child(obj, "sio", &s->via_sio, TYPE_VT82C686B_SUPERIO);
> +    object_initialize_child(obj, "pm", &s->pm, TYPE_VT82C686B_PM);
> }
>
> static void vt82c686b_class_init(ObjectClass *klass, void *data)
> @@ -746,6 +757,7 @@ static void vt8231_init(Object *obj)
>     ViaISAState *s = VIA_ISA(obj);
>
>     object_initialize_child(obj, "sio", &s->via_sio, TYPE_VT8231_SUPERIO);
> +    object_initialize_child(obj, "pm", &s->pm, TYPE_VT8231_PM);
> }
>
> static void vt8231_class_init(ObjectClass *klass, void *data)
> diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
> index dc92223b76..377108d313 100644
> --- a/hw/mips/fuloong2e.c
> +++ b/hw/mips/fuloong2e.c
> @@ -208,7 +208,7 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq intc,
>     dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
>     pci_ide_create_devs(dev);
>
> -    dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 4), TYPE_VT82C686B_PM);
> +    dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm"));
>     *i2c_bus = I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c"));
>
>     /* Audio support */
> diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
> index 85cca6f7a6..e32944ee2b 100644
> --- a/hw/ppc/pegasos2.c
> +++ b/hw/ppc/pegasos2.c
> @@ -168,8 +168,7 @@ static void pegasos2_init(MachineState *machine)
>     dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
>     pci_ide_create_devs(dev);
>
> -    /* VT8231 function 4: Power Management Controller */
> -    dev = pci_create_simple(pci_bus, PCI_DEVFN(12, 4), TYPE_VT8231_PM);
> +    dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm"));
>     i2c_bus = I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c"));
>     spd_data = spd_data_generate(DDR, machine->ram_size);
>     smbus_eeprom_init_one(i2c_bus, 0x57, spd_data);
> diff --git a/include/hw/isa/vt82c686.h b/include/hw/isa/vt82c686.h
> index 56ac141be3..559f7c8926 100644
> --- a/include/hw/isa/vt82c686.h
> +++ b/include/hw/isa/vt82c686.h
> @@ -4,9 +4,7 @@
> #include "hw/pci/pci.h"
>
> #define TYPE_VT82C686B_ISA "vt82c686b-isa"
> -#define TYPE_VT82C686B_PM "vt82c686b-pm"
> #define TYPE_VT8231_ISA "vt8231-isa"
> -#define TYPE_VT8231_PM "vt8231-pm"
> #define TYPE_VIA_AC97 "via-ac97"
> #define TYPE_VIA_MC97 "via-mc97"
>
>
Bernhard Beschow Aug. 31, 2022, 10:04 a.m. UTC | #2
Am 31. August 2022 00:39:22 MESZ schrieb BALATON Zoltan <balaton@eik.bme.hu>:
>On Tue, 30 Aug 2022, Bernhard Beschow wrote:
>> The PM controller has activity bits which monitor activity of other
>> built-in devices in the host device.
>> 
>> Signed-off-by: Bernhard Beschow <shentey@gmail.com>
>> ---
>> hw/isa/vt82c686.c         | 12 ++++++++++++
>> hw/mips/fuloong2e.c       |  2 +-
>> hw/ppc/pegasos2.c         |  3 +--
>> include/hw/isa/vt82c686.h |  2 --
>> 4 files changed, 14 insertions(+), 5 deletions(-)
>> 
>> diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
>> index 6aba7f29de..4e66570655 100644
>> --- a/hw/isa/vt82c686.c
>> +++ b/hw/isa/vt82c686.c
>> @@ -40,6 +40,9 @@
>> #define TYPE_VIA_PM "via-pm"
>> OBJECT_DECLARE_SIMPLE_TYPE(ViaPMState, VIA_PM)
>> 
>> +#define TYPE_VT82C686B_PM "vt82c686b-pm"
>> +#define TYPE_VT8231_PM "vt8231-pm"
>
>These defines should be further down before vt82c686b_pm_init_info and vt8231_pm_init_info respectively to keep object class definitions together. Here the generic abstract superclass is defined, followed be the specific chips so it's too early to define these at this point.

Right. Fixed in v3.

Regards,
Bernhard
>
>Regards,
>BALATON Zoltan
>
>> +
>> struct ViaPMState {
>>     PCIDevice dev;
>>     MemoryRegion io;
>> @@ -548,6 +551,7 @@ struct ViaISAState {
>>     ViaSuperIOState via_sio;
>>     PCIIDEState ide;
>>     UHCIState uhci[2];
>> +    ViaPMState pm;
>> };
>> 
>> static const VMStateDescription vmstate_via = {
>> @@ -641,6 +645,12 @@ static void via_isa_realize(PCIDevice *d, Error **errp)
>>             return;
>>         }
>>     }
>> +
>> +    /* Function 4: Power Management */
>> +    qdev_prop_set_int32(DEVICE(&s->pm), "addr", d->devfn + 4);
>> +    if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) {
>> +        return;
>> +    }
>> }
>> 
>> /* TYPE_VT82C686B_ISA */
>> @@ -683,6 +693,7 @@ static void vt82c686b_init(Object *obj)
>>     ViaISAState *s = VIA_ISA(obj);
>> 
>>     object_initialize_child(obj, "sio", &s->via_sio, TYPE_VT82C686B_SUPERIO);
>> +    object_initialize_child(obj, "pm", &s->pm, TYPE_VT82C686B_PM);
>> }
>> 
>> static void vt82c686b_class_init(ObjectClass *klass, void *data)
>> @@ -746,6 +757,7 @@ static void vt8231_init(Object *obj)
>>     ViaISAState *s = VIA_ISA(obj);
>> 
>>     object_initialize_child(obj, "sio", &s->via_sio, TYPE_VT8231_SUPERIO);
>> +    object_initialize_child(obj, "pm", &s->pm, TYPE_VT8231_PM);
>> }
>> 
>> static void vt8231_class_init(ObjectClass *klass, void *data)
>> diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
>> index dc92223b76..377108d313 100644
>> --- a/hw/mips/fuloong2e.c
>> +++ b/hw/mips/fuloong2e.c
>> @@ -208,7 +208,7 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq intc,
>>     dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
>>     pci_ide_create_devs(dev);
>> 
>> -    dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 4), TYPE_VT82C686B_PM);
>> +    dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm"));
>>     *i2c_bus = I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c"));
>> 
>>     /* Audio support */
>> diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
>> index 85cca6f7a6..e32944ee2b 100644
>> --- a/hw/ppc/pegasos2.c
>> +++ b/hw/ppc/pegasos2.c
>> @@ -168,8 +168,7 @@ static void pegasos2_init(MachineState *machine)
>>     dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
>>     pci_ide_create_devs(dev);
>> 
>> -    /* VT8231 function 4: Power Management Controller */
>> -    dev = pci_create_simple(pci_bus, PCI_DEVFN(12, 4), TYPE_VT8231_PM);
>> +    dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm"));
>>     i2c_bus = I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c"));
>>     spd_data = spd_data_generate(DDR, machine->ram_size);
>>     smbus_eeprom_init_one(i2c_bus, 0x57, spd_data);
>> diff --git a/include/hw/isa/vt82c686.h b/include/hw/isa/vt82c686.h
>> index 56ac141be3..559f7c8926 100644
>> --- a/include/hw/isa/vt82c686.h
>> +++ b/include/hw/isa/vt82c686.h
>> @@ -4,9 +4,7 @@
>> #include "hw/pci/pci.h"
>> 
>> #define TYPE_VT82C686B_ISA "vt82c686b-isa"
>> -#define TYPE_VT82C686B_PM "vt82c686b-pm"
>> #define TYPE_VT8231_ISA "vt8231-isa"
>> -#define TYPE_VT8231_PM "vt8231-pm"
>> #define TYPE_VIA_AC97 "via-ac97"
>> #define TYPE_VIA_MC97 "via-mc97"
>> 
>>
diff mbox series

Patch

diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 6aba7f29de..4e66570655 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -40,6 +40,9 @@ 
 #define TYPE_VIA_PM "via-pm"
 OBJECT_DECLARE_SIMPLE_TYPE(ViaPMState, VIA_PM)
 
+#define TYPE_VT82C686B_PM "vt82c686b-pm"
+#define TYPE_VT8231_PM "vt8231-pm"
+
 struct ViaPMState {
     PCIDevice dev;
     MemoryRegion io;
@@ -548,6 +551,7 @@  struct ViaISAState {
     ViaSuperIOState via_sio;
     PCIIDEState ide;
     UHCIState uhci[2];
+    ViaPMState pm;
 };
 
 static const VMStateDescription vmstate_via = {
@@ -641,6 +645,12 @@  static void via_isa_realize(PCIDevice *d, Error **errp)
             return;
         }
     }
+
+    /* Function 4: Power Management */
+    qdev_prop_set_int32(DEVICE(&s->pm), "addr", d->devfn + 4);
+    if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) {
+        return;
+    }
 }
 
 /* TYPE_VT82C686B_ISA */
@@ -683,6 +693,7 @@  static void vt82c686b_init(Object *obj)
     ViaISAState *s = VIA_ISA(obj);
 
     object_initialize_child(obj, "sio", &s->via_sio, TYPE_VT82C686B_SUPERIO);
+    object_initialize_child(obj, "pm", &s->pm, TYPE_VT82C686B_PM);
 }
 
 static void vt82c686b_class_init(ObjectClass *klass, void *data)
@@ -746,6 +757,7 @@  static void vt8231_init(Object *obj)
     ViaISAState *s = VIA_ISA(obj);
 
     object_initialize_child(obj, "sio", &s->via_sio, TYPE_VT8231_SUPERIO);
+    object_initialize_child(obj, "pm", &s->pm, TYPE_VT8231_PM);
 }
 
 static void vt8231_class_init(ObjectClass *klass, void *data)
diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
index dc92223b76..377108d313 100644
--- a/hw/mips/fuloong2e.c
+++ b/hw/mips/fuloong2e.c
@@ -208,7 +208,7 @@  static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq intc,
     dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
     pci_ide_create_devs(dev);
 
-    dev = pci_create_simple(pci_bus, PCI_DEVFN(slot, 4), TYPE_VT82C686B_PM);
+    dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm"));
     *i2c_bus = I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c"));
 
     /* Audio support */
diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
index 85cca6f7a6..e32944ee2b 100644
--- a/hw/ppc/pegasos2.c
+++ b/hw/ppc/pegasos2.c
@@ -168,8 +168,7 @@  static void pegasos2_init(MachineState *machine)
     dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "ide"));
     pci_ide_create_devs(dev);
 
-    /* VT8231 function 4: Power Management Controller */
-    dev = pci_create_simple(pci_bus, PCI_DEVFN(12, 4), TYPE_VT8231_PM);
+    dev = PCI_DEVICE(object_resolve_path_component(OBJECT(via), "pm"));
     i2c_bus = I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c"));
     spd_data = spd_data_generate(DDR, machine->ram_size);
     smbus_eeprom_init_one(i2c_bus, 0x57, spd_data);
diff --git a/include/hw/isa/vt82c686.h b/include/hw/isa/vt82c686.h
index 56ac141be3..559f7c8926 100644
--- a/include/hw/isa/vt82c686.h
+++ b/include/hw/isa/vt82c686.h
@@ -4,9 +4,7 @@ 
 #include "hw/pci/pci.h"
 
 #define TYPE_VT82C686B_ISA "vt82c686b-isa"
-#define TYPE_VT82C686B_PM "vt82c686b-pm"
 #define TYPE_VT8231_ISA "vt8231-isa"
-#define TYPE_VT8231_PM "vt8231-pm"
 #define TYPE_VIA_AC97 "via-ac97"
 #define TYPE_VIA_MC97 "via-mc97"