From: Alexander Graf <agraf@suse.de>
To: qemu-ppc@nongnu.org
Cc: Blue Swirl <blauwirbel@gmail.com>,
qemu-devel Developers <qemu-devel@nongnu.org>,
Aurelien Jarno <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH 10/26] PPC: 4xx: Qdevify the 440 PCI host controller
Date: Sat, 21 Jan 2012 05:18:55 +0100 [thread overview]
Message-ID: <1327119551-29674-11-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1327119551-29674-1-git-send-email-agraf@suse.de>
Due to popular demand, this qdevifies the PCI host controller of 4xx SoCs
the same way as e500.
We have to introduce a small stub function for pci init that will be
removed in a later patch, once we qdev'ified the board, to keep the build
working.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
hw/ppc440_bamboo.c | 9 ++++
hw/ppc4xx_pci.c | 125 +++++++++++++++++++++++++++-------------------------
2 files changed, 74 insertions(+), 60 deletions(-)
diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c
index 2369fba..124e7d7 100644
--- a/hw/ppc440_bamboo.c
+++ b/hw/ppc440_bamboo.c
@@ -34,6 +34,15 @@
static target_phys_addr_t entry;
+static PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],
+ target_phys_addr_t config_space,
+ target_phys_addr_t int_ack,
+ target_phys_addr_t special_cycle,
+ target_phys_addr_t registers)
+{
+ return NULL;
+}
+
static int bamboo_load_device_tree(target_phys_addr_t addr,
uint32_t ramsize,
target_phys_addr_t initrd_base,
diff --git a/hw/ppc4xx_pci.c b/hw/ppc4xx_pci.c
index 1bf785b..26de007 100644
--- a/hw/ppc4xx_pci.c
+++ b/hw/ppc4xx_pci.c
@@ -49,13 +49,14 @@ struct PCITargetMap {
#define PPC4xx_PCI_NR_PTMS 2
struct PPC4xxPCIState {
+ PCIHostState pci_state;
+
struct PCIMasterMap pmm[PPC4xx_PCI_NR_PMMS];
struct PCITargetMap ptm[PPC4xx_PCI_NR_PTMS];
+ qemu_irq irq[4];
- PCIHostState pci_state;
- PCIDevice *pci_dev;
- MemoryRegion iomem_addr;
- MemoryRegion iomem_regs;
+ MemoryRegion container;
+ MemoryRegion iomem;
};
typedef struct PPC4xxPCIState PPC4xxPCIState;
@@ -83,8 +84,10 @@ typedef struct PPC4xxPCIState PPC4xxPCIState;
#define PCIL0_PTM1LA 0x34
#define PCIL0_PTM2MS 0x38
#define PCIL0_PTM2LA 0x3c
+#define PCI_REG_BASE 0x800000
#define PCI_REG_SIZE 0x40
+#define PCI_ALL_SIZE (PCI_REG_BASE + PCI_REG_SIZE)
static uint64_t pci4xx_cfgaddr_read(void *opaque, target_phys_addr_t addr,
unsigned size)
@@ -314,7 +317,6 @@ static const VMStateDescription vmstate_ppc4xx_pci = {
.minimum_version_id = 1,
.minimum_version_id_old = 1,
.fields = (VMStateField[]) {
- VMSTATE_PCI_DEVICE_POINTER(pci_dev, PPC4xxPCIState),
VMSTATE_STRUCT_ARRAY(pmm, PPC4xxPCIState, PPC4xx_PCI_NR_PMMS, 1,
vmstate_pci_master_map,
struct PCIMasterMap),
@@ -326,60 +328,63 @@ static const VMStateDescription vmstate_ppc4xx_pci = {
};
/* XXX Interrupt acknowledge cycles not supported. */
-PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],
- target_phys_addr_t config_space,
- target_phys_addr_t int_ack,
- target_phys_addr_t special_cycle,
- target_phys_addr_t registers)
+static int ppc4xx_pcihost_initfn(SysBusDevice *dev)
+{
+ PPC4xxPCIState *s;
+ PCIHostState *h;
+ PCIBus *b;
+ int i;
+
+ h = FROM_SYSBUS(PCIHostState, sysbus_from_qdev(dev));
+ s = DO_UPCAST(PPC4xxPCIState, pci_state, h);
+
+ for (i = 0; i < ARRAY_SIZE(s->irq); i++) {
+ sysbus_init_irq(dev, &s->irq[i]);
+ }
+
+ b = pci_register_bus(&s->pci_state.busdev.qdev, NULL, ppc4xx_pci_set_irq,
+ ppc4xx_pci_map_irq, s->irq, get_system_memory(),
+ get_system_io(), 0, 4);
+ s->pci_state.bus = b;
+
+ pci_create_simple(b, 0, "ppc4xx-host-bridge");
+
+ /* XXX split into 2 memory regions, one for config space, one for regs */
+ memory_region_init(&s->container, "pci-container", PCI_ALL_SIZE);
+ memory_region_init_io(&h->conf_mem, &pci_host_conf_le_ops, h,
+ "pci-conf-idx", 4);
+ memory_region_init_io(&h->data_mem, &pci_host_data_le_ops, h,
+ "pci-conf-data", 4);
+ memory_region_init_io(&s->iomem, &pci_reg_ops, s,
+ "pci.reg", PCI_REG_SIZE);
+ memory_region_add_subregion(&s->container, PCIC0_CFGADDR, &h->conf_mem);
+ memory_region_add_subregion(&s->container, PCIC0_CFGDATA, &h->data_mem);
+ memory_region_add_subregion(&s->container, PCI_REG_BASE, &s->iomem);
+ sysbus_init_mmio(dev, &s->container);
+ qemu_register_reset(ppc4xx_pci_reset, s);
+
+ return 0;
+}
+
+static PCIDeviceInfo ppc4xx_host_bridge_info = {
+ .qdev.name = "ppc4xx-host-bridge",
+ .qdev.desc = "Host bridge",
+ .qdev.size = sizeof(PCIDevice),
+ .vendor_id = PCI_VENDOR_ID_IBM,
+ .device_id = PCI_DEVICE_ID_IBM_440GX,
+ .class_id = PCI_CLASS_BRIDGE_OTHER,
+};
+
+static SysBusDeviceInfo ppc4xx_pcihost_info = {
+ .init = ppc4xx_pcihost_initfn,
+ .qdev.name = "ppc4xx-pcihost",
+ .qdev.size = sizeof(PPC4xxPCIState),
+ .qdev.vmsd = &vmstate_ppc4xx_pci,
+};
+
+static void ppc4xx_pci_register(void)
{
- PPC4xxPCIState *controller;
- static int ppc4xx_pci_id;
- uint8_t *pci_conf;
-
- controller = g_malloc0(sizeof(PPC4xxPCIState));
-
- controller->pci_state.bus = pci_register_bus(NULL, "pci",
- ppc4xx_pci_set_irq,
- ppc4xx_pci_map_irq,
- pci_irqs,
- get_system_memory(),
- get_system_io(),
- 0, 4);
-
- controller->pci_dev = pci_register_device(controller->pci_state.bus,
- "host bridge", sizeof(PCIDevice),
- 0, NULL, NULL);
- pci_conf = controller->pci_dev->config;
- pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_IBM);
- pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_IBM_440GX);
- pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_OTHER);
-
- /* CFGADDR */
- memory_region_init_io(&controller->iomem_addr, &pci4xx_cfgaddr_ops,
- controller, "pci.cfgaddr", 4);
- memory_region_add_subregion(get_system_memory(),
- config_space + PCIC0_CFGADDR,
- &controller->iomem_addr);
-
- /* CFGDATA */
- memory_region_init_io(&controller->pci_state.data_mem,
- &pci_host_data_be_ops,
- &controller->pci_state, "pci-conf-data", 4);
- memory_region_add_subregion(get_system_memory(),
- config_space + PCIC0_CFGDATA,
- &controller->pci_state.data_mem);
-
- /* Internal registers */
- memory_region_init_io(&controller->iomem_regs, &pci_reg_ops, controller,
- "pci.regs", PCI_REG_SIZE);
- memory_region_add_subregion(get_system_memory(), registers,
- &controller->iomem_regs);
-
- qemu_register_reset(ppc4xx_pci_reset, controller);
-
- /* XXX load/save code not tested. */
- vmstate_register(&controller->pci_dev->qdev, ppc4xx_pci_id++,
- &vmstate_ppc4xx_pci, controller);
-
- return controller->pci_state.bus;
+ sysbus_register_withprop(&ppc4xx_pcihost_info);
+ pci_qdev_register(&ppc4xx_host_bridge_info);
}
+device_init(ppc4xx_pci_register);
--
1.6.0.2
next prev parent reply other threads:[~2012-01-21 4:19 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-21 4:18 [Qemu-devel] [PULL 00/26] ppc patch queue 2012-01-21 Alexander Graf
2012-01-21 4:18 ` [Qemu-devel] [PATCH 01/26] PPC: 440EP: Initialize timer Alexander Graf
2012-01-21 4:18 ` [Qemu-devel] [PATCH 02/26] PPC: Bamboo: Register CPU reset Alexander Graf
2012-01-21 4:18 ` [Qemu-devel] [PATCH 03/26] PPC: Bamboo: Set initial TLB entry Alexander Graf
2012-01-21 4:18 ` [Qemu-devel] [PATCH 04/26] PPC: 440: Ignore invalid PCI IRQs Alexander Graf
2012-01-21 4:18 ` [Qemu-devel] [PATCH 05/26] PPC: Bamboo: recompile device tree Alexander Graf
2012-01-21 4:18 ` [Qemu-devel] [PATCH 06/26] PPC: 440: Default to 440EP CPU Alexander Graf
2012-01-21 4:18 ` [Qemu-devel] [PATCH 07/26] PPC: Enable 440EP CPU target Alexander Graf
2012-01-21 4:18 ` [Qemu-devel] [PATCH 08/26] PPC: bamboo: remove old machine descriptions Alexander Graf
2012-01-21 4:18 ` [Qemu-devel] [PATCH 09/26] PPC: bamboo: fix whitespace Alexander Graf
2012-01-21 4:18 ` Alexander Graf [this message]
2012-01-21 4:18 ` [Qemu-devel] [PATCH 11/26] PPC: Bamboo: fold ppc440.c and ppc440_bamboo.c into a single file Alexander Graf
2012-01-21 4:18 ` [Qemu-devel] [PATCH 12/26] PPC: Bamboo: Integrate SoC instatiation, use qdev for PCI Alexander Graf
2012-01-21 4:18 ` [Qemu-devel] [PATCH 13/26] virtio-pci: Fix endianness of virtio config Alexander Graf
2012-01-21 4:18 ` [Qemu-devel] [PATCH 14/26] virtio: change memcpy to guest reads Alexander Graf
2012-01-21 4:19 ` [Qemu-devel] [PATCH 15/26] load_image_targphys() should enforce the max size Alexander Graf
2012-01-21 4:19 ` [Qemu-devel] [PATCH 16/26] Fix dirty logging with 32-bit qemu & 64-bit guests Alexander Graf
2012-01-21 4:19 ` [Qemu-devel] [PATCH 17/26] Update gitignore file Alexander Graf
2012-01-21 4:19 ` [Qemu-devel] [PATCH 18/26] Correct types in bmdma_addr_{read, write} Alexander Graf
2012-01-21 4:19 ` [Qemu-devel] [PATCH 19/26] pseries: Support PCI extended config space in RTAS calls Alexander Graf
2012-01-21 4:19 ` [Qemu-devel] [PATCH 20/26] pseries: Use correct dispatcher for PCI config space accesses Alexander Graf
2012-01-21 4:19 ` [Qemu-devel] [PATCH 21/26] pseries: SLOF PCI flag day Alexander Graf
2012-01-21 4:19 ` [Qemu-devel] [PATCH 22/26] MAINTAINERS: Add qemu-ppc to all ppc target stuff Alexander Graf
2012-01-21 7:22 ` Andreas Färber
2012-01-21 4:19 ` [Qemu-devel] [PATCH 23/26] MAINTAINERS: Add PCI host bridge files to CHRP machines Alexander Graf
2012-01-21 4:19 ` [Qemu-devel] [PATCH 24/26] PPC: Pseries: Check for PCI boundaries Alexander Graf
2012-01-21 4:19 ` [Qemu-devel] [PATCH 25/26] MAINTAINERS: Add PCI-PCI bridge to New World Mac machine Alexander Graf
2012-01-21 4:19 ` [Qemu-devel] [PATCH 26/26] grackle_pci: Clean up qdev names Alexander Graf
2012-01-21 20:02 ` [Qemu-devel] [PULL 00/26] ppc patch queue 2012-01-21 Blue Swirl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1327119551-29674-11-git-send-email-agraf@suse.de \
--to=agraf@suse.de \
--cc=aurelien@aurel32.net \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).