pci-ecam.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright 2016 Broadcom
  4. */
  5. #ifndef DRIVERS_PCI_ECAM_H
  6. #define DRIVERS_PCI_ECAM_H
  7. #include <linux/pci.h>
  8. #include <linux/kernel.h>
  9. #include <linux/platform_device.h>
  10. /*
  11. * struct to hold pci ops and bus shift of the config window
  12. * for a PCI controller.
  13. */
  14. struct pci_config_window;
  15. struct pci_ecam_ops {
  16. unsigned int bus_shift;
  17. struct pci_ops pci_ops;
  18. int (*init)(struct pci_config_window *);
  19. };
  20. /*
  21. * struct to hold the mappings of a config space window. This
  22. * is expected to be used as sysdata for PCI controllers that
  23. * use ECAM.
  24. */
  25. struct pci_config_window {
  26. struct resource res;
  27. struct resource busr;
  28. void *priv;
  29. struct pci_ecam_ops *ops;
  30. union {
  31. void __iomem *win; /* 64-bit single mapping */
  32. void __iomem **winp; /* 32-bit per-bus mapping */
  33. };
  34. struct device *parent;/* ECAM res was from this dev */
  35. };
  36. /* create and free pci_config_window */
  37. struct pci_config_window *pci_ecam_create(struct device *dev,
  38. struct resource *cfgres, struct resource *busr,
  39. struct pci_ecam_ops *ops);
  40. void pci_ecam_free(struct pci_config_window *cfg);
  41. /* map_bus when ->sysdata is an instance of pci_config_window */
  42. void __iomem *pci_ecam_map_bus(struct pci_bus *bus, unsigned int devfn,
  43. int where);
  44. /* default ECAM ops */
  45. extern struct pci_ecam_ops pci_generic_ecam_ops;
  46. #if defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS)
  47. extern struct pci_ecam_ops pci_32b_ops; /* 32-bit accesses only */
  48. extern struct pci_ecam_ops hisi_pcie_ops; /* HiSilicon */
  49. extern struct pci_ecam_ops thunder_pem_ecam_ops; /* Cavium ThunderX 1.x & 2.x */
  50. extern struct pci_ecam_ops pci_thunder_ecam_ops; /* Cavium ThunderX 1.x */
  51. extern struct pci_ecam_ops xgene_v1_pcie_ecam_ops; /* APM X-Gene PCIe v1 */
  52. extern struct pci_ecam_ops xgene_v2_pcie_ecam_ops; /* APM X-Gene PCIe v2.x */
  53. #endif
  54. #ifdef CONFIG_PCI_HOST_COMMON
  55. /* for DT-based PCI controllers that support ECAM */
  56. int pci_host_common_probe(struct platform_device *pdev,
  57. struct pci_ecam_ops *ops);
  58. int pci_host_common_remove(struct platform_device *pdev);
  59. #endif
  60. #endif