pcie-iproc.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2014-2015 Broadcom Corporation
  4. */
  5. #ifndef _PCIE_IPROC_H
  6. #define _PCIE_IPROC_H
  7. /**
  8. * iProc PCIe interface type
  9. *
  10. * PAXB is the wrapper used in root complex that can be connected to an
  11. * external endpoint device.
  12. *
  13. * PAXC is the wrapper used in root complex dedicated for internal emulated
  14. * endpoint devices.
  15. */
  16. enum iproc_pcie_type {
  17. IPROC_PCIE_PAXB_BCMA = 0,
  18. IPROC_PCIE_PAXB,
  19. IPROC_PCIE_PAXB_V2,
  20. IPROC_PCIE_PAXC,
  21. IPROC_PCIE_PAXC_V2,
  22. };
  23. /**
  24. * iProc PCIe outbound mapping
  25. * @axi_offset: offset from the AXI address to the internal address used by
  26. * the iProc PCIe core
  27. * @nr_windows: total number of supported outbound mapping windows
  28. */
  29. struct iproc_pcie_ob {
  30. resource_size_t axi_offset;
  31. unsigned int nr_windows;
  32. };
  33. /**
  34. * iProc PCIe inbound mapping
  35. * @nr_regions: total number of supported inbound mapping regions
  36. */
  37. struct iproc_pcie_ib {
  38. unsigned int nr_regions;
  39. };
  40. struct iproc_pcie_ob_map;
  41. struct iproc_pcie_ib_map;
  42. struct iproc_msi;
  43. /**
  44. * iProc PCIe device
  45. *
  46. * @dev: pointer to device data structure
  47. * @type: iProc PCIe interface type
  48. * @reg_offsets: register offsets
  49. * @base: PCIe host controller I/O register base
  50. * @base_addr: PCIe host controller register base physical address
  51. * @root_bus: pointer to root bus
  52. * @phy: optional PHY device that controls the Serdes
  53. * @map_irq: function callback to map interrupts
  54. * @ep_is_internal: indicates an internal emulated endpoint device is connected
  55. * @iproc_cfg_read: indicates the iProc config read function should be used
  56. * @rej_unconfig_pf: indicates the root complex needs to detect and reject
  57. * enumeration against unconfigured physical functions emulated in the ASIC
  58. * @has_apb_err_disable: indicates the controller can be configured to prevent
  59. * unsupported request from being forwarded as an APB bus error
  60. * @fix_paxc_cap: indicates the controller has corrupted capability list in its
  61. * config space registers and requires SW based fixup
  62. *
  63. * @need_ob_cfg: indicates SW needs to configure the outbound mapping window
  64. * @ob: outbound mapping related parameters
  65. * @ob_map: outbound mapping related parameters specific to the controller
  66. *
  67. * @need_ib_cfg: indicates SW needs to configure the inbound mapping window
  68. * @ib: inbound mapping related parameters
  69. * @ib_map: outbound mapping region related parameters
  70. *
  71. * @need_msi_steer: indicates additional configuration of the iProc PCIe
  72. * controller is required to steer MSI writes to external interrupt controller
  73. * @msi: MSI data
  74. */
  75. struct iproc_pcie {
  76. struct device *dev;
  77. enum iproc_pcie_type type;
  78. u16 *reg_offsets;
  79. void __iomem *base;
  80. phys_addr_t base_addr;
  81. struct resource mem;
  82. struct pci_bus *root_bus;
  83. struct phy *phy;
  84. int (*map_irq)(const struct pci_dev *, u8, u8);
  85. bool ep_is_internal;
  86. bool iproc_cfg_read;
  87. bool rej_unconfig_pf;
  88. bool has_apb_err_disable;
  89. bool fix_paxc_cap;
  90. bool need_ob_cfg;
  91. struct iproc_pcie_ob ob;
  92. const struct iproc_pcie_ob_map *ob_map;
  93. bool need_ib_cfg;
  94. struct iproc_pcie_ib ib;
  95. const struct iproc_pcie_ib_map *ib_map;
  96. bool need_msi_steer;
  97. struct iproc_msi *msi;
  98. };
  99. int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
  100. int iproc_pcie_remove(struct iproc_pcie *pcie);
  101. int iproc_pcie_shutdown(struct iproc_pcie *pcie);
  102. #ifdef CONFIG_PCIE_IPROC_MSI
  103. int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node);
  104. void iproc_msi_exit(struct iproc_pcie *pcie);
  105. #else
  106. static inline int iproc_msi_init(struct iproc_pcie *pcie,
  107. struct device_node *node)
  108. {
  109. return -ENODEV;
  110. }
  111. static inline void iproc_msi_exit(struct iproc_pcie *pcie)
  112. {
  113. }
  114. #endif
  115. #endif /* _PCIE_IPROC_H */