@@ -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 = {
@@ -1449,8 +1449,10 @@ void mips_malta_init(MachineState *machine)
empty_slot_init("GT64120", 0, 0x20000000);
/* 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"));