From nobody Sat Feb 7 05:52:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.42 as permitted sender) client-ip=209.85.221.42; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f42.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.42 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1616608528; cv=none; d=zohomail.com; s=zohoarc; b=BT9kGTyzeUMBjX4QVL9oO2qv/p3tKo+FyOj8RsPZbqYssubqvX7pVaAye0GVm/QMx1/25PrxqlOkHNZNWKDyjgmSU7eVR2yuDCbYzS5DPCMn+Wir5hpN0Da3HG54rSHkToZOOZHpVProz+5TF3+9M6cfOnoyxIqXIQv0YxglUoI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616608528; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=33tIPVTTy4w3TP0mdRFjmaEZnocP/TEDVOP38fCjKBg=; b=XfESqxN4mV/NKfz0/B45sS7w5rzahR9wGxctCLZQjNgrSofBG+ILw2hqHKrYXyPenxatBxshV70G9oLiw+GCx+vqOCROm/2AeO7JLrc2hsB9tSCRx0SMwJ39mBtOjRPviYAMKGv7FkFjCYXMqcAI/W9e4SV1scSXbIZF0rtNjYg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.42 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mx.zohomail.com with SMTPS id 1616608528786480.9496758359029; Wed, 24 Mar 2021 10:55:28 -0700 (PDT) Received: by mail-wr1-f42.google.com with SMTP id x13so25338210wrs.9 for ; Wed, 24 Mar 2021 10:55:27 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id 12sm3156632wmw.43.2021.03.24.10.55.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 10:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=33tIPVTTy4w3TP0mdRFjmaEZnocP/TEDVOP38fCjKBg=; b=Vf+xioGAtyAAFH6MTZNUrzcJeMEDwQMCrQU71OTQAGH0XSk0MASnvuQdedyl2ODOLv p0F09a/Et3HuMRrDpKqRwNvU0VlaEkPH4QP5v/6d3XqlRBMoeaZHZ6HJGj6vBlGNFxMB f3xM/QJWTJqr/dzwtD6/yUtzD+UBPRwmRmzsnkGILx0DaMlMzDVmgVoef9LE0uMcSS1D H9RWIsOKvxhiAzgZQdYI1stRuia0ucY96fsmOP7EngnTPj2TRdQuiwOUsH08Yd46aclC 2VKr2LpbStVN6dDeRfxhHWnjEupPUtqdfNsuv5eEhSzxanEGzw6lfiCdA9ymdxfY/qgG NuqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=33tIPVTTy4w3TP0mdRFjmaEZnocP/TEDVOP38fCjKBg=; b=j7us1YcErD+KVdTUHSyRghfH3jHmtoqglj5XwkLGH0yFN14YO9LcWyKAwdD5lCNDK0 +p2E9rBjWklPoOiQRIikEiWa1nylHdRHU4M2N0he/Ibojo1+irPyFuB5Vn18rWEZCIkb ugAA6RtPVwpVOglXeM1nZWkVJpjYX5vCfM/5tLFlG0e3BcWaZPWB6HSeUKj8wZsGucC+ bPokxXrVIJF3uJ9n+EaF/9NkK2Bbj5Q3dSYwJwQS2o93lOyIYh9VBHQ2dzwAePWZQSoP pABUxQUKrcuGIV8mQW0x6JzJvQ9rYLAY2vYsrlun535CP6weFTXGlOVl6r8jNVP8ThCS ZHhw== X-Gm-Message-State: AOAM532/rt/8ExRGewN9hXSa2YJDKZMuITZepoInS6DbZGnZfvFrCVDu 5WnUq6xPj20WkBJHzMx8lG8= X-Google-Smtp-Source: ABdhPJzxS8R48h7V6wmk/hb0PvH7C/tSc4VPjUgacpbeKVbqvdFf03g3kcWMR2O5PuFvosjZH0wVFA== X-Received: by 2002:a5d:42ca:: with SMTP id t10mr4743750wrr.274.1616608525921; Wed, 24 Mar 2021 10:55:25 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: BALATON Zoltan , Jiaxun Yang , John Snow , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Aleksandar Rikalo , Huacai Chen , Aurelien Jarno Subject: [PATCH 6/6] hw/southbridge/vt82c686: Introduce VT82C686B_SOUTHBRIDGE Date: Wed, 24 Mar 2021 18:54:38 +0100 Message-Id: <20210324175438.680310-7-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210324175438.680310-1-f4bug@amsat.org> References: <20210324175438.680310-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The VT82C686B south bridge is a single chipset. Model it as a single sysbus device. Move the vt82c686b_southbridge_init as via_southbridge_realize, add the QOM state: ViaSouthBridgeState. This device needs 2 properties to be realized: the PCI bus and its slot number. 2 aliases are exposed: the ISA PIC output IRQ and the I2C bus. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/fuloong2e.c | 42 +++------------ hw/southbridge/vt82c686.c | 107 +++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + hw/Kconfig | 1 + hw/isa/Kconfig | 8 --- hw/meson.build | 1 + hw/southbridge/Kconfig | 7 +++ hw/southbridge/meson.build | 1 + 8 files changed, 126 insertions(+), 42 deletions(-) create mode 100644 hw/southbridge/vt82c686.c create mode 100644 hw/southbridge/Kconfig create mode 100644 hw/southbridge/meson.build diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index f1c5db13b78..01f5ef89339 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -35,10 +35,8 @@ #include "hw/pci/pci.h" #include "qemu/log.h" #include "hw/loader.h" -#include "hw/ide/pci.h" #include "hw/qdev-properties.h" #include "elf.h" -#include "hw/isa/vt82c686.h" #include "exec/address-spaces.h" #include "sysemu/qtest.h" #include "sysemu/reset.h" @@ -199,36 +197,6 @@ static void main_cpu_reset(void *opaque) } } =20 -static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq= intc, - I2CBus **i2c_bus) -{ - PCIDevice *dev; - DeviceState *isa; - - dev =3D pci_create_simple_multifunction(pci_bus, PCI_DEVFN(slot, 0), t= rue, - TYPE_VT82C686B_ISA); - isa =3D DEVICE(dev); - qdev_connect_gpio_out_named(isa, "intr", 0, intc); - - dev =3D pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide"); - for (unsigned i =3D 0; i < 2; i++) { - qdev_connect_gpio_out_named(DEVICE(dev), "ide-irq", i, - qdev_get_gpio_in_named(isa, - "isa-irq", 14 += i)); - } - pci_ide_create_devs(dev); - - pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), "vt82c686b-usb-uhci"); - pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), "vt82c686b-usb-uhci"); - - dev =3D pci_create_simple(pci_bus, PCI_DEVFN(slot, 4), TYPE_VT82C686B_= PM); - *i2c_bus =3D 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 */ static void network_init(PCIBus *pci_bus) { @@ -325,8 +293,14 @@ static void mips_fuloong2e_init(MachineState *machine) pci_bus =3D bonito_init((qemu_irq *)&(env->irq[2])); =20 /* South bridge -> IP5 */ - vt82c686b_southbridge_init(pci_bus, FULOONG2E_VIA_SLOT, env->irq[5], - &smbus); + dev =3D qdev_new("vt82c686b-southbridge"); + object_property_set_uint(OBJECT(dev), "pci-slot", + FULOONG2E_VIA_SLOT, &error_fatal); + object_property_set_link(OBJECT(dev), "pci-bus", + OBJECT(pci_bus), &error_fatal); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + qdev_connect_gpio_out_named(dev, "intr", 0, env->irq[5]); + smbus =3D I2C_BUS(qdev_get_child_bus(dev, "i2c")); =20 /* GPU */ if (vga_interface_type !=3D VGA_NONE) { diff --git a/hw/southbridge/vt82c686.c b/hw/southbridge/vt82c686.c new file mode 100644 index 00000000000..61c3e6ae306 --- /dev/null +++ b/hw/southbridge/vt82c686.c @@ -0,0 +1,107 @@ +/* + * VT82C686B south bridge emulation + * + * Copyright (c) 2008 yajin (yajin@vm-kernel.org) + * Copyright (c) 2009 chenming (chenming@rdc.faw.com.cn) + * Copyright (c) 2010 Huacai Chen (zltjiangshi@gmail.com) + * Copyright (c) 2021 Philippe Mathieu-Daud=C3=A9 + * This code is licensed under the GNU GPL v2. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/sysbus.h" +#include "hw/pci/pci.h" +#include "hw/ide/pci.h" +#include "hw/isa/vt82c686.h" + +#define TYPE_VT82C686B_SOUTHBRIDGE "vt82c686b-southbridge" +OBJECT_DECLARE_SIMPLE_TYPE(ViaSouthBridgeState, VT82C686B_SOUTHBRIDGE) + +struct ViaSouthBridgeState { + /* */ + SysBusDevice parent_obj; + /* */ + + uint8_t pci_slot; + PCIBus *pci_bus; + PCIDevice *isa; + PCIDevice *ide; + PCIDevice *usb[2]; + PCIDevice *apm; + PCIDevice *audio; + PCIDevice *modem; +}; + +static void via_southbridge_realize(DeviceState *dev, Error **errp) +{ + ViaSouthBridgeState *s =3D VT82C686B_SOUTHBRIDGE(dev); + + if (!s->pci_bus) { + error_setg(errp, "SMMU is not attached to any PCI bus!"); + return; + } + + s->isa =3D pci_create_simple_multifunction(s->pci_bus, + PCI_DEVFN(s->pci_slot, 0), + true, TYPE_VT82C686B_ISA); + qdev_pass_gpios(DEVICE(s->isa), dev, "intr"); + + s->ide =3D pci_create_simple(s->pci_bus, + PCI_DEVFN(s->pci_slot, 1), "via-ide"); + for (unsigned i =3D 0; i < 2; i++) { + qdev_connect_gpio_out_named(DEVICE(s->ide), "ide-irq", i, + qdev_get_gpio_in_named(DEVICE(s->isa), + "isa-irq", 14 + i)); + } + pci_ide_create_devs(s->ide); + + s->usb[0] =3D pci_create_simple(s->pci_bus, + PCI_DEVFN(s->pci_slot, 2), + "vt82c686b-usb-uhci"); + s->usb[1] =3D pci_create_simple(s->pci_bus, + PCI_DEVFN(s->pci_slot, 3), + "vt82c686b-usb-uhci"); + + s->apm =3D pci_create_simple(s->pci_bus, + PCI_DEVFN(s->pci_slot, 4), + TYPE_VT82C686B_PM); + object_property_add_alias(OBJECT(s), "i2c", + OBJECT(s->apm), "i2c"); + + s->audio =3D pci_create_simple(s->pci_bus, + PCI_DEVFN(s->pci_slot, 5), + TYPE_VIA_AC97); + s->modem =3D pci_create_simple(s->pci_bus, + PCI_DEVFN(s->pci_slot, 6), + TYPE_VIA_MC97); +} + +static Property via_southbridge_properties[] =3D { + DEFINE_PROP_UINT8("pci-slot", ViaSouthBridgeState, pci_slot, 0), + DEFINE_PROP_LINK("pci-bus", ViaSouthBridgeState, pci_bus, "PCI", PCIBu= s *), + DEFINE_PROP_END_OF_LIST(), +}; + +static void via_southbridge_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->realize =3D via_southbridge_realize; + device_class_set_props(dc, via_southbridge_properties); +} + +static const TypeInfo via_southbridge_info =3D { + .name =3D TYPE_VT82C686B_SOUTHBRIDGE, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(ViaSouthBridgeState), + .class_init =3D via_southbridge_class_init, +}; + +static void via_southbridge_register_types(void) +{ + type_register_static(&via_southbridge_info); +} + +type_init(via_southbridge_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index 10ed6d76240..65a0ec11c2a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1195,6 +1195,7 @@ S: Odd Fixes F: hw/mips/fuloong2e.c F: hw/isa/vt82c686.c F: hw/pci-host/bonito.c +F: hw/southbridge/vt82c686.c F: hw/usb/vt82c686-uhci-pci.c F: include/hw/isa/vt82c686.h =20 diff --git a/hw/Kconfig b/hw/Kconfig index ff40bd3f7bb..76e35ad189f 100644 --- a/hw/Kconfig +++ b/hw/Kconfig @@ -32,6 +32,7 @@ source rtc/Kconfig source scsi/Kconfig source sd/Kconfig source smbios/Kconfig +source southbridge/Kconfig source ssi/Kconfig source timer/Kconfig source tpm/Kconfig diff --git a/hw/isa/Kconfig b/hw/isa/Kconfig index 2691eae2f0c..34adc411fa6 100644 --- a/hw/isa/Kconfig +++ b/hw/isa/Kconfig @@ -41,14 +41,6 @@ config PIIX4 select ISA_BUS select USB_UHCI =20 -config VT82C686 - bool - select ISA_SUPERIO - select ACPI_SMBUS - select SERIAL_ISA - select FDC - select USB_UHCI - config SMC37C669 bool select ISA_SUPERIO diff --git a/hw/meson.build b/hw/meson.build index 8ba79b1a528..4bdd254e041 100644 --- a/hw/meson.build +++ b/hw/meson.build @@ -31,6 +31,7 @@ subdir('scsi') subdir('sd') subdir('smbios') +subdir('southbridge') subdir('ssi') subdir('timer') subdir('tpm') diff --git a/hw/southbridge/Kconfig b/hw/southbridge/Kconfig new file mode 100644 index 00000000000..356434f4e44 --- /dev/null +++ b/hw/southbridge/Kconfig @@ -0,0 +1,7 @@ +config VT82C686 + bool + select ISA_SUPERIO + select ACPI_SMBUS + select SERIAL_ISA + select FDC + select USB_UHCI diff --git a/hw/southbridge/meson.build b/hw/southbridge/meson.build new file mode 100644 index 00000000000..53b02e9563c --- /dev/null +++ b/hw/southbridge/meson.build @@ -0,0 +1 @@ +softmmu_ss.add(when: 'CONFIG_VT82C686', if_true: files('vt82c686.c')) --=20 2.26.2