0058-PCI-designware-Move-Root-Complex-setup-code-to-dw_pc.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. From 892a427f8a2b25b561298941cf1fc0373a98b269 Mon Sep 17 00:00:00 2001
  2. From: Jisheng Zhang <jszhang@marvell.com>
  3. Date: Wed, 16 Mar 2016 19:40:33 +0800
  4. Subject: [PATCH 58/70] PCI: designware: Move Root Complex setup code to
  5. dw_pcie_setup_rc()
  6. dw_pcie_host_init() looks up host bridge resources, ioremaps them, creates
  7. IRQ domains, and enumerates devices below the bridge. dw_pcie_setup_rc()
  8. programs the Root Complex registers. The Root Complex may lose power
  9. during suspend-to-RAM, and when we resume, we want to redo the latter but
  10. not the former.
  11. Move some Root Complex programming from dw_pcie_host_init() to
  12. dw_pcie_setup_rc() where it belongs. DesignWare-based drivers can call
  13. dw_pcie_setup_rc() in their resume paths.
  14. [Niklas Cassel <niklas.cassel@axis.com>: This change moves outbound ATU
  15. programming, which uses pp->mem_base, to dw_pcie_setup_rc(). Apply the
  16. dra7xx pp->mem_base update before calling dw_pcie_setup_rc().]
  17. [bhelgaas: changelog, fold in dra7xx fix from Niklas]
  18. Signed-off-by: Jisheng Zhang <jszhang@marvell.com>
  19. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
  20. Acked-by: Pratyush Anand <pratyush.anand@gmail.com>
  21. ---
  22. drivers/pci/host/pci-dra7xx.c | 4 ++--
  23. drivers/pci/host/pcie-designware.c | 39 ++++++++++++++++++------------------
  24. 2 files changed, 21 insertions(+), 22 deletions(-)
  25. --- a/drivers/pci/host/pci-dra7xx.c
  26. +++ b/drivers/pci/host/pci-dra7xx.c
  27. @@ -142,13 +142,13 @@ static void dra7xx_pcie_enable_interrupt
  28. static void dra7xx_pcie_host_init(struct pcie_port *pp)
  29. {
  30. - dw_pcie_setup_rc(pp);
  31. -
  32. pp->io_base &= DRA7XX_CPU_TO_BUS_ADDR;
  33. pp->mem_base &= DRA7XX_CPU_TO_BUS_ADDR;
  34. pp->cfg0_base &= DRA7XX_CPU_TO_BUS_ADDR;
  35. pp->cfg1_base &= DRA7XX_CPU_TO_BUS_ADDR;
  36. + dw_pcie_setup_rc(pp);
  37. +
  38. dra7xx_pcie_establish_link(pp);
  39. if (IS_ENABLED(CONFIG_PCI_MSI))
  40. dw_pcie_msi_init(pp);
  41. --- a/drivers/pci/host/pcie-designware.c
  42. +++ b/drivers/pci/host/pcie-designware.c
  43. @@ -434,7 +434,6 @@ int dw_pcie_host_init(struct pcie_port *
  44. struct platform_device *pdev = to_platform_device(pp->dev);
  45. struct pci_bus *bus, *child;
  46. struct resource *cfg_res;
  47. - u32 val;
  48. int i, ret;
  49. LIST_HEAD(res);
  50. struct resource_entry *win;
  51. @@ -544,25 +543,6 @@ int dw_pcie_host_init(struct pcie_port *
  52. if (pp->ops->host_init)
  53. pp->ops->host_init(pp);
  54. - /*
  55. - * If the platform provides ->rd_other_conf, it means the platform
  56. - * uses its own address translation component rather than ATU, so
  57. - * we should not program the ATU here.
  58. - */
  59. - if (!pp->ops->rd_other_conf)
  60. - dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX1,
  61. - PCIE_ATU_TYPE_MEM, pp->mem_base,
  62. - pp->mem_bus_addr, pp->mem_size);
  63. -
  64. - dw_pcie_wr_own_conf(pp, PCI_BASE_ADDRESS_0, 4, 0);
  65. -
  66. - /* program correct class for RC */
  67. - dw_pcie_wr_own_conf(pp, PCI_CLASS_DEVICE, 2, PCI_CLASS_BRIDGE_PCI);
  68. -
  69. - dw_pcie_rd_own_conf(pp, PCIE_LINK_WIDTH_SPEED_CONTROL, 4, &val);
  70. - val |= PORT_LOGIC_SPEED_CHANGE;
  71. - dw_pcie_wr_own_conf(pp, PCIE_LINK_WIDTH_SPEED_CONTROL, 4, val);
  72. -
  73. pp->root_bus_nr = pp->busn->start;
  74. if (IS_ENABLED(CONFIG_PCI_MSI)) {
  75. bus = pci_scan_root_bus_msi(pp->dev, pp->root_bus_nr,
  76. @@ -800,6 +780,25 @@ void dw_pcie_setup_rc(struct pcie_port *
  77. val |= PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
  78. PCI_COMMAND_MASTER | PCI_COMMAND_SERR;
  79. dw_pcie_writel_rc(pp, val, PCI_COMMAND);
  80. +
  81. + /*
  82. + * If the platform provides ->rd_other_conf, it means the platform
  83. + * uses its own address translation component rather than ATU, so
  84. + * we should not program the ATU here.
  85. + */
  86. + if (!pp->ops->rd_other_conf)
  87. + dw_pcie_prog_outbound_atu(pp, PCIE_ATU_REGION_INDEX1,
  88. + PCIE_ATU_TYPE_MEM, pp->mem_base,
  89. + pp->mem_bus_addr, pp->mem_size);
  90. +
  91. + dw_pcie_wr_own_conf(pp, PCI_BASE_ADDRESS_0, 4, 0);
  92. +
  93. + /* program correct class for RC */
  94. + dw_pcie_wr_own_conf(pp, PCI_CLASS_DEVICE, 2, PCI_CLASS_BRIDGE_PCI);
  95. +
  96. + dw_pcie_rd_own_conf(pp, PCIE_LINK_WIDTH_SPEED_CONTROL, 4, &val);
  97. + val |= PORT_LOGIC_SPEED_CHANGE;
  98. + dw_pcie_wr_own_conf(pp, PCIE_LINK_WIDTH_SPEED_CONTROL, 4, val);
  99. }
  100. MODULE_AUTHOR("Jingoo Han <jg1.han@samsung.com>");