0057-PCI-designware-Add-default-link-up-check-if-sub-driv.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. From a0a4f406c7e90b2be66e88ea8b21699940c0823f Mon Sep 17 00:00:00 2001
  2. From: Joao Pinto <Joao.Pinto@synopsys.com>
  3. Date: Thu, 10 Mar 2016 14:44:44 -0600
  4. Subject: [PATCH 57/70] PCI: designware: Add default link up check if
  5. sub-driver doesn't override
  6. Add a default DesignWare "link_up" test for use when a sub-driver doesn't
  7. supply its own pcie_host_ops.link_up() method.
  8. [bhelgaas: changelog, split into its own patch]
  9. Signed-off-by: Joao Pinto <jpinto@synopsys.com>
  10. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
  11. Acked-by: Pratyush Anand <pratyush.anand@gmail.com>
  12. ---
  13. drivers/pci/host/pcie-designware.c | 10 +++++++++-
  14. 1 file changed, 9 insertions(+), 1 deletion(-)
  15. --- a/drivers/pci/host/pcie-designware.c
  16. +++ b/drivers/pci/host/pcie-designware.c
  17. @@ -70,6 +70,11 @@
  18. #define PCIE_ATU_FUNC(x) (((x) & 0x7) << 16)
  19. #define PCIE_ATU_UPPER_TARGET 0x91C
  20. +/* PCIe Port Logic registers */
  21. +#define PLR_OFFSET 0x700
  22. +#define PCIE_PHY_DEBUG_R1 (PLR_OFFSET + 0x2c)
  23. +#define PCIE_PHY_DEBUG_R1_LINK_UP 0x00000010
  24. +
  25. static struct pci_ops dw_pcie_ops;
  26. int dw_pcie_cfg_read(void __iomem *addr, int size, u32 *val)
  27. @@ -401,10 +406,13 @@ int dw_pcie_wait_for_link(struct pcie_po
  28. int dw_pcie_link_up(struct pcie_port *pp)
  29. {
  30. + u32 val;
  31. +
  32. if (pp->ops->link_up)
  33. return pp->ops->link_up(pp);
  34. - return 0;
  35. + val = readl(pp->dbi_base + PCIE_PHY_DEBUG_R1);
  36. + return val & PCIE_PHY_DEBUG_R1_LINK_UP;
  37. }
  38. static int dw_pcie_msi_map(struct irq_domain *domain, unsigned int irq,