pcie-iproc.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. * @has_apb_err_disable: indicates the controller can be configured to prevent
  56. * unsupported request from being forwarded as an APB bus error
  57. *
  58. * @need_ob_cfg: indicates SW needs to configure the outbound mapping window
  59. * @ob: outbound mapping related parameters
  60. * @ob_map: outbound mapping related parameters specific to the controller
  61. *
  62. * @need_ib_cfg: indicates SW needs to configure the inbound mapping window
  63. * @ib: inbound mapping related parameters
  64. * @ib_map: outbound mapping region related parameters
  65. *
  66. * @need_msi_steer: indicates additional configuration of the iProc PCIe
  67. * controller is required to steer MSI writes to external interrupt controller
  68. * @msi: MSI data
  69. */
  70. struct iproc_pcie {
  71. struct device *dev;
  72. enum iproc_pcie_type type;
  73. u16 *reg_offsets;
  74. void __iomem *base;
  75. phys_addr_t base_addr;
  76. struct resource mem;
  77. struct pci_bus *root_bus;
  78. struct phy *phy;
  79. int (*map_irq)(const struct pci_dev *, u8, u8);
  80. bool ep_is_internal;
  81. bool has_apb_err_disable;
  82. bool need_ob_cfg;
  83. struct iproc_pcie_ob ob;
  84. const struct iproc_pcie_ob_map *ob_map;
  85. bool need_ib_cfg;
  86. struct iproc_pcie_ib ib;
  87. const struct iproc_pcie_ib_map *ib_map;
  88. bool need_msi_steer;
  89. struct iproc_msi *msi;
  90. };
  91. int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
  92. int iproc_pcie_remove(struct iproc_pcie *pcie);
  93. int iproc_pcie_shutdown(struct iproc_pcie *pcie);
  94. #ifdef CONFIG_PCIE_IPROC_MSI
  95. int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node);
  96. void iproc_msi_exit(struct iproc_pcie *pcie);
  97. #else
  98. static inline int iproc_msi_init(struct iproc_pcie *pcie,
  99. struct device_node *node)
  100. {
  101. return -ENODEV;
  102. }
  103. static inline void iproc_msi_exit(struct iproc_pcie *pcie)
  104. {
  105. }
  106. #endif
  107. #endif /* _PCIE_IPROC_H */