1d64e5eabSAndrey Smirnov /* 2d64e5eabSAndrey Smirnov * Copyright (c) 2017, Impinj, Inc. 3d64e5eabSAndrey Smirnov * 4d64e5eabSAndrey Smirnov * Designware PCIe IP block emulation 5d64e5eabSAndrey Smirnov * 6d64e5eabSAndrey Smirnov * This library is free software; you can redistribute it and/or 7d64e5eabSAndrey Smirnov * modify it under the terms of the GNU Lesser General Public 8d64e5eabSAndrey Smirnov * License as published by the Free Software Foundation; either 961f3c91aSChetan Pant * version 2.1 of the License, or (at your option) any later version. 10d64e5eabSAndrey Smirnov * 11d64e5eabSAndrey Smirnov * This library is distributed in the hope that it will be useful, 12d64e5eabSAndrey Smirnov * but WITHOUT ANY WARRANTY; without even the implied warranty of 13d64e5eabSAndrey Smirnov * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14d64e5eabSAndrey Smirnov * Lesser General Public License for more details. 15d64e5eabSAndrey Smirnov * 16d64e5eabSAndrey Smirnov * You should have received a copy of the GNU Lesser General Public 17d64e5eabSAndrey Smirnov * License along with this library; if not, see 18d64e5eabSAndrey Smirnov * <http://www.gnu.org/licenses/>. 19d64e5eabSAndrey Smirnov */ 20d64e5eabSAndrey Smirnov 21d64e5eabSAndrey Smirnov #ifndef DESIGNWARE_H 22d64e5eabSAndrey Smirnov #define DESIGNWARE_H 23d64e5eabSAndrey Smirnov 24d64e5eabSAndrey Smirnov #include "hw/sysbus.h" 25d64e5eabSAndrey Smirnov #include "hw/pci/pci_bridge.h" 26db1015e9SEduardo Habkost #include "qom/object.h" 27d64e5eabSAndrey Smirnov 28*faa2150aSBernhard Beschow #define TYPE_DESIGNWARE_PCIE_ROOT_BUS "designware-pcie-root-BUS" 29*faa2150aSBernhard Beschow OBJECT_DECLARE_SIMPLE_TYPE(DesignwarePCIERootBus, DESIGNWARE_PCIE_ROOT_BUS) 30*faa2150aSBernhard Beschow 31d64e5eabSAndrey Smirnov #define TYPE_DESIGNWARE_PCIE_HOST "designware-pcie-host" 328063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(DesignwarePCIEHost, DESIGNWARE_PCIE_HOST) 33d64e5eabSAndrey Smirnov 34d64e5eabSAndrey Smirnov #define TYPE_DESIGNWARE_PCIE_ROOT "designware-pcie-root" 358063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(DesignwarePCIERoot, DESIGNWARE_PCIE_ROOT) 36d64e5eabSAndrey Smirnov 37*faa2150aSBernhard Beschow struct DesignwarePCIERootBus { 38*faa2150aSBernhard Beschow PCIBus parent; 39*faa2150aSBernhard Beschow }; 40*faa2150aSBernhard Beschow 41d64e5eabSAndrey Smirnov typedef struct DesignwarePCIEViewport { 42d64e5eabSAndrey Smirnov DesignwarePCIERoot *root; 43d64e5eabSAndrey Smirnov 44d64e5eabSAndrey Smirnov MemoryRegion cfg; 45d64e5eabSAndrey Smirnov MemoryRegion mem; 46d64e5eabSAndrey Smirnov 47d64e5eabSAndrey Smirnov uint64_t base; 48d64e5eabSAndrey Smirnov uint64_t target; 49d64e5eabSAndrey Smirnov uint32_t limit; 50d64e5eabSAndrey Smirnov uint32_t cr[2]; 51d64e5eabSAndrey Smirnov 52d64e5eabSAndrey Smirnov bool inbound; 53d64e5eabSAndrey Smirnov } DesignwarePCIEViewport; 54d64e5eabSAndrey Smirnov 55d64e5eabSAndrey Smirnov typedef struct DesignwarePCIEMSIBank { 56d64e5eabSAndrey Smirnov uint32_t enable; 57d64e5eabSAndrey Smirnov uint32_t mask; 58d64e5eabSAndrey Smirnov uint32_t status; 59d64e5eabSAndrey Smirnov } DesignwarePCIEMSIBank; 60d64e5eabSAndrey Smirnov 61d64e5eabSAndrey Smirnov typedef struct DesignwarePCIEMSI { 62d64e5eabSAndrey Smirnov uint64_t base; 63d64e5eabSAndrey Smirnov MemoryRegion iomem; 64d64e5eabSAndrey Smirnov 65d64e5eabSAndrey Smirnov #define DESIGNWARE_PCIE_NUM_MSI_BANKS 1 66d64e5eabSAndrey Smirnov 67d64e5eabSAndrey Smirnov DesignwarePCIEMSIBank intr[DESIGNWARE_PCIE_NUM_MSI_BANKS]; 68d64e5eabSAndrey Smirnov } DesignwarePCIEMSI; 69d64e5eabSAndrey Smirnov 70d64e5eabSAndrey Smirnov struct DesignwarePCIERoot { 71d64e5eabSAndrey Smirnov PCIBridge parent_obj; 72d64e5eabSAndrey Smirnov 73d64e5eabSAndrey Smirnov uint32_t atu_viewport; 74d64e5eabSAndrey Smirnov 75d64e5eabSAndrey Smirnov #define DESIGNWARE_PCIE_VIEWPORT_OUTBOUND 0 76d64e5eabSAndrey Smirnov #define DESIGNWARE_PCIE_VIEWPORT_INBOUND 1 77d64e5eabSAndrey Smirnov #define DESIGNWARE_PCIE_NUM_VIEWPORTS 4 78d64e5eabSAndrey Smirnov 79d64e5eabSAndrey Smirnov DesignwarePCIEViewport viewports[2][DESIGNWARE_PCIE_NUM_VIEWPORTS]; 80d64e5eabSAndrey Smirnov DesignwarePCIEMSI msi; 81d64e5eabSAndrey Smirnov }; 82d64e5eabSAndrey Smirnov 83db1015e9SEduardo Habkost struct DesignwarePCIEHost { 84d64e5eabSAndrey Smirnov PCIHostState parent_obj; 85d64e5eabSAndrey Smirnov 86d64e5eabSAndrey Smirnov DesignwarePCIERoot root; 87d64e5eabSAndrey Smirnov 88d64e5eabSAndrey Smirnov struct { 89d64e5eabSAndrey Smirnov AddressSpace address_space; 90d64e5eabSAndrey Smirnov MemoryRegion address_space_root; 91d64e5eabSAndrey Smirnov 92d64e5eabSAndrey Smirnov MemoryRegion memory; 93d64e5eabSAndrey Smirnov MemoryRegion io; 94d64e5eabSAndrey Smirnov 95d64e5eabSAndrey Smirnov qemu_irq irqs[4]; 961b326f27SBernhard Beschow qemu_irq msi; 97d64e5eabSAndrey Smirnov } pci; 98d64e5eabSAndrey Smirnov 99d64e5eabSAndrey Smirnov MemoryRegion mmio; 100db1015e9SEduardo Habkost }; 101d64e5eabSAndrey Smirnov 102d64e5eabSAndrey Smirnov #endif /* DESIGNWARE_H */ 103