0071-5-PCI-qcom-Programming-the-PCIE-iATU-for-IPQ806x.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. From d27c303e828d7e42f339a459d2abfe30c51698e9 Mon Sep 17 00:00:00 2001
  2. From: Sham Muthayyan <[email protected]>
  3. Date: Tue, 26 Jul 2016 12:28:31 +0530
  4. Subject: PCI: qcom: Programming the PCIE iATU for IPQ806x
  5. Resolved PCIE EP detection errors caused due to missing iATU programming.
  6. Change-Id: Ie95c0f8cb940abc0192a8a3c4e825ddba54b72fe
  7. Signed-off-by: Sham Muthayyan <[email protected]>
  8. ---
  9. drivers/pci/host/pcie-qcom.c | 77 ++++++++++++++++++++++++++++++++++++++++++++
  10. 1 file changed, 77 insertions(+)
  11. --- a/drivers/pci/dwc/pcie-qcom.c
  12. +++ b/drivers/pci/dwc/pcie-qcom.c
  13. @@ -83,6 +83,30 @@
  14. #define PCIE20_CAP_LINK_1 (PCIE20_CAP + 0x14)
  15. #define PCIE_CAP_LINK1_VAL 0x2FD7F
  16. +#define PCIE20_CAP_LINKCTRLSTATUS (PCIE20_CAP + 0x10)
  17. +
  18. +#define PCIE20_AXI_MSTR_RESP_COMP_CTRL0 0x818
  19. +#define PCIE20_AXI_MSTR_RESP_COMP_CTRL1 0x81c
  20. +
  21. +#define PCIE20_PLR_IATU_VIEWPORT 0x900
  22. +#define PCIE20_PLR_IATU_REGION_OUTBOUND (0x0 << 31)
  23. +#define PCIE20_PLR_IATU_REGION_INDEX(x) (x << 0)
  24. +
  25. +#define PCIE20_PLR_IATU_CTRL1 0x904
  26. +#define PCIE20_PLR_IATU_TYPE_CFG0 (0x4 << 0)
  27. +#define PCIE20_PLR_IATU_TYPE_MEM (0x0 << 0)
  28. +
  29. +#define PCIE20_PLR_IATU_CTRL2 0x908
  30. +#define PCIE20_PLR_IATU_ENABLE BIT(31)
  31. +
  32. +#define PCIE20_PLR_IATU_LBAR 0x90C
  33. +#define PCIE20_PLR_IATU_UBAR 0x910
  34. +#define PCIE20_PLR_IATU_LAR 0x914
  35. +#define PCIE20_PLR_IATU_LTAR 0x918
  36. +#define PCIE20_PLR_IATU_UTAR 0x91c
  37. +
  38. +#define MSM_PCIE_DEV_CFG_ADDR 0x01000000
  39. +
  40. #define PCIE20_PARF_Q2A_FLUSH 0x1AC
  41. #define PCIE20_MISC_CONTROL_1_REG 0x8BC
  42. @@ -251,6 +275,57 @@ static void qcom_pcie_2_1_0_ltssm_enable
  43. writel(val, pcie->elbi + PCIE20_ELBI_SYS_CTRL);
  44. }
  45. +static void qcom_pcie_prog_viewport_cfg0(struct qcom_pcie *pcie, u32 busdev)
  46. +{
  47. + struct pcie_port *pp = &pcie->pci->pp;
  48. +
  49. + /*
  50. + * program and enable address translation region 0 (device config
  51. + * address space); region type config;
  52. + * axi config address range to device config address range
  53. + */
  54. + writel(PCIE20_PLR_IATU_REGION_OUTBOUND |
  55. + PCIE20_PLR_IATU_REGION_INDEX(0),
  56. + pcie->pci->dbi_base + PCIE20_PLR_IATU_VIEWPORT);
  57. +
  58. + writel(PCIE20_PLR_IATU_TYPE_CFG0, pcie->pci->dbi_base + PCIE20_PLR_IATU_CTRL1);
  59. + writel(PCIE20_PLR_IATU_ENABLE, pcie->pci->dbi_base + PCIE20_PLR_IATU_CTRL2);
  60. + writel(pp->cfg0_base, pcie->pci->dbi_base + PCIE20_PLR_IATU_LBAR);
  61. + writel((pp->cfg0_base >> 32), pcie->pci->dbi_base + PCIE20_PLR_IATU_UBAR);
  62. + writel((pp->cfg0_base + pp->cfg0_size - 1),
  63. + pcie->pci->dbi_base + PCIE20_PLR_IATU_LAR);
  64. + writel(busdev, pcie->pci->dbi_base + PCIE20_PLR_IATU_LTAR);
  65. + writel(0, pcie->pci->dbi_base + PCIE20_PLR_IATU_UTAR);
  66. +}
  67. +
  68. +static void qcom_pcie_prog_viewport_mem2_outbound(struct qcom_pcie *pcie)
  69. +{
  70. + struct pcie_port *pp = &pcie->pci->pp;
  71. +
  72. + /*
  73. + * program and enable address translation region 2 (device resource
  74. + * address space); region type memory;
  75. + * axi device bar address range to device bar address range
  76. + */
  77. + writel(PCIE20_PLR_IATU_REGION_OUTBOUND |
  78. + PCIE20_PLR_IATU_REGION_INDEX(2),
  79. + pcie->pci->dbi_base + PCIE20_PLR_IATU_VIEWPORT);
  80. +
  81. + writel(PCIE20_PLR_IATU_TYPE_MEM, pcie->pci->dbi_base + PCIE20_PLR_IATU_CTRL1);
  82. + writel(PCIE20_PLR_IATU_ENABLE, pcie->pci->dbi_base + PCIE20_PLR_IATU_CTRL2);
  83. + writel(pp->mem_base, pcie->pci->dbi_base + PCIE20_PLR_IATU_LBAR);
  84. + writel((pp->mem_base >> 32), pcie->pci->dbi_base + PCIE20_PLR_IATU_UBAR);
  85. + writel(pp->mem_base + pp->mem_size - 1,
  86. + pcie->pci->dbi_base + PCIE20_PLR_IATU_LAR);
  87. + writel(pp->mem_bus_addr, pcie->pci->dbi_base + PCIE20_PLR_IATU_LTAR);
  88. + writel(upper_32_bits(pp->mem_bus_addr),
  89. + pcie->pci->dbi_base + PCIE20_PLR_IATU_UTAR);
  90. +
  91. + /* 256B PCIE buffer setting */
  92. + writel(0x1, pcie->pci->dbi_base + PCIE20_AXI_MSTR_RESP_COMP_CTRL0);
  93. + writel(0x1, pcie->pci->dbi_base + PCIE20_AXI_MSTR_RESP_COMP_CTRL1);
  94. +}
  95. +
  96. static int qcom_pcie_get_resources_2_1_0(struct qcom_pcie *pcie)
  97. {
  98. struct qcom_pcie_resources_2_1_0 *res = &pcie->res.v2_1_0;
  99. @@ -465,6 +540,9 @@ static int qcom_pcie_init_2_1_0(struct q
  100. writel(CFG_BRIDGE_SB_INIT,
  101. pci->dbi_base + PCIE20_AXI_MSTR_RESP_COMP_CTRL1);
  102. + qcom_pcie_prog_viewport_cfg0(pcie, MSM_PCIE_DEV_CFG_ADDR);
  103. + qcom_pcie_prog_viewport_mem2_outbound(pcie);
  104. +
  105. return 0;
  106. err_deassert_ahb: