pcie-iproc.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright (C) 2014-2015 Broadcom Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation version 2.
  7. *
  8. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  9. * kind, whether express or implied; without even the implied warranty
  10. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef _PCIE_IPROC_H
  14. #define _PCIE_IPROC_H
  15. /**
  16. * iProc PCIe interface type
  17. *
  18. * PAXB is the wrapper used in root complex that can be connected to an
  19. * external endpoint device.
  20. *
  21. * PAXC is the wrapper used in root complex dedicated for internal emulated
  22. * endpoint devices.
  23. */
  24. enum iproc_pcie_type {
  25. IPROC_PCIE_PAXB_BCMA = 0,
  26. IPROC_PCIE_PAXB,
  27. IPROC_PCIE_PAXB_V2,
  28. IPROC_PCIE_PAXC,
  29. IPROC_PCIE_PAXC_V2,
  30. };
  31. /**
  32. * iProc PCIe outbound mapping
  33. * @axi_offset: offset from the AXI address to the internal address used by
  34. * the iProc PCIe core
  35. * @nr_windows: total number of supported outbound mapping windows
  36. */
  37. struct iproc_pcie_ob {
  38. resource_size_t axi_offset;
  39. unsigned int nr_windows;
  40. };
  41. /**
  42. * iProc PCIe inbound mapping
  43. * @nr_regions: total number of supported inbound mapping regions
  44. */
  45. struct iproc_pcie_ib {
  46. unsigned int nr_regions;
  47. };
  48. struct iproc_pcie_ob_map;
  49. struct iproc_pcie_ib_map;
  50. struct iproc_msi;
  51. /**
  52. * iProc PCIe device
  53. *
  54. * @dev: pointer to device data structure
  55. * @type: iProc PCIe interface type
  56. * @reg_offsets: register offsets
  57. * @base: PCIe host controller I/O register base
  58. * @base_addr: PCIe host controller register base physical address
  59. * @sysdata: Per PCI controller data (ARM-specific)
  60. * @root_bus: pointer to root bus
  61. * @phy: optional PHY device that controls the Serdes
  62. * @map_irq: function callback to map interrupts
  63. * @ep_is_internal: indicates an internal emulated endpoint device is connected
  64. * @has_apb_err_disable: indicates the controller can be configured to prevent
  65. * unsupported request from being forwarded as an APB bus error
  66. *
  67. * @need_ob_cfg: indicates SW needs to configure the outbound mapping window
  68. * @ob: outbound mapping related parameters
  69. * @ob_map: outbound mapping related parameters specific to the controller
  70. *
  71. * @ib: inbound mapping related parameters
  72. * @ib_map: outbound mapping region related parameters
  73. *
  74. * @need_msi_steer: indicates additional configuration of the iProc PCIe
  75. * controller is required to steer MSI writes to external interrupt controller
  76. * @msi: MSI data
  77. */
  78. struct iproc_pcie {
  79. struct device *dev;
  80. enum iproc_pcie_type type;
  81. u16 *reg_offsets;
  82. void __iomem *base;
  83. phys_addr_t base_addr;
  84. #ifdef CONFIG_ARM
  85. struct pci_sys_data sysdata;
  86. #endif
  87. struct pci_bus *root_bus;
  88. struct phy *phy;
  89. int (*map_irq)(const struct pci_dev *, u8, u8);
  90. bool ep_is_internal;
  91. bool has_apb_err_disable;
  92. bool need_ob_cfg;
  93. struct iproc_pcie_ob ob;
  94. const struct iproc_pcie_ob_map *ob_map;
  95. struct iproc_pcie_ib ib;
  96. const struct iproc_pcie_ib_map *ib_map;
  97. bool need_msi_steer;
  98. struct iproc_msi *msi;
  99. };
  100. int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res);
  101. int iproc_pcie_remove(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 */