pci-ecam.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright 2016 Broadcom
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License, version 2, as
  6. * published by the Free Software Foundation (the "GPL").
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License version 2 (GPLv2) for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * version 2 (GPLv2) along with this source code.
  15. */
  16. #ifndef DRIVERS_PCI_ECAM_H
  17. #define DRIVERS_PCI_ECAM_H
  18. #include <linux/pci.h>
  19. #include <linux/kernel.h>
  20. #include <linux/platform_device.h>
  21. /*
  22. * struct to hold pci ops and bus shift of the config window
  23. * for a PCI controller.
  24. */
  25. struct pci_config_window;
  26. struct pci_ecam_ops {
  27. unsigned int bus_shift;
  28. struct pci_ops pci_ops;
  29. int (*init)(struct pci_config_window *);
  30. };
  31. /*
  32. * struct to hold the mappings of a config space window. This
  33. * is expected to be used as sysdata for PCI controllers that
  34. * use ECAM.
  35. */
  36. struct pci_config_window {
  37. struct resource res;
  38. struct resource busr;
  39. void *priv;
  40. struct pci_ecam_ops *ops;
  41. union {
  42. void __iomem *win; /* 64-bit single mapping */
  43. void __iomem **winp; /* 32-bit per-bus mapping */
  44. };
  45. struct device *parent;/* ECAM res was from this dev */
  46. };
  47. /* create and free pci_config_window */
  48. struct pci_config_window *pci_ecam_create(struct device *dev,
  49. struct resource *cfgres, struct resource *busr,
  50. struct pci_ecam_ops *ops);
  51. void pci_ecam_free(struct pci_config_window *cfg);
  52. /* map_bus when ->sysdata is an instance of pci_config_window */
  53. void __iomem *pci_ecam_map_bus(struct pci_bus *bus, unsigned int devfn,
  54. int where);
  55. /* default ECAM ops */
  56. extern struct pci_ecam_ops pci_generic_ecam_ops;
  57. #if defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS)
  58. extern struct pci_ecam_ops pci_32b_ops; /* 32-bit accesses only */
  59. extern struct pci_ecam_ops hisi_pcie_ops; /* HiSilicon */
  60. extern struct pci_ecam_ops thunder_pem_ecam_ops; /* Cavium ThunderX 1.x & 2.x */
  61. extern struct pci_ecam_ops pci_thunder_ecam_ops; /* Cavium ThunderX 1.x */
  62. extern struct pci_ecam_ops xgene_v1_pcie_ecam_ops; /* APM X-Gene PCIe v1 */
  63. extern struct pci_ecam_ops xgene_v2_pcie_ecam_ops; /* APM X-Gene PCIe v2.x */
  64. #endif
  65. #ifdef CONFIG_PCI_HOST_COMMON
  66. /* for DT-based PCI controllers that support ECAM */
  67. int pci_host_common_probe(struct platform_device *pdev,
  68. struct pci_ecam_ops *ops);
  69. #endif
  70. #endif