ppc: Remove xpedite boards
[platform/kernel/u-boot.git] / include / pci.h
index 281f353..8e62235 100644 (file)
 #define PCI_EA_FIRST_ENT       4       /* First EA Entry in List */
 #define  PCI_EA_ES             0x00000007 /* Entry Size */
 #define  PCI_EA_BEI            0x000000f0 /* BAR Equivalent Indicator */
+/* 9-14 map to VF BARs 0-5 respectively */
+#define  PCI_EA_BEI_VF_BAR0    9
+#define  PCI_EA_BEI_VF_BAR5    14
 /* Base, MaxOffset registers */
 /* bit 0 is reserved */
 #define  PCI_EA_IS_64          0x00000002      /* 64-bit field flag */
 #define  PCI_EXP_LNKSTA_DLLLA  0x2000  /* Data Link Layer Link Active */
 #define PCI_EXP_SLTCAP         20      /* Slot Capabilities */
 #define  PCI_EXP_SLTCAP_PSN    0xfff80000 /* Physical Slot Number */
+#define PCI_EXP_DEVCAP2                36      /* Device Capabilities 2 */
+#define  PCI_EXP_DEVCAP2_ARI   0x00000020 /* ARI Forwarding Supported */
+#define PCI_EXP_DEVCTL2                40      /* Device Control 2 */
+#define  PCI_EXP_DEVCTL2_ARI   0x0020 /* Alternative Routing-ID */
+
 #define PCI_EXP_LNKCTL2                48      /* Link Control 2 */
+/* Single Root I/O Virtualization Registers */
+#define PCI_SRIOV_CAP          0x04    /* SR-IOV Capabilities */
+#define PCI_SRIOV_CTRL         0x08    /* SR-IOV Control */
+#define  PCI_SRIOV_CTRL_VFE    0x01    /* VF Enable */
+#define  PCI_SRIOV_CTRL_MSE    0x08    /* VF Memory Space Enable */
+#define  PCI_SRIOV_CTRL_ARI    0x10    /* ARI Capable Hierarchy */
+#define PCI_SRIOV_INITIAL_VF   0x0c    /* Initial VFs */
+#define PCI_SRIOV_TOTAL_VF     0x0e    /* Total VFs */
+#define PCI_SRIOV_NUM_VF       0x10    /* Number of VFs */
+#define PCI_SRIOV_VF_OFFSET    0x14    /* First VF Offset */
+#define PCI_SRIOV_VF_STRIDE    0x16    /* Following VF Stride */
+#define PCI_SRIOV_VF_DID       0x1a    /* VF Device ID */
 
 /* Include the ID list */
 
@@ -590,8 +610,6 @@ extern void pci_cfgfunc_do_nothing(struct pci_controller* hose, pci_dev_t dev,
 extern void pci_cfgfunc_config_device(struct pci_controller* hose, pci_dev_t dev,
                                      struct pci_config_table *);
 
-#define MAX_PCI_REGIONS                7
-
 #define INDIRECT_TYPE_NO_PCIE_LINK     1
 
 /**
@@ -632,7 +650,7 @@ struct pci_controller {
         * for PCI controllers and a separate UCLASS (or perhaps
         * UCLASS_PCI_GENERIC) is used for bridges.
         */
-       struct pci_region regions[MAX_PCI_REGIONS];
+       struct pci_region *regions;
        int region_count;
 
        struct pci_config_table *config_table;
@@ -810,12 +828,6 @@ int pci_find_next_ext_capability(struct pci_controller *hose,
 int pci_hose_find_ext_capability(struct pci_controller *hose,
                                 pci_dev_t dev, int cap);
 
-#ifdef CONFIG_PCI_FIXUP_DEV
-extern void board_pci_fixup_dev(struct pci_controller *hose, pci_dev_t dev,
-                               unsigned short vendor,
-                               unsigned short device,
-                               unsigned short class);
-#endif
 #endif /* !defined(CONFIG_DM_PCI) || defined(CONFIG_DM_PCI_COMPAT) */
 
 const char * pci_class_str(u8 class);
@@ -881,23 +893,31 @@ struct udevice;
 
 #ifdef CONFIG_DM_PCI
 /**
- * struct pci_child_platdata - information stored about each PCI device
+ * struct pci_child_plat - information stored about each PCI device
  *
  * Every device on a PCI bus has this per-child data.
  *
- * It can be accessed using dev_get_parent_platdata(dev) if dev->parent is a
+ * It can be accessed using dev_get_parent_plat(dev) if dev->parent is a
  * PCI bus (i.e. UCLASS_PCI)
  *
  * @devfn:     Encoded device and function index - see PCI_DEVFN()
  * @vendor:    PCI vendor ID (see pci_ids.h)
  * @device:    PCI device ID (see pci_ids.h)
  * @class:     PCI class, 3 bytes: (base, sub, prog-if)
+ * @is_virtfn: True for Virtual Function device
+ * @pfdev:     Handle to Physical Function device
+ * @virtid:    Virtual Function Index
  */
-struct pci_child_platdata {
+struct pci_child_plat {
        int devfn;
        unsigned short vendor;
        unsigned short device;
        unsigned int class;
+
+       /* Variables for CONFIG_PCI_SRIOV */
+       bool is_virtfn;
+       struct udevice *pfdev;
+       int virtid;
 };
 
 /* PCI bus operations */
@@ -908,7 +928,7 @@ struct dm_pci_ops {
         * PCI buses must support reading and writing configuration values
         * so that the bus can be scanned and its devices configured.
         *
-        * Normally PCI_BUS(@bdf) is the same as @bus->seq, but not always.
+        * Normally PCI_BUS(@bdf) is the same as @dev_seq(bus), but not always.
         * If bridges exist it is possible to use the top-level bus to
         * access a sub-bus. In that case @bus will be the top-level bus
         * and PCI_BUS(bdf) will be a different (higher) value
@@ -1210,6 +1230,25 @@ int pci_generic_mmap_read_config(
        ulong *valuep,
        enum pci_size_t size);
 
+#if defined(CONFIG_PCI_SRIOV)
+/**
+ * pci_sriov_init() - Scan Virtual Function devices
+ *
+ * @pdev:      Physical Function udevice handle
+ * @vf_en:     Number of Virtual Function devices to enable
+ * @return 0 on success, -ve on error
+ */
+int pci_sriov_init(struct udevice *pdev, int vf_en);
+
+/**
+ * pci_sriov_get_totalvfs() - Get total available Virtual Function devices
+ *
+ * @pdev:      Physical Function udevice handle
+ * @return count on success, -ve on error
+ */
+int pci_sriov_get_totalvfs(struct udevice *pdev);
+#endif
+
 #ifdef CONFIG_DM_PCI_COMPAT
 /* Compatibility with old naming */
 static inline int pci_write_config_dword(pci_dev_t pcidev, int offset,
@@ -1315,7 +1354,8 @@ struct udevice *pci_get_controller(struct udevice *dev);
  */
 int pci_get_regions(struct udevice *dev, struct pci_region **iop,
                    struct pci_region **memp, struct pci_region **prefp);
-
+int
+pci_get_dma_regions(struct udevice *dev, struct pci_region *memp, int index);
 /**
  * dm_pci_write_bar32() - Write the address of a BAR
  *
@@ -1644,6 +1684,14 @@ int sandbox_pci_get_emul(const struct udevice *bus, pci_dev_t find_devfn,
  */
 int sandbox_pci_get_client(struct udevice *emul, struct udevice **devp);
 
+/**
+ * board_pci_fixup_dev() - Board callback for PCI device fixups
+ *
+ * @bus:       PCI bus
+ * @dev:       PCI device
+ */
+extern void board_pci_fixup_dev(struct udevice *bus, struct udevice *dev);
+
 #endif /* CONFIG_DM_PCI */
 
 /**