[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 13/23] hw/isa/piix4: Make PIIX4's ACPI and USB functions optio
From: |
Bernhard Beschow |
Subject: |
[PATCH v8 13/23] hw/isa/piix4: Make PIIX4's ACPI and USB functions optional |
Date: |
Thu, 2 Mar 2023 22:21:51 +0100 |
This aligns PIIX4 with PIIX3.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20221022150508.26830-30-shentey@gmail.com>
---
hw/isa/piix4.c | 44 ++++++++++++++++++++++++++++++++------------
hw/mips/malta.c | 6 ++++--
2 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index e0b149f8eb..c13f68733b 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -51,9 +51,16 @@ struct PIIX4State {
PCIIDEState ide;
UHCIState uhci;
PIIX4PMState pm;
+
+ uint32_t smb_io_base;
+
/* Reset Control Register */
MemoryRegion rcr_mem;
uint8_t rcr;
+
+ bool has_acpi;
+ bool has_usb;
+ bool smm_enabled;
};
OBJECT_DECLARE_SIMPLE_TYPE(PIIX4State, PIIX4_PCI_DEVICE)
@@ -234,17 +241,26 @@ static void piix4_realize(PCIDevice *dev, Error **errp)
}
/* USB */
- qdev_prop_set_int32(DEVICE(&s->uhci), "addr", dev->devfn + 2);
- if (!qdev_realize(DEVICE(&s->uhci), BUS(pci_bus), errp)) {
- return;
+ if (s->has_usb) {
+ object_initialize_child(OBJECT(dev), "uhci", &s->uhci,
+ TYPE_PIIX4_USB_UHCI);
+ qdev_prop_set_int32(DEVICE(&s->uhci), "addr", dev->devfn + 2);
+ if (!qdev_realize(DEVICE(&s->uhci), BUS(pci_bus), errp)) {
+ return;
+ }
}
/* ACPI controller */
- qdev_prop_set_int32(DEVICE(&s->pm), "addr", dev->devfn + 3);
- if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) {
- return;
+ if (s->has_acpi) {
+ object_initialize_child(OBJECT(s), "pm", &s->pm, TYPE_PIIX4_PM);
+ qdev_prop_set_int32(DEVICE(&s->pm), "addr", dev->devfn + 3);
+ qdev_prop_set_uint32(DEVICE(&s->pm), "smb_io_base", s->smb_io_base);
+ qdev_prop_set_bit(DEVICE(&s->pm), "smm-enabled", s->smm_enabled);
+ if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) {
+ return;
+ }
+ qdev_connect_gpio_out(DEVICE(&s->pm), 0, s->isa[9]);
}
- qdev_connect_gpio_out(DEVICE(&s->pm), 0, s->isa[9]);
pci_bus_irqs(pci_bus, piix4_set_irq, s, PIIX_NUM_PIRQS);
}
@@ -255,13 +271,16 @@ static void piix4_init(Object *obj)
object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC);
object_initialize_child(obj, "ide", &s->ide, TYPE_PIIX4_IDE);
- object_initialize_child(obj, "uhci", &s->uhci, TYPE_PIIX4_USB_UHCI);
-
- object_initialize_child(obj, "pm", &s->pm, TYPE_PIIX4_PM);
- qdev_prop_set_uint32(DEVICE(&s->pm), "smb_io_base", 0x1100);
- qdev_prop_set_bit(DEVICE(&s->pm), "smm-enabled", 0);
}
+static Property piix4_props[] = {
+ DEFINE_PROP_UINT32("smb_io_base", PIIX4State, smb_io_base, 0),
+ DEFINE_PROP_BOOL("has-acpi", PIIX4State, has_acpi, true),
+ DEFINE_PROP_BOOL("has-usb", PIIX4State, has_usb, true),
+ DEFINE_PROP_BOOL("smm-enabled", PIIX4State, smm_enabled, false),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static void piix4_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -280,6 +299,7 @@ static void piix4_class_init(ObjectClass *klass, void *data)
*/
dc->user_creatable = false;
dc->hotpluggable = false;
+ device_class_set_props(dc, piix4_props);
}
static const TypeInfo piix4_info = {
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index ec172b111a..db5e5fd85c 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -1254,8 +1254,10 @@ void mips_malta_init(MachineState *machine)
pci_bus_map_irqs(pci_bus, malta_pci_slot_get_pirq);
/* Southbridge */
- piix4 = pci_create_simple_multifunction(pci_bus, PIIX4_PCI_DEVFN, true,
- TYPE_PIIX4_PCI_DEVICE);
+ piix4 = pci_new_multifunction(PIIX4_PCI_DEVFN, true,
+ TYPE_PIIX4_PCI_DEVICE);
+ qdev_prop_set_uint32(DEVICE(piix4), "smb_io_base", 0x1100);
+ pci_realize_and_unref(piix4, pci_bus, &error_fatal);
isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix4), "isa.0"));
dev = DEVICE(object_resolve_path_component(OBJECT(piix4), "ide"));
--
2.39.2
- [PATCH v8 06/23] hw/isa/piix3: Move ISA bus IRQ assignments into host device, (continued)
- [PATCH v8 06/23] hw/isa/piix3: Move ISA bus IRQ assignments into host device, Bernhard Beschow, 2023/03/02
- [PATCH v8 07/23] hw/isa/piix3: Create IDE controller in host device, Bernhard Beschow, 2023/03/02
- [PATCH v8 08/23] hw/isa/piix3: Wire up ACPI interrupt internally, Bernhard Beschow, 2023/03/02
- [PATCH v8 09/23] hw/isa/piix3: Resolve redundant PIIX_NUM_PIC_IRQS, Bernhard Beschow, 2023/03/02
- [PATCH v8 11/23] hw/isa/piix3: Rename piix3_reset() for sharing with PIIX4, Bernhard Beschow, 2023/03/02
- [PATCH v8 12/23] hw/isa/piix3: Drop the "3" from PIIX base class, Bernhard Beschow, 2023/03/02
- [PATCH v8 10/23] hw/isa/piix3: Rename pci_piix3_props for sharing with PIIX4, Bernhard Beschow, 2023/03/02
- [PATCH v8 14/23] hw/isa/piix4: Remove unused inbound ISA interrupt lines, Bernhard Beschow, 2023/03/02
- [PATCH v8 16/23] hw/isa/piix4: Create the "intr" property during init() already, Bernhard Beschow, 2023/03/02
- [PATCH v8 17/23] hw/isa/piix4: Rename reset control operations to match PIIX3, Bernhard Beschow, 2023/03/02
- [PATCH v8 13/23] hw/isa/piix4: Make PIIX4's ACPI and USB functions optional,
Bernhard Beschow <=
- [PATCH v8 15/23] hw/isa/piix4: Reuse struct PIIXState from PIIX3, Bernhard Beschow, 2023/03/02
- [PATCH v8 19/23] hw/isa/piix: Harmonize names of reset control memory regions, Bernhard Beschow, 2023/03/02
- [PATCH v8 18/23] hw/isa/piix3: Merge hw/isa/piix4.c, Bernhard Beschow, 2023/03/02
- [PATCH v8 21/23] hw/isa/piix: Consolidate IRQ triggering, Bernhard Beschow, 2023/03/02
- [PATCH v8 20/23] hw/isa/piix: Rename functions to be shared for interrupt triggering, Bernhard Beschow, 2023/03/02
- [PATCH v8 22/23] hw/isa/piix: Share PIIX3's base class with PIIX4, Bernhard Beschow, 2023/03/02
- [PATCH v8 23/23] hw/isa/piix: Reuse PIIX3 base class' realize method in PIIX4, Bernhard Beschow, 2023/03/02