0001
0002
0003
0004
0005 #ifndef DRIVERS_PCI_ECAM_H
0006 #define DRIVERS_PCI_ECAM_H
0007
0008 #include <linux/pci.h>
0009 #include <linux/kernel.h>
0010 #include <linux/platform_device.h>
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #define PCIE_ECAM_BUS_SHIFT 20
0024 #define PCIE_ECAM_DEVFN_SHIFT 12
0025
0026 #define PCIE_ECAM_BUS_MASK 0xff
0027 #define PCIE_ECAM_DEVFN_MASK 0xff
0028 #define PCIE_ECAM_REG_MASK 0xfff
0029
0030 #define PCIE_ECAM_BUS(x) (((x) & PCIE_ECAM_BUS_MASK) << PCIE_ECAM_BUS_SHIFT)
0031 #define PCIE_ECAM_DEVFN(x) (((x) & PCIE_ECAM_DEVFN_MASK) << PCIE_ECAM_DEVFN_SHIFT)
0032 #define PCIE_ECAM_REG(x) ((x) & PCIE_ECAM_REG_MASK)
0033
0034 #define PCIE_ECAM_OFFSET(bus, devfn, where) \
0035 (PCIE_ECAM_BUS(bus) | \
0036 PCIE_ECAM_DEVFN(devfn) | \
0037 PCIE_ECAM_REG(where))
0038
0039
0040
0041
0042
0043 struct pci_config_window;
0044 struct pci_ecam_ops {
0045 unsigned int bus_shift;
0046 struct pci_ops pci_ops;
0047 int (*init)(struct pci_config_window *);
0048 };
0049
0050
0051
0052
0053
0054
0055 struct pci_config_window {
0056 struct resource res;
0057 struct resource busr;
0058 unsigned int bus_shift;
0059 void *priv;
0060 const struct pci_ecam_ops *ops;
0061 union {
0062 void __iomem *win;
0063 void __iomem **winp;
0064 };
0065 struct device *parent;
0066 };
0067
0068
0069 struct pci_config_window *pci_ecam_create(struct device *dev,
0070 struct resource *cfgres, struct resource *busr,
0071 const struct pci_ecam_ops *ops);
0072 void pci_ecam_free(struct pci_config_window *cfg);
0073
0074
0075 void __iomem *pci_ecam_map_bus(struct pci_bus *bus, unsigned int devfn,
0076 int where);
0077
0078 extern const struct pci_ecam_ops pci_generic_ecam_ops;
0079
0080 #if defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS)
0081 extern const struct pci_ecam_ops pci_32b_ops;
0082 extern const struct pci_ecam_ops pci_32b_read_ops;
0083 extern const struct pci_ecam_ops hisi_pcie_ops;
0084 extern const struct pci_ecam_ops thunder_pem_ecam_ops;
0085 extern const struct pci_ecam_ops pci_thunder_ecam_ops;
0086 extern const struct pci_ecam_ops xgene_v1_pcie_ecam_ops;
0087 extern const struct pci_ecam_ops xgene_v2_pcie_ecam_ops;
0088 extern const struct pci_ecam_ops al_pcie_ops;
0089 extern const struct pci_ecam_ops tegra194_pcie_ops;
0090 extern const struct pci_ecam_ops loongson_pci_ecam_ops;
0091 #endif
0092
0093 #if IS_ENABLED(CONFIG_PCI_HOST_COMMON)
0094
0095 int pci_host_common_probe(struct platform_device *pdev);
0096 int pci_host_common_remove(struct platform_device *pdev);
0097 #endif
0098 #endif