pcie-iproc.h 4.0 KB

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