pcie_layerscape.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright 2017-2019 NXP
  4. * Copyright 2014-2015 Freescale Semiconductor, Inc.
  5. * Layerscape PCIe driver
  6. */
  7. #ifndef _PCIE_LAYERSCAPE_H_
  8. #define _PCIE_LAYERSCAPE_H_
  9. #include <pci.h>
  10. #include <dm.h>
  11. #ifndef CONFIG_SYS_PCI_MEMORY_BUS
  12. #define CONFIG_SYS_PCI_MEMORY_BUS CONFIG_SYS_SDRAM_BASE
  13. #endif
  14. #ifndef CONFIG_SYS_PCI_MEMORY_PHYS
  15. #define CONFIG_SYS_PCI_MEMORY_PHYS CONFIG_SYS_SDRAM_BASE
  16. #endif
  17. #ifndef CONFIG_SYS_PCI_MEMORY_SIZE
  18. #define CONFIG_SYS_PCI_MEMORY_SIZE (2 * 1024 * 1024 * 1024UL) /* 2G */
  19. #endif
  20. #ifndef CONFIG_SYS_PCI_EP_MEMORY_BASE
  21. #define CONFIG_SYS_PCI_EP_MEMORY_BASE CONFIG_SYS_LOAD_ADDR
  22. #endif
  23. #define PCIE_PHYS_SIZE 0x200000000
  24. #define LS2088A_PCIE_PHYS_SIZE 0x800000000
  25. #define LS2088A_PCIE1_PHYS_ADDR 0x2000000000
  26. /* iATU registers */
  27. #define PCIE_ATU_VIEWPORT 0x900
  28. #define PCIE_ATU_REGION_INBOUND (0x1 << 31)
  29. #define PCIE_ATU_REGION_OUTBOUND (0x0 << 31)
  30. #define PCIE_ATU_REGION_INDEX0 (0x0 << 0)
  31. #define PCIE_ATU_REGION_INDEX1 (0x1 << 0)
  32. #define PCIE_ATU_REGION_INDEX2 (0x2 << 0)
  33. #define PCIE_ATU_REGION_INDEX3 (0x3 << 0)
  34. #define PCIE_ATU_REGION_NUM 6
  35. #define PCIE_ATU_CR1 0x904
  36. #define PCIE_ATU_TYPE_MEM (0x0 << 0)
  37. #define PCIE_ATU_TYPE_IO (0x2 << 0)
  38. #define PCIE_ATU_TYPE_CFG0 (0x4 << 0)
  39. #define PCIE_ATU_TYPE_CFG1 (0x5 << 0)
  40. #define PCIE_ATU_CR2 0x908
  41. #define PCIE_ATU_ENABLE (0x1 << 31)
  42. #define PCIE_ATU_BAR_MODE_ENABLE (0x1 << 30)
  43. #define PCIE_ATU_BAR_NUM(bar) ((bar) << 8)
  44. #define PCIE_ATU_LOWER_BASE 0x90C
  45. #define PCIE_ATU_UPPER_BASE 0x910
  46. #define PCIE_ATU_LIMIT 0x914
  47. #define PCIE_ATU_LOWER_TARGET 0x918
  48. #define PCIE_ATU_BUS(x) (((x) & 0xff) << 24)
  49. #define PCIE_ATU_DEV(x) (((x) & 0x1f) << 19)
  50. #define PCIE_ATU_FUNC(x) (((x) & 0x7) << 16)
  51. #define PCIE_ATU_UPPER_TARGET 0x91C
  52. /* DBI registers */
  53. #define PCIE_SRIOV 0x178
  54. #define PCIE_STRFMR1 0x71c /* Symbol Timer & Filter Mask Register1 */
  55. #define PCIE_DBI_RO_WR_EN 0x8bc
  56. #define PCIE_LINK_CAP 0x7c
  57. #define PCIE_LINK_SPEED_MASK 0xf
  58. #define PCIE_LINK_WIDTH_MASK 0x3f0
  59. #define PCIE_LINK_STA 0x82
  60. #define LTSSM_STATE_MASK 0x3f
  61. #define LTSSM_PCIE_L0 0x11 /* L0 state */
  62. #define PCIE_DBI_SIZE 0x100000 /* 1M */
  63. #define PCIE_LCTRL0_CFG2_ENABLE (1 << 31)
  64. #define PCIE_LCTRL0_VF(vf) ((vf) << 22)
  65. #define PCIE_LCTRL0_PF(pf) ((pf) << 16)
  66. #define PCIE_LCTRL0_VF_ACTIVE (1 << 21)
  67. #define PCIE_LCTRL0_VAL(pf, vf) (PCIE_LCTRL0_PF(pf) | \
  68. PCIE_LCTRL0_VF(vf) | \
  69. ((vf) == 0 ? 0 : PCIE_LCTRL0_VF_ACTIVE) | \
  70. PCIE_LCTRL0_CFG2_ENABLE)
  71. #define PCIE_NO_SRIOV_BAR_BASE 0x1000
  72. #define PCIE_PF_NUM 2
  73. #define PCIE_VF_NUM 64
  74. #define PCIE_BAR0_SIZE (4 * 1024) /* 4K */
  75. #define PCIE_BAR1_SIZE (8 * 1024) /* 8K for MSIX */
  76. #define PCIE_BAR2_SIZE (4 * 1024) /* 4K */
  77. #define PCIE_BAR4_SIZE (1 * 1024 * 1024) /* 1M */
  78. /* LUT registers */
  79. #define PCIE_LUT_UDR(n) (0x800 + (n) * 8)
  80. #define PCIE_LUT_LDR(n) (0x804 + (n) * 8)
  81. #define PCIE_LUT_ENABLE (1 << 31)
  82. #define PCIE_LUT_ENTRY_COUNT 32
  83. /* PF Controll registers */
  84. #define PCIE_PF_CONFIG 0x14
  85. #define PCIE_PF_VF_CTRL 0x7F8
  86. #define PCIE_PF_DBG 0x7FC
  87. #define PCIE_CONFIG_READY (1 << 0)
  88. #define PCIE_SRDS_PRTCL(idx) (PCIE1 + (idx))
  89. #define PCIE_SYS_BASE_ADDR 0x3400000
  90. #define PCIE_CCSR_SIZE 0x0100000
  91. /* CS2 */
  92. #define PCIE_CS2_OFFSET 0x1000 /* For PCIe without SR-IOV */
  93. #define SVR_LS102XA 0
  94. #define SVR_VAR_PER_SHIFT 8
  95. #define SVR_LS102XA_MASK 0x700
  96. #define SVR_LS2088A 0x870900
  97. #define SVR_LS2084A 0x870910
  98. #define SVR_LS2048A 0x870920
  99. #define SVR_LS2044A 0x870930
  100. #define SVR_LS2081A 0x870918
  101. #define SVR_LS2041A 0x870914
  102. /* LS1021a PCIE space */
  103. #define LS1021_PCIE_SPACE_OFFSET 0x4000000000ULL
  104. #define LS1021_PCIE_SPACE_SIZE 0x0800000000ULL
  105. /* LS1021a PEX1/2 Misc Ports Status Register */
  106. #define LS1021_PEXMSCPORTSR(pex_idx) (0x94 + (pex_idx) * 4)
  107. #define LS1021_LTSSM_STATE_SHIFT 20
  108. struct ls_pcie {
  109. int idx;
  110. struct list_head list;
  111. struct udevice *bus;
  112. struct fdt_resource dbi_res;
  113. struct fdt_resource lut_res;
  114. struct fdt_resource ctrl_res;
  115. struct fdt_resource cfg_res;
  116. void __iomem *dbi;
  117. void __iomem *lut;
  118. void __iomem *ctrl;
  119. void __iomem *cfg0;
  120. void __iomem *cfg1;
  121. bool big_endian;
  122. bool enabled;
  123. int next_lut_index;
  124. int stream_id_cur;
  125. int mode;
  126. };
  127. extern struct list_head ls_pcie_list;
  128. #endif /* _PCIE_LAYERSCAPE_H_ */