From e6eb2853cb5a6cb48b38d894af06ee791317c75a Mon Sep 17 00:00:00 2001 From: espes Date: Sun, 9 Dec 2012 18:36:56 +1100 Subject: [PATCH] xbox: initial mcpx aci device code --- hw/i386/Makefile.objs | 2 +- hw/mcpx_aci.c | 110 ++++++++++++++++++++++++++++++++++++++++++ hw/mcpx_apu.h | 1 + hw/pci_ids.h | 1 + hw/xbox.c | 3 ++ 5 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 hw/mcpx_aci.c diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs index 50b89db1e2..665e7af4fb 100644 --- a/hw/i386/Makefile.objs +++ b/hw/i386/Makefile.objs @@ -13,6 +13,6 @@ obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_msi.o obj-y += kvm/ obj-$(CONFIG_SPICE) += qxl.o qxl-logger.o qxl-render.o -obj-$(CONFIG_XBOX) += xbox.o xbox_pci.o acpi_xbox.o amd_smbus.o nv2a.o nv2a_vsh.o mcpx_apu.o smbus_xbox_smc.o smbus_cx25871.o smbus_adm1032.o +obj-$(CONFIG_XBOX) += xbox.o xbox_pci.o acpi_xbox.o amd_smbus.o nv2a.o nv2a_vsh.o mcpx_apu.o mcpx_aci.o smbus_xbox_smc.o smbus_cx25871.o smbus_adm1032.o obj-y := $(addprefix ../,$(obj-y)) diff --git a/hw/mcpx_aci.c b/hw/mcpx_aci.c new file mode 100644 index 0000000000..d932e8babf --- /dev/null +++ b/hw/mcpx_aci.c @@ -0,0 +1,110 @@ +/* + * QEMU MCPX Audio Codec Interface implementation + * + * Copyright (c) 2012 espes + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 or + * (at your option) version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ +#include "hw.h" +#include "pc.h" +#include "pci.h" +#include "ac97_int.h" + +#include "mcpx_apu.h" + +typedef struct MCPXACIState { + PCIDevice dev; + qemu_irq irq; + + AC97LinkState ac97; + + + MemoryRegion io_nam, io_nabm; + + MemoryRegion mmio; + MemoryRegion nam_mmio, nabm_mmio; +} MCPXACIState; + + +#define MCPX_ACI_DEVICE(obj) \ + OBJECT_CHECK(MCPXACIState, (obj), "mcpx-aci") + + +static int mcpx_aci_initfn(PCIDevice *dev) +{ + MCPXACIState *d = MCPX_ACI_DEVICE(dev); + + //mmio + memory_region_init(&d->mmio, "mcpx-aci-mmio", 0x1000); + + memory_region_init_io(&d->io_nam, &ac97_io_nam_ops, &d->ac97, + "mcpx-aci-nam", 0x100); + memory_region_init_io(&d->io_nabm, &ac97_io_nabm_ops, &d->ac97, + "mcpx-aci-nabm", 0x80); + + /*pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &d->io_nam); + pci_register_bar(&d->dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &d->io_nabm); + + memory_region_init_alias(&d->nam_mmio, NULL, &d->io_nam, 0, 0x100); + memory_region_add_subregion(&d->mmio, 0x0, &d->nam_mmio); + + memory_region_init_alias(&d->nabm_mmio, NULL, &d->io_nabm, 0, 0x80); + memory_region_add_subregion(&d->mmio, 0x100, &d->nabm_mmio);*/ + + memory_region_add_subregion(&d->mmio, 0x0, &d->io_nam); + memory_region_add_subregion(&d->mmio, 0x100, &d->io_nabm); + + pci_register_bar(&d->dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &d->mmio); + + ac97_common_init(&d->ac97, d->irq, pci_dma_context(&d->dev)); + + return 0; +} + +static void mcpx_aci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + + k->vendor_id = PCI_VENDOR_ID_NVIDIA; + k->device_id = PCI_DEVICE_ID_NVIDIA_MCPX_ACI; + k->revision = 210; + k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO; + k->init = mcpx_aci_initfn; + + dc->desc = "MCPX Audio Codec Interface"; +} + +static const TypeInfo mcpx_aci_info = { + .name = "mcpx-aci", + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(MCPXACIState), + .class_init = mcpx_aci_class_init, +}; + +static void mcpx_aci_register(void) +{ + type_register_static(&mcpx_aci_info); +} +type_init(mcpx_aci_register); + + +void mcpx_aci_init(PCIBus *bus, int devfn, qemu_irq irq) +{ + PCIDevice *dev; + MCPXACIState *d; + dev = pci_create_simple(bus, devfn, "mcpx-aci"); + d = MCPX_ACI_DEVICE(dev); + d->irq = irq; +} diff --git a/hw/mcpx_apu.h b/hw/mcpx_apu.h index ca263fb21f..29e59b35d0 100644 --- a/hw/mcpx_apu.h +++ b/hw/mcpx_apu.h @@ -21,5 +21,6 @@ #define HW_MCPX_APU_H void mcpx_apu_init(PCIBus *bus, int devfn, qemu_irq irq); +void mcpx_aci_init(PCIBus *bus, int devfn, qemu_irq irq); #endif \ No newline at end of file diff --git a/hw/pci_ids.h b/hw/pci_ids.h index 9c15f094cf..8252e39180 100644 --- a/hw/pci_ids.h +++ b/hw/pci_ids.h @@ -149,6 +149,7 @@ #define PCI_VENDOR_ID_NVIDIA 0x10de #define PCI_DEVICE_ID_NVIDIA_MCPX_APU 0x01b0 +#define PCI_DEVICE_ID_NVIDIA_MCPX_ACI 0x01b1 #define PCI_DEVICE_ID_NVIDIA_NFORCE_LPC 0x01b2 #define PCI_DEVICE_ID_NVIDIA_NFORCE_SMBUS 0x01b4 #define PCI_DEVICE_ID_NVIDIA_NFORCE_AGP 0x01b7 diff --git a/hw/xbox.c b/hw/xbox.c index 28c788ca26..17c4e032cd 100644 --- a/hw/xbox.c +++ b/hw/xbox.c @@ -288,6 +288,9 @@ static void xbox_init(QEMUMachineInitArgs *args) /* APU! */ mcpx_apu_init(host_bus, PCI_DEVFN(5, 0), gsi[5]); + /* ACI! */ + mcpx_aci_init(host_bus, PCI_DEVFN(6, 0), gsi[6]); + /* GPU! */ nv2a_init(agp_bus, PCI_DEVFN(0, 0), gsi[3]); }