hw/usb: Extract VT82C686 UHCI PCI function into a new unit

Extract the VT82C686 PCI UHCI function into a new unit so
it is only build when the VT82C686 south bridge is selected.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20210309190802.830969-4-f4bug@amsat.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2021-03-09 20:08:02 +01:00 committed by Gerd Hoffmann
parent 9a4e12a64d
commit 6f2bcd5fc8
4 changed files with 45 additions and 23 deletions

View File

@ -1180,6 +1180,7 @@ S: Odd Fixes
F: hw/mips/fuloong2e.c
F: hw/isa/vt82c686.c
F: hw/pci-host/bonito.c
F: hw/usb/vt82c686-uhci-pci.c
F: include/hw/isa/vt82c686.h
Loongson-3 virtual platforms

View File

@ -1207,21 +1207,6 @@ void usb_uhci_common_realize(PCIDevice *dev, Error **errp)
pci_register_bar(&s->dev, 4, PCI_BASE_ADDRESS_SPACE_IO, &s->io_bar);
}
static void usb_uhci_vt82c686b_realize(PCIDevice *dev, Error **errp)
{
UHCIState *s = UHCI(dev);
uint8_t *pci_conf = s->dev.config;
/* USB misc control 1/2 */
pci_set_long(pci_conf + 0x40,0x00001000);
/* PM capability */
pci_set_long(pci_conf + 0x80,0x00020001);
/* USB legacy support */
pci_set_long(pci_conf + 0xc0,0x00002000);
usb_uhci_common_realize(dev, errp);
}
static void usb_uhci_exit(PCIDevice *dev)
{
UHCIState *s = UHCI(dev);
@ -1318,14 +1303,6 @@ static UHCIInfo uhci_info[] = {
.revision = 0x01,
.irq_pin = 3,
.unplug = true,
},{
.name = "vt82c686b-usb-uhci",
.vendor_id = PCI_VENDOR_ID_VIA,
.device_id = PCI_DEVICE_ID_VIA_UHCI,
.revision = 0x01,
.irq_pin = 3,
.realize = usb_uhci_vt82c686b_realize,
.unplug = true,
},{
.name = "ich9-usb-uhci1", /* 00:1d.0 */
.vendor_id = PCI_VENDOR_ID_INTEL,

View File

@ -32,6 +32,7 @@ softmmu_ss.add(when: 'CONFIG_USB_DWC3', if_true: files('hcd-dwc3.c'))
softmmu_ss.add(when: 'CONFIG_TUSB6010', if_true: files('tusb6010.c'))
softmmu_ss.add(when: 'CONFIG_IMX', if_true: files('chipidea.c'))
softmmu_ss.add(when: 'CONFIG_IMX_USBPHY', if_true: files('imx-usb-phy.c'))
softmmu_ss.add(when: 'CONFIG_VT82C686', if_true: files('vt82c686-uhci-pci.c'))
specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-usb2-ctrl-regs.c'))
specific_ss.add(when: 'CONFIG_XLNX_USB_SUBSYS', if_true: files('xlnx-usb-subsystem.c'))

View File

@ -0,0 +1,43 @@
#include "qemu/osdep.h"
#include "hcd-uhci.h"
static void usb_uhci_vt82c686b_realize(PCIDevice *dev, Error **errp)
{
UHCIState *s = UHCI(dev);
uint8_t *pci_conf = s->dev.config;
/* USB misc control 1/2 */
pci_set_long(pci_conf + 0x40, 0x00001000);
/* PM capability */
pci_set_long(pci_conf + 0x80, 0x00020001);
/* USB legacy support */
pci_set_long(pci_conf + 0xc0, 0x00002000);
usb_uhci_common_realize(dev, errp);
}
static UHCIInfo uhci_info[] = {
{
.name = "vt82c686b-usb-uhci",
.vendor_id = PCI_VENDOR_ID_VIA,
.device_id = PCI_DEVICE_ID_VIA_UHCI,
.revision = 0x01,
.irq_pin = 3,
.realize = usb_uhci_vt82c686b_realize,
.unplug = true,
}
};
static const TypeInfo vt82c686b_usb_uhci_type_info = {
.parent = TYPE_UHCI,
.name = "vt82c686b-usb-uhci",
.class_init = uhci_data_class_init,
.class_data = uhci_info,
};
static void vt82c686b_usb_uhci_register_types(void)
{
type_register_static(&vt82c686b_usb_uhci_type_info);
}
type_init(vt82c686b_usb_uhci_register_types)