On Tue, Aug 23, 2022 at 2:44 AM BALATON Zoltan <bala...@eik.bme.hu> wrote:

> On Tue, 23 Aug 2022, Bernhard Beschow wrote:
> > Resolves duplicate code in the boards.
> >
> > Signed-off-by: Bernhard Beschow <shen...@gmail.com>
> > ---
> > hw/isa/vt82c686.c   | 16 ++++++++++++++++
> > hw/mips/fuloong2e.c |  4 ----
> > hw/ppc/pegasos2.c   |  4 ----
> > 3 files changed, 16 insertions(+), 8 deletions(-)
> >
> > diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
> > index b964d1a760..47f2fd2669 100644
> > --- a/hw/isa/vt82c686.c
> > +++ b/hw/isa/vt82c686.c
> > @@ -549,6 +549,8 @@ struct ViaISAState {
> >     PCIIDEState ide;
> >     UHCIState uhci[2];
> >     ViaPMState pm;
> > +    PCIDevice ac97;
> > +    PCIDevice mc97;
> > };
> >
> > static const VMStateDescription vmstate_via = {
> > @@ -568,6 +570,8 @@ static void via_isa_init(Object *obj)
> >     object_initialize_child(obj, "ide", &s->ide, "via-ide");
> >     object_initialize_child(obj, "uhci1", &s->uhci[0],
> "vt82c686b-usb-uhci");
> >     object_initialize_child(obj, "uhci2", &s->uhci[1],
> "vt82c686b-usb-uhci");
> > +    object_initialize_child(obj, "ac97", &s->ac97, TYPE_VIA_AC97);
> > +    object_initialize_child(obj, "mc97", &s->mc97, TYPE_VIA_MC97);
> > }
> >
> > static const TypeInfo via_isa_info = {
> > @@ -644,6 +648,18 @@ static void via_isa_realize(PCIDevice *d, Error
> **errp)
> >     if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) {
> >         return;
> >     }
> > +
> > +    /* Function 5: AC97 Audio */
> > +    qdev_prop_set_int32(DEVICE(&s->ac97), "addr", d->devfn + 5);
> > +    if (!qdev_realize(DEVICE(&s->ac97), BUS(pci_bus), errp)) {
> > +        return;
> > +    }
> > +
> > +    /* Function 6: AC97 Modem */
> > +    qdev_prop_set_int32(DEVICE(&s->mc97), "addr", d->devfn + 6);
> > +    if (!qdev_realize(DEVICE(&s->mc97), BUS(pci_bus), errp)) {
> > +        return;
> > +    }
> > }
> >
> > /* TYPE_VT82C686B_ISA */
> > diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
> > index f05474348f..ea1aef3049 100644
> > --- a/hw/mips/fuloong2e.c
> > +++ b/hw/mips/fuloong2e.c
> > @@ -207,10 +207,6 @@ static void vt82c686b_southbridge_init(PCIBus
> *pci_bus, int slot, qemu_irq intc,
> >
> >     dev = PCI_DEVICE(object_resolve_path_component(OBJECT(dev), "pm"));
> >     *i2c_bus = I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c"));
> > -
> > -    /* Audio support */
> > -    pci_create_simple(pci_bus, PCI_DEVFN(slot, 5), TYPE_VIA_AC97);
> > -    pci_create_simple(pci_bus, PCI_DEVFN(slot, 6), TYPE_VIA_MC97);
> > }
> >
> > /* Network support */
> > diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c
> > index 4e29e42fba..89ef4aed8b 100644
> > --- a/hw/ppc/pegasos2.c
> > +++ b/hw/ppc/pegasos2.c
> > @@ -171,10 +171,6 @@ static void pegasos2_init(MachineState *machine)
> >     spd_data = spd_data_generate(DDR, machine->ram_size);
> >     smbus_eeprom_init_one(i2c_bus, 0x57, spd_data);
> >
> > -    /* VT8231 function 5-6: AC97 Audio & Modem */
> > -    pci_create_simple(pci_bus, PCI_DEVFN(12, 5), TYPE_VIA_AC97);
> > -    pci_create_simple(pci_bus, PCI_DEVFN(12, 6), TYPE_VIA_MC97);
> > -
>
> This removes the last function created here so the comment above saying:
> /* VT8231 function 0: PCI-to-ISA Bridge */
> is now stale and may be removed as well.
>

Sure, I'll remove it in v2. What about the comment saying:
/* VT8231 function 4: Power Management Controller */
?

Thanks,
Bernhard

>
> Regards,
> BALATON Zoltan
>
> >     /* other PC hardware */
> >     pci_vga_init(pci_bus);
> >
> >
>

Reply via email to