| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * QEMU PowerPC E500 embedded processors pci controller emulation | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Author: Yu Liu,     <yu.liu@freescale.com> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file is derived from hw/ppc4xx_pci.c, | 
					
						
							|  |  |  |  * the copyright for that material belongs to the original owners. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This 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 of the  License, or | 
					
						
							|  |  |  |  * (at your option) any later version. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-26 18:17:15 +00:00
										 |  |  | #include "qemu/osdep.h"
 | 
					
						
							| 
									
										
										
										
											2013-02-04 15:40:22 +01:00
										 |  |  | #include "hw/hw.h"
 | 
					
						
							| 
									
										
										
										
											2012-10-10 04:28:28 +00:00
										 |  |  | #include "hw/ppc/e500-ccsr.h"
 | 
					
						
							| 
									
										
										
										
											2013-02-04 15:40:22 +01:00
										 |  |  | #include "hw/pci/pci.h"
 | 
					
						
							|  |  |  | #include "hw/pci/pci_host.h"
 | 
					
						
							| 
									
										
										
										
											2012-12-17 18:20:00 +01:00
										 |  |  | #include "qemu/bswap.h"
 | 
					
						
							| 
									
										
										
										
											2013-02-05 17:06:20 +01:00
										 |  |  | #include "hw/pci-host/ppce500.h"
 | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef DEBUG_PCI
 | 
					
						
							| 
									
										
										
										
											2009-05-13 17:53:17 +00:00
										 |  |  | #define pci_debug(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
 | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2009-05-13 17:53:17 +00:00
										 |  |  | #define pci_debug(fmt, ...)
 | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PCIE500_CFGADDR       0x0
 | 
					
						
							|  |  |  | #define PCIE500_CFGDATA       0x4
 | 
					
						
							|  |  |  | #define PCIE500_REG_BASE      0xC00
 | 
					
						
							| 
									
										
										
										
											2010-08-31 00:22:28 +02:00
										 |  |  | #define PCIE500_ALL_SIZE      0x1000
 | 
					
						
							|  |  |  | #define PCIE500_REG_SIZE      (PCIE500_ALL_SIZE - PCIE500_REG_BASE)
 | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-08 12:21:30 +02:00
										 |  |  | #define PCIE500_PCI_IOLEN     0x10000ULL
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | #define PPCE500_PCI_CONFIG_ADDR         0x0
 | 
					
						
							|  |  |  | #define PPCE500_PCI_CONFIG_DATA         0x4
 | 
					
						
							|  |  |  | #define PPCE500_PCI_INTACK              0x8
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PPCE500_PCI_OW1                 (0xC20 - PCIE500_REG_BASE)
 | 
					
						
							|  |  |  | #define PPCE500_PCI_OW2                 (0xC40 - PCIE500_REG_BASE)
 | 
					
						
							|  |  |  | #define PPCE500_PCI_OW3                 (0xC60 - PCIE500_REG_BASE)
 | 
					
						
							|  |  |  | #define PPCE500_PCI_OW4                 (0xC80 - PCIE500_REG_BASE)
 | 
					
						
							|  |  |  | #define PPCE500_PCI_IW3                 (0xDA0 - PCIE500_REG_BASE)
 | 
					
						
							|  |  |  | #define PPCE500_PCI_IW2                 (0xDC0 - PCIE500_REG_BASE)
 | 
					
						
							|  |  |  | #define PPCE500_PCI_IW1                 (0xDE0 - PCIE500_REG_BASE)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PPCE500_PCI_GASKET_TIMR         (0xE20 - PCIE500_REG_BASE)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PCI_POTAR               0x0
 | 
					
						
							|  |  |  | #define PCI_POTEAR              0x4
 | 
					
						
							|  |  |  | #define PCI_POWBAR              0x8
 | 
					
						
							|  |  |  | #define PCI_POWAR               0x10
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PCI_PITAR               0x0
 | 
					
						
							|  |  |  | #define PCI_PIWBAR              0x8
 | 
					
						
							|  |  |  | #define PCI_PIWBEAR             0xC
 | 
					
						
							|  |  |  | #define PCI_PIWAR               0x10
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PPCE500_PCI_NR_POBS     5
 | 
					
						
							|  |  |  | #define PPCE500_PCI_NR_PIBS     3
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  | #define PIWAR_EN                0x80000000      /* Enable */
 | 
					
						
							|  |  |  | #define PIWAR_PF                0x20000000      /* prefetch */
 | 
					
						
							|  |  |  | #define PIWAR_TGI_LOCAL         0x00f00000      /* target - local memory */
 | 
					
						
							|  |  |  | #define PIWAR_READ_SNOOP        0x00050000
 | 
					
						
							|  |  |  | #define PIWAR_WRITE_SNOOP       0x00005000
 | 
					
						
							|  |  |  | #define PIWAR_SZ_MASK           0x0000003f
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | struct  pci_outbound { | 
					
						
							|  |  |  |     uint32_t potar; | 
					
						
							|  |  |  |     uint32_t potear; | 
					
						
							|  |  |  |     uint32_t powbar; | 
					
						
							|  |  |  |     uint32_t powar; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |     MemoryRegion mem; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct pci_inbound { | 
					
						
							|  |  |  |     uint32_t pitar; | 
					
						
							|  |  |  |     uint32_t piwbar; | 
					
						
							|  |  |  |     uint32_t piwbear; | 
					
						
							|  |  |  |     uint32_t piwar; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |     MemoryRegion mem; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-20 19:08:03 +02:00
										 |  |  | #define TYPE_PPC_E500_PCI_HOST_BRIDGE "e500-pcihost"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PPC_E500_PCI_HOST_BRIDGE(obj) \
 | 
					
						
							|  |  |  |     OBJECT_CHECK(PPCE500PCIState, (obj), TYPE_PPC_E500_PCI_HOST_BRIDGE) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | struct PPCE500PCIState { | 
					
						
							| 
									
										
										
										
											2012-08-20 19:08:09 +02:00
										 |  |  |     PCIHostState parent_obj; | 
					
						
							| 
									
										
										
										
											2012-08-20 19:08:03 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  |     struct pci_outbound pob[PPCE500_PCI_NR_POBS]; | 
					
						
							|  |  |  |     struct pci_inbound pib[PPCE500_PCI_NR_PIBS]; | 
					
						
							|  |  |  |     uint32_t gasket_time; | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:39 +05:30
										 |  |  |     qemu_irq irq[PCI_NUM_PINS]; | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:40 +05:30
										 |  |  |     uint32_t irq_num[PCI_NUM_PINS]; | 
					
						
							| 
									
										
										
										
											2012-12-12 12:56:40 +01:00
										 |  |  |     uint32_t first_slot; | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:40 +05:30
										 |  |  |     uint32_t first_pin_irq; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |     AddressSpace bm_as; | 
					
						
							|  |  |  |     MemoryRegion bm; | 
					
						
							| 
									
										
										
										
											2010-08-31 00:22:28 +02:00
										 |  |  |     /* mmio maps */ | 
					
						
							| 
									
										
										
										
											2011-12-16 23:37:47 +01:00
										 |  |  |     MemoryRegion container; | 
					
						
							| 
									
										
										
										
											2011-11-20 11:52:58 +02:00
										 |  |  |     MemoryRegion iomem; | 
					
						
							| 
									
										
										
										
											2012-10-08 12:21:30 +02:00
										 |  |  |     MemoryRegion pio; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |     MemoryRegion busmem; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-10 04:28:28 +00:00
										 |  |  | #define TYPE_PPC_E500_PCI_BRIDGE "e500-host-bridge"
 | 
					
						
							|  |  |  | #define PPC_E500_PCI_BRIDGE(obj) \
 | 
					
						
							|  |  |  |     OBJECT_CHECK(PPCE500PCIBridgeState, (obj), TYPE_PPC_E500_PCI_BRIDGE) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct PPCE500PCIBridgeState { | 
					
						
							|  |  |  |     /*< private >*/ | 
					
						
							|  |  |  |     PCIDevice parent; | 
					
						
							|  |  |  |     /*< public >*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     MemoryRegion bar0; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct PPCE500PCIBridgeState PPCE500PCIBridgeState; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | typedef struct PPCE500PCIState PPCE500PCIState; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 12:30:10 +02:00
										 |  |  | static uint64_t pci_reg_read4(void *opaque, hwaddr addr, | 
					
						
							| 
									
										
										
										
											2011-11-20 11:52:58 +02:00
										 |  |  |                               unsigned size) | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     PPCE500PCIState *pci = opaque; | 
					
						
							|  |  |  |     unsigned long win; | 
					
						
							|  |  |  |     uint32_t value = 0; | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |     int idx; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     win = addr & 0xfe0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     switch (win) { | 
					
						
							|  |  |  |     case PPCE500_PCI_OW1: | 
					
						
							|  |  |  |     case PPCE500_PCI_OW2: | 
					
						
							|  |  |  |     case PPCE500_PCI_OW3: | 
					
						
							|  |  |  |     case PPCE500_PCI_OW4: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |         idx = (addr >> 5) & 0x7; | 
					
						
							| 
									
										
										
										
											2015-08-14 13:38:55 +02:00
										 |  |  |         switch (addr & 0x1F) { | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |         case PCI_POTAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             value = pci->pob[idx].potar; | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case PCI_POTEAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             value = pci->pob[idx].potear; | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case PCI_POWBAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             value = pci->pob[idx].powbar; | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case PCI_POWAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             value = pci->pob[idx].powar; | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case PPCE500_PCI_IW3: | 
					
						
							|  |  |  |     case PPCE500_PCI_IW2: | 
					
						
							|  |  |  |     case PPCE500_PCI_IW1: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |         idx = ((addr >> 5) & 0x3) - 1; | 
					
						
							| 
									
										
										
										
											2015-08-14 13:38:55 +02:00
										 |  |  |         switch (addr & 0x1F) { | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |         case PCI_PITAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             value = pci->pib[idx].pitar; | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case PCI_PIWBAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             value = pci->pib[idx].piwbar; | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case PCI_PIWBEAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             value = pci->pib[idx].piwbear; | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case PCI_PIWAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             value = pci->pib[idx].piwar; | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  |         }; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case PPCE500_PCI_GASKET_TIMR: | 
					
						
							|  |  |  |         value = pci->gasket_time; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-20 10:37:51 +00:00
										 |  |  |     pci_debug("%s: win:%lx(addr:" TARGET_FMT_plx ") -> value:%x\n", __func__, | 
					
						
							|  |  |  |               win, addr, value); | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  |     return value; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  | /* DMA mapping */ | 
					
						
							|  |  |  | static void e500_update_piw(PPCE500PCIState *pci, int idx) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     uint64_t tar = ((uint64_t)pci->pib[idx].pitar) << 12; | 
					
						
							|  |  |  |     uint64_t wbar = ((uint64_t)pci->pib[idx].piwbar) << 12; | 
					
						
							|  |  |  |     uint64_t war = pci->pib[idx].piwar; | 
					
						
							|  |  |  |     uint64_t size = 2ULL << (war & PIWAR_SZ_MASK); | 
					
						
							|  |  |  |     MemoryRegion *address_space_mem = get_system_memory(); | 
					
						
							|  |  |  |     MemoryRegion *mem = &pci->pib[idx].mem; | 
					
						
							|  |  |  |     MemoryRegion *bm = &pci->bm; | 
					
						
							|  |  |  |     char *name; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (memory_region_is_mapped(mem)) { | 
					
						
							|  |  |  |         /* Before we modify anything, unmap and destroy the region */ | 
					
						
							|  |  |  |         memory_region_del_subregion(bm, mem); | 
					
						
							|  |  |  |         object_unparent(OBJECT(mem)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!(war & PIWAR_EN)) { | 
					
						
							|  |  |  |         /* Not enabled, nothing to do */ | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     name = g_strdup_printf("PCI Inbound Window %d", idx); | 
					
						
							|  |  |  |     memory_region_init_alias(mem, OBJECT(pci), name, address_space_mem, tar, | 
					
						
							|  |  |  |                              size); | 
					
						
							|  |  |  |     memory_region_add_subregion_overlap(bm, wbar, mem, -1); | 
					
						
							|  |  |  |     g_free(name); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     pci_debug("%s: Added window of size=%#lx from PCI=%#lx to CPU=%#lx\n", | 
					
						
							|  |  |  |               __func__, size, wbar, tar); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* BAR mapping */ | 
					
						
							|  |  |  | static void e500_update_pow(PPCE500PCIState *pci, int idx) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     uint64_t tar = ((uint64_t)pci->pob[idx].potar) << 12; | 
					
						
							|  |  |  |     uint64_t wbar = ((uint64_t)pci->pob[idx].powbar) << 12; | 
					
						
							|  |  |  |     uint64_t war = pci->pob[idx].powar; | 
					
						
							|  |  |  |     uint64_t size = 2ULL << (war & PIWAR_SZ_MASK); | 
					
						
							|  |  |  |     MemoryRegion *mem = &pci->pob[idx].mem; | 
					
						
							|  |  |  |     MemoryRegion *address_space_mem = get_system_memory(); | 
					
						
							|  |  |  |     char *name; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (memory_region_is_mapped(mem)) { | 
					
						
							|  |  |  |         /* Before we modify anything, unmap and destroy the region */ | 
					
						
							|  |  |  |         memory_region_del_subregion(address_space_mem, mem); | 
					
						
							|  |  |  |         object_unparent(OBJECT(mem)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (!(war & PIWAR_EN)) { | 
					
						
							|  |  |  |         /* Not enabled, nothing to do */ | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     name = g_strdup_printf("PCI Outbound Window %d", idx); | 
					
						
							|  |  |  |     memory_region_init_alias(mem, OBJECT(pci), name, &pci->busmem, tar, | 
					
						
							|  |  |  |                              size); | 
					
						
							|  |  |  |     memory_region_add_subregion(address_space_mem, wbar, mem); | 
					
						
							|  |  |  |     g_free(name); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     pci_debug("%s: Added window of size=%#lx from CPU=%#lx to PCI=%#lx\n", | 
					
						
							|  |  |  |               __func__, size, wbar, tar); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-23 12:30:10 +02:00
										 |  |  | static void pci_reg_write4(void *opaque, hwaddr addr, | 
					
						
							| 
									
										
										
										
											2011-11-20 11:52:58 +02:00
										 |  |  |                            uint64_t value, unsigned size) | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     PPCE500PCIState *pci = opaque; | 
					
						
							|  |  |  |     unsigned long win; | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |     int idx; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     win = addr & 0xfe0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-20 10:37:51 +00:00
										 |  |  |     pci_debug("%s: value:%x -> win:%lx(addr:" TARGET_FMT_plx ")\n", | 
					
						
							| 
									
										
										
										
											2011-11-20 11:52:58 +02:00
										 |  |  |               __func__, (unsigned)value, win, addr); | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     switch (win) { | 
					
						
							|  |  |  |     case PPCE500_PCI_OW1: | 
					
						
							|  |  |  |     case PPCE500_PCI_OW2: | 
					
						
							|  |  |  |     case PPCE500_PCI_OW3: | 
					
						
							|  |  |  |     case PPCE500_PCI_OW4: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |         idx = (addr >> 5) & 0x7; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |         switch (addr & 0x1F) { | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |         case PCI_POTAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             pci->pob[idx].potar = value; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |             e500_update_pow(pci, idx); | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case PCI_POTEAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             pci->pob[idx].potear = value; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |             e500_update_pow(pci, idx); | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case PCI_POWBAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             pci->pob[idx].powbar = value; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |             e500_update_pow(pci, idx); | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case PCI_POWAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             pci->pob[idx].powar = value; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |             e500_update_pow(pci, idx); | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  |         }; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case PPCE500_PCI_IW3: | 
					
						
							|  |  |  |     case PPCE500_PCI_IW2: | 
					
						
							|  |  |  |     case PPCE500_PCI_IW1: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |         idx = ((addr >> 5) & 0x3) - 1; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |         switch (addr & 0x1F) { | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |         case PCI_PITAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             pci->pib[idx].pitar = value; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |             e500_update_piw(pci, idx); | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case PCI_PIWBAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             pci->pib[idx].piwbar = value; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |             e500_update_piw(pci, idx); | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case PCI_PIWBEAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             pci->pib[idx].piwbear = value; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |             e500_update_piw(pci, idx); | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         case PCI_PIWAR: | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:50 +00:00
										 |  |  |             pci->pib[idx].piwar = value; | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |             e500_update_piw(pci, idx); | 
					
						
							| 
									
										
										
										
											2011-09-29 17:52:49 +00:00
										 |  |  |             break; | 
					
						
							|  |  |  |         default: | 
					
						
							|  |  |  |             break; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  |         }; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case PPCE500_PCI_GASKET_TIMR: | 
					
						
							|  |  |  |         pci->gasket_time = value; | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-20 11:52:58 +02:00
										 |  |  | static const MemoryRegionOps e500_pci_reg_ops = { | 
					
						
							|  |  |  |     .read = pci_reg_read4, | 
					
						
							|  |  |  |     .write = pci_reg_write4, | 
					
						
							|  |  |  |     .endianness = DEVICE_BIG_ENDIAN, | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:39 +05:30
										 |  |  | static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int pin) | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-12-12 12:58:12 +01:00
										 |  |  |     int devno = pci_dev->devfn >> 3; | 
					
						
							|  |  |  |     int ret; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:39 +05:30
										 |  |  |     ret = ppce500_pci_map_irq_slot(devno, pin); | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     pci_debug("%s: devfn %x irq %d -> %d  devno:%x\n", __func__, | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:39 +05:30
										 |  |  |            pci_dev->devfn, pin, ret, devno); | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:39 +05:30
										 |  |  | static void mpc85xx_pci_set_irq(void *opaque, int pin, int level) | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:40 +05:30
										 |  |  |     PPCE500PCIState *s = opaque; | 
					
						
							|  |  |  |     qemu_irq *pic = s->irq; | 
					
						
							| 
									
										
										
										
											2009-08-28 15:28:17 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:39 +05:30
										 |  |  |     pci_debug("%s: PCI irq %d, level:%d\n", __func__, pin , level); | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:39 +05:30
										 |  |  |     qemu_set_irq(pic[pin], level); | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:40 +05:30
										 |  |  | static PCIINTxRoute e500_route_intx_pin_to_irq(void *opaque, int pin) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     PCIINTxRoute route; | 
					
						
							|  |  |  |     PPCE500PCIState *s = opaque; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     route.mode = PCI_INTX_ENABLED; | 
					
						
							|  |  |  |     route.irq = s->irq_num[pin]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     pci_debug("%s: PCI irq-pin = %d, irq_num= %d\n", __func__, pin, route.irq); | 
					
						
							|  |  |  |     return route; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-02 15:29:42 +01:00
										 |  |  | static const VMStateDescription vmstate_pci_outbound = { | 
					
						
							|  |  |  |     .name = "pci_outbound", | 
					
						
							|  |  |  |     .version_id = 0, | 
					
						
							|  |  |  |     .minimum_version_id = 0, | 
					
						
							| 
									
										
										
										
											2014-04-16 15:24:04 +02:00
										 |  |  |     .fields = (VMStateField[]) { | 
					
						
							| 
									
										
										
										
											2010-12-02 15:29:42 +01:00
										 |  |  |         VMSTATE_UINT32(potar, struct pci_outbound), | 
					
						
							|  |  |  |         VMSTATE_UINT32(potear, struct pci_outbound), | 
					
						
							|  |  |  |         VMSTATE_UINT32(powbar, struct pci_outbound), | 
					
						
							|  |  |  |         VMSTATE_UINT32(powar, struct pci_outbound), | 
					
						
							|  |  |  |         VMSTATE_END_OF_LIST() | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-12-02 15:29:42 +01:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-02 15:29:42 +01:00
										 |  |  | static const VMStateDescription vmstate_pci_inbound = { | 
					
						
							|  |  |  |     .name = "pci_inbound", | 
					
						
							|  |  |  |     .version_id = 0, | 
					
						
							|  |  |  |     .minimum_version_id = 0, | 
					
						
							| 
									
										
										
										
											2014-04-16 15:24:04 +02:00
										 |  |  |     .fields = (VMStateField[]) { | 
					
						
							| 
									
										
										
										
											2010-12-02 15:29:42 +01:00
										 |  |  |         VMSTATE_UINT32(pitar, struct pci_inbound), | 
					
						
							|  |  |  |         VMSTATE_UINT32(piwbar, struct pci_inbound), | 
					
						
							|  |  |  |         VMSTATE_UINT32(piwbear, struct pci_inbound), | 
					
						
							|  |  |  |         VMSTATE_UINT32(piwar, struct pci_inbound), | 
					
						
							|  |  |  |         VMSTATE_END_OF_LIST() | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-12-02 15:29:42 +01:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-12-02 15:29:42 +01:00
										 |  |  | static const VMStateDescription vmstate_ppce500_pci = { | 
					
						
							|  |  |  |     .name = "ppce500_pci", | 
					
						
							|  |  |  |     .version_id = 1, | 
					
						
							|  |  |  |     .minimum_version_id = 1, | 
					
						
							| 
									
										
										
										
											2014-04-16 15:24:04 +02:00
										 |  |  |     .fields = (VMStateField[]) { | 
					
						
							| 
									
										
										
										
											2010-12-02 15:29:42 +01:00
										 |  |  |         VMSTATE_STRUCT_ARRAY(pob, PPCE500PCIState, PPCE500_PCI_NR_POBS, 1, | 
					
						
							|  |  |  |                              vmstate_pci_outbound, struct pci_outbound), | 
					
						
							|  |  |  |         VMSTATE_STRUCT_ARRAY(pib, PPCE500PCIState, PPCE500_PCI_NR_PIBS, 1, | 
					
						
							| 
									
										
										
										
											2014-05-29 12:05:34 +01:00
										 |  |  |                              vmstate_pci_inbound, struct pci_inbound), | 
					
						
							| 
									
										
										
										
											2010-12-02 15:29:42 +01:00
										 |  |  |         VMSTATE_UINT32(gasket_time, PPCE500PCIState), | 
					
						
							|  |  |  |         VMSTATE_END_OF_LIST() | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-12-02 15:29:42 +01:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-17 18:19:49 +01:00
										 |  |  | #include "exec/address-spaces.h"
 | 
					
						
							| 
									
										
										
										
											2011-07-26 14:26:19 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-19 15:52:30 +01:00
										 |  |  | static void e500_pcihost_bridge_realize(PCIDevice *d, Error **errp) | 
					
						
							| 
									
										
										
										
											2012-10-10 04:28:28 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     PPCE500PCIBridgeState *b = PPC_E500_PCI_BRIDGE(d); | 
					
						
							|  |  |  |     PPCE500CCSRState *ccsr = CCSR(container_get(qdev_get_machine(), | 
					
						
							|  |  |  |                                   "/e500-ccsr")); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-06 21:25:08 -04:00
										 |  |  |     memory_region_init_alias(&b->bar0, OBJECT(ccsr), "e500-pci-bar0", &ccsr->ccsr_space, | 
					
						
							| 
									
										
										
										
											2012-10-10 04:28:28 +00:00
										 |  |  |                              0, int128_get64(ccsr->ccsr_space.size)); | 
					
						
							|  |  |  |     pci_register_bar(d, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &b->bar0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  | static AddressSpace *e500_pcihost_set_iommu(PCIBus *bus, void *opaque, | 
					
						
							|  |  |  |                                             int devfn) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     PPCE500PCIState *s = opaque; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return &s->bm_as; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-31 00:22:28 +02:00
										 |  |  | static int e500_pcihost_initfn(SysBusDevice *dev) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     PCIHostState *h; | 
					
						
							|  |  |  |     PPCE500PCIState *s; | 
					
						
							|  |  |  |     PCIBus *b; | 
					
						
							|  |  |  |     int i; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-20 19:08:08 +02:00
										 |  |  |     h = PCI_HOST_BRIDGE(dev); | 
					
						
							| 
									
										
										
										
											2012-08-20 19:08:03 +02:00
										 |  |  |     s = PPC_E500_PCI_HOST_BRIDGE(dev); | 
					
						
							| 
									
										
										
										
											2010-08-31 00:22:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (i = 0; i < ARRAY_SIZE(s->irq); i++) { | 
					
						
							|  |  |  |         sysbus_init_irq(dev, &s->irq[i]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:40 +05:30
										 |  |  |     for (i = 0; i < PCI_NUM_PINS; i++) { | 
					
						
							|  |  |  |         s->irq_num[i] = s->first_pin_irq + i; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-06 21:25:08 -04:00
										 |  |  |     memory_region_init(&s->pio, OBJECT(s), "pci-pio", PCIE500_PCI_IOLEN); | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |     memory_region_init(&s->busmem, OBJECT(s), "pci bus memory", UINT64_MAX); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* PIO lives at the bottom of our bus space */ | 
					
						
							|  |  |  |     memory_region_add_subregion_overlap(&s->busmem, 0, &s->pio, -2); | 
					
						
							| 
									
										
										
										
											2012-10-08 12:21:30 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-29 19:46:22 +11:00
										 |  |  |     b = pci_register_root_bus(DEVICE(dev), NULL, mpc85xx_pci_set_irq, | 
					
						
							|  |  |  |                               mpc85xx_pci_map_irq, s, &s->busmem, &s->pio, | 
					
						
							|  |  |  |                               PCI_DEVFN(s->first_slot, 0), 4, TYPE_PCI_BUS); | 
					
						
							| 
									
										
										
										
											2012-08-20 19:08:03 +02:00
										 |  |  |     h->bus = b; | 
					
						
							| 
									
										
										
										
											2010-08-31 00:22:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-12 22:44:52 +01:00
										 |  |  |     /* Set up PCI view of memory */ | 
					
						
							|  |  |  |     memory_region_init(&s->bm, OBJECT(s), "bm-e500", UINT64_MAX); | 
					
						
							|  |  |  |     memory_region_add_subregion(&s->bm, 0x0, &s->busmem); | 
					
						
							|  |  |  |     address_space_init(&s->bm_as, &s->bm, "pci-bm"); | 
					
						
							|  |  |  |     pci_setup_iommu(b, e500_pcihost_set_iommu, s); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-31 00:22:28 +02:00
										 |  |  |     pci_create_simple(b, 0, "e500-host-bridge"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-06 21:25:08 -04:00
										 |  |  |     memory_region_init(&s->container, OBJECT(h), "pci-container", PCIE500_ALL_SIZE); | 
					
						
							|  |  |  |     memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_be_ops, h, | 
					
						
							| 
									
										
										
										
											2011-07-24 17:47:18 +03:00
										 |  |  |                           "pci-conf-idx", 4); | 
					
						
							| 
									
										
										
										
											2013-06-06 21:25:08 -04:00
										 |  |  |     memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops, h, | 
					
						
							| 
									
										
										
										
											2011-07-24 17:47:18 +03:00
										 |  |  |                           "pci-conf-data", 4); | 
					
						
							| 
									
										
										
										
											2013-06-06 21:25:08 -04:00
										 |  |  |     memory_region_init_io(&s->iomem, OBJECT(s), &e500_pci_reg_ops, s, | 
					
						
							| 
									
										
										
										
											2011-11-20 11:52:58 +02:00
										 |  |  |                           "pci.reg", PCIE500_REG_SIZE); | 
					
						
							| 
									
										
										
										
											2011-12-16 23:37:47 +01:00
										 |  |  |     memory_region_add_subregion(&s->container, PCIE500_CFGADDR, &h->conf_mem); | 
					
						
							|  |  |  |     memory_region_add_subregion(&s->container, PCIE500_CFGDATA, &h->data_mem); | 
					
						
							|  |  |  |     memory_region_add_subregion(&s->container, PCIE500_REG_BASE, &s->iomem); | 
					
						
							|  |  |  |     sysbus_init_mmio(dev, &s->container); | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:40 +05:30
										 |  |  |     pci_bus_set_route_irq_fn(b, e500_route_intx_pin_to_irq); | 
					
						
							| 
									
										
										
										
											2010-08-31 00:22:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-12-04 12:22:06 -06:00
										 |  |  | static void e500_host_bridge_class_init(ObjectClass *klass, void *data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     DeviceClass *dc = DEVICE_CLASS(klass); | 
					
						
							| 
									
										
										
										
											2011-12-04 12:22:06 -06:00
										 |  |  |     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-19 15:52:30 +01:00
										 |  |  |     k->realize = e500_pcihost_bridge_realize; | 
					
						
							| 
									
										
										
										
											2011-12-04 12:22:06 -06:00
										 |  |  |     k->vendor_id = PCI_VENDOR_ID_FREESCALE; | 
					
						
							|  |  |  |     k->device_id = PCI_DEVICE_ID_MPC8533E; | 
					
						
							|  |  |  |     k->class_id = PCI_CLASS_PROCESSOR_POWERPC; | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     dc->desc = "Host bridge"; | 
					
						
							| 
									
										
										
											
												pci-host: Consistently set cannot_instantiate_with_device_add_yet
Many PCI host bridges consist of a sysbus device and a PCI device.
You need both for the thing to work.  Arguably, these bridges should
be modelled as a single, composite devices instead of pairs of
seemingly independent devices you can only use together, but we're not
there, yet.
Since the sysbus part can't be instantiated with device_add, yet,
permitting it with the PCI part is useless.  We shouldn't offer
useless options to the user, so let's set
cannot_instantiate_with_device_add_yet for them.
It's already set for Bonito, Grackle, i440FX and Raven.  Document why.
Set it for the others: dec-21154, e500-host-bridge, gt64120_pci, mch,
pbm-pci, ppc4xx-host-bridge, sh_pci_host, u3-agp, uni-north-agp,
uni-north-internal-pci, uni-north-pci, and versatile_pci_host.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marcel Apfelbaum <marcel.a@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
											
										 
											2013-11-28 17:26:58 +01:00
										 |  |  |     /*
 | 
					
						
							|  |  |  |      * PCI-facing part of the host bridge, not usable without the | 
					
						
							|  |  |  |      * host-facing part, which can't be device_add'ed, yet. | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2017-05-03 17:35:44 -03:00
										 |  |  |     dc->user_creatable = false; | 
					
						
							| 
									
										
										
										
											2011-12-04 12:22:06 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-20 19:07:56 +02:00
										 |  |  | static const TypeInfo e500_host_bridge_info = { | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     .name          = "e500-host-bridge", | 
					
						
							|  |  |  |     .parent        = TYPE_PCI_DEVICE, | 
					
						
							| 
									
										
										
										
											2012-10-10 04:28:28 +00:00
										 |  |  |     .instance_size = sizeof(PPCE500PCIBridgeState), | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     .class_init    = e500_host_bridge_class_init, | 
					
						
							| 
									
										
										
										
											2017-09-27 16:56:34 -03:00
										 |  |  |     .interfaces = (InterfaceInfo[]) { | 
					
						
							|  |  |  |         { INTERFACE_CONVENTIONAL_PCI_DEVICE }, | 
					
						
							|  |  |  |         { }, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2010-08-31 00:22:28 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-12 12:56:40 +01:00
										 |  |  | static Property pcihost_properties[] = { | 
					
						
							|  |  |  |     DEFINE_PROP_UINT32("first_slot", PPCE500PCIState, first_slot, 0x11), | 
					
						
							| 
									
										
										
										
											2014-05-12 15:15:40 +05:30
										 |  |  |     DEFINE_PROP_UINT32("first_pin_irq", PPCE500PCIState, first_pin_irq, 0x1), | 
					
						
							| 
									
										
										
										
											2012-12-12 12:56:40 +01:00
										 |  |  |     DEFINE_PROP_END_OF_LIST(), | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-24 13:12:29 -06:00
										 |  |  | static void e500_pcihost_class_init(ObjectClass *klass, void *data) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     DeviceClass *dc = DEVICE_CLASS(klass); | 
					
						
							| 
									
										
										
										
											2012-01-24 13:12:29 -06:00
										 |  |  |     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     k->init = e500_pcihost_initfn; | 
					
						
							| 
									
										
										
										
											2013-07-29 17:17:45 +03:00
										 |  |  |     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); | 
					
						
							| 
									
										
										
										
											2012-12-12 12:56:40 +01:00
										 |  |  |     dc->props = pcihost_properties; | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     dc->vmsd = &vmstate_ppce500_pci; | 
					
						
							| 
									
										
										
										
											2012-01-24 13:12:29 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-20 19:07:56 +02:00
										 |  |  | static const TypeInfo e500_pcihost_info = { | 
					
						
							| 
									
										
										
										
											2012-08-20 19:08:03 +02:00
										 |  |  |     .name          = TYPE_PPC_E500_PCI_HOST_BRIDGE, | 
					
						
							| 
									
										
										
										
											2012-08-20 19:08:08 +02:00
										 |  |  |     .parent        = TYPE_PCI_HOST_BRIDGE, | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     .instance_size = sizeof(PPCE500PCIState), | 
					
						
							|  |  |  |     .class_init    = e500_pcihost_class_init, | 
					
						
							| 
									
										
										
										
											2010-08-31 00:22:28 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-09 15:20:55 +01:00
										 |  |  | static void e500_pci_register_types(void) | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-12-07 21:34:16 -06:00
										 |  |  |     type_register_static(&e500_pcihost_info); | 
					
						
							|  |  |  |     type_register_static(&e500_host_bridge_info); | 
					
						
							| 
									
										
										
										
											2009-03-02 16:42:23 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2012-02-09 15:20:55 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | type_init(e500_pci_register_types) |