2018-01-27 01:50:27 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2016-05-10 22:19:51 +07:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Broadcom
|
|
|
|
*/
|
|
|
|
#ifndef DRIVERS_PCI_ECAM_H
|
|
|
|
#define DRIVERS_PCI_ECAM_H
|
|
|
|
|
2017-03-17 21:53:19 +07:00
|
|
|
#include <linux/pci.h>
|
2016-05-10 22:19:51 +07:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* struct to hold pci ops and bus shift of the config window
|
|
|
|
* for a PCI controller.
|
|
|
|
*/
|
|
|
|
struct pci_config_window;
|
|
|
|
struct pci_ecam_ops {
|
|
|
|
unsigned int bus_shift;
|
|
|
|
struct pci_ops pci_ops;
|
2016-06-11 02:55:10 +07:00
|
|
|
int (*init)(struct pci_config_window *);
|
2016-05-10 22:19:51 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* struct to hold the mappings of a config space window. This
|
|
|
|
* is expected to be used as sysdata for PCI controllers that
|
|
|
|
* use ECAM.
|
|
|
|
*/
|
|
|
|
struct pci_config_window {
|
|
|
|
struct resource res;
|
|
|
|
struct resource busr;
|
|
|
|
void *priv;
|
|
|
|
struct pci_ecam_ops *ops;
|
|
|
|
union {
|
|
|
|
void __iomem *win; /* 64-bit single mapping */
|
|
|
|
void __iomem **winp; /* 32-bit per-bus mapping */
|
|
|
|
};
|
2016-06-11 02:55:10 +07:00
|
|
|
struct device *parent;/* ECAM res was from this dev */
|
2016-05-10 22:19:51 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/* create and free pci_config_window */
|
|
|
|
struct pci_config_window *pci_ecam_create(struct device *dev,
|
|
|
|
struct resource *cfgres, struct resource *busr,
|
|
|
|
struct pci_ecam_ops *ops);
|
|
|
|
void pci_ecam_free(struct pci_config_window *cfg);
|
|
|
|
|
|
|
|
/* map_bus when ->sysdata is an instance of pci_config_window */
|
|
|
|
void __iomem *pci_ecam_map_bus(struct pci_bus *bus, unsigned int devfn,
|
|
|
|
int where);
|
|
|
|
/* default ECAM ops */
|
|
|
|
extern struct pci_ecam_ops pci_generic_ecam_ops;
|
|
|
|
|
2016-11-02 23:11:27 +07:00
|
|
|
#if defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS)
|
|
|
|
extern struct pci_ecam_ops pci_32b_ops; /* 32-bit accesses only */
|
2016-12-01 13:45:35 +07:00
|
|
|
extern struct pci_ecam_ops hisi_pcie_ops; /* HiSilicon */
|
2016-12-01 12:16:34 +07:00
|
|
|
extern struct pci_ecam_ops thunder_pem_ecam_ops; /* Cavium ThunderX 1.x & 2.x */
|
|
|
|
extern struct pci_ecam_ops pci_thunder_ecam_ops; /* Cavium ThunderX 1.x */
|
2016-12-02 09:27:07 +07:00
|
|
|
extern struct pci_ecam_ops xgene_v1_pcie_ecam_ops; /* APM X-Gene PCIe v1 */
|
|
|
|
extern struct pci_ecam_ops xgene_v2_pcie_ecam_ops; /* APM X-Gene PCIe v2.x */
|
2019-03-28 18:57:56 +07:00
|
|
|
extern struct pci_ecam_ops al_pcie_ops; /* Amazon Annapurna Labs PCIe */
|
2016-11-02 23:11:27 +07:00
|
|
|
#endif
|
|
|
|
|
2017-04-19 02:21:04 +07:00
|
|
|
#ifdef CONFIG_PCI_HOST_COMMON
|
2016-05-12 05:34:46 +07:00
|
|
|
/* for DT-based PCI controllers that support ECAM */
|
|
|
|
int pci_host_common_probe(struct platform_device *pdev,
|
|
|
|
struct pci_ecam_ops *ops);
|
2018-05-15 16:07:06 +07:00
|
|
|
int pci_host_common_remove(struct platform_device *pdev);
|
2016-05-12 05:34:46 +07:00
|
|
|
#endif
|
2016-05-10 22:19:51 +07:00
|
|
|
#endif
|