143-PCI-iproc-Fix-PCIe-reset-logic.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. From 199ff14100095d52cd1b232cc0f3b12f348b5b07 Mon Sep 17 00:00:00 2001
  2. From: Ray Jui <rjui@broadcom.com>
  3. Date: Tue, 15 Sep 2015 17:39:18 -0700
  4. Subject: [PATCH 143/147] PCI: iproc: Fix PCIe reset logic
  5. The current reset logic does not always properly reset the device. For
  6. example, in the case when the perst_b signal is already de-asserted in the
  7. bootloader, the current reset logic fails to trigger a proper assert ->
  8. de-assert reset sequence.
  9. Fix the issue by always triggering the proper reset sequence.
  10. Also explicitly select the desired reset source, i.e., perst_b, and reduce
  11. the wait time after the device comes out of reset from 250 ms to 100 ms,
  12. based on recommendation from the ASIC team.
  13. Tested-by: Vladimir Dreizin <vdreizin@broadcom.com>
  14. Tested-by: Darren Edamura <dedamura@broadcom.com>
  15. Signed-off-by: Ray Jui <rjui@broadcom.com>
  16. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
  17. Reviewed-by: Vladimir Dreizin <vdreizin@broadcom.com>
  18. Reviewed-by: Trac Hoang <trhoang@broadcom.com>
  19. Reviewed-by: Scott Branden <sbranden@broadcom.com>
  20. ---
  21. drivers/pci/host/pcie-iproc.c | 15 ++++++++++-----
  22. 1 file changed, 10 insertions(+), 5 deletions(-)
  23. --- a/drivers/pci/host/pcie-iproc.c
  24. +++ b/drivers/pci/host/pcie-iproc.c
  25. @@ -31,6 +31,8 @@
  26. #include "pcie-iproc.h"
  27. #define CLK_CONTROL_OFFSET 0x000
  28. +#define EP_PERST_SOURCE_SELECT_SHIFT 2
  29. +#define EP_PERST_SOURCE_SELECT BIT(EP_PERST_SOURCE_SELECT_SHIFT)
  30. #define EP_MODE_SURVIVE_PERST_SHIFT 1
  31. #define EP_MODE_SURVIVE_PERST BIT(EP_MODE_SURVIVE_PERST_SHIFT)
  32. #define RC_PCIE_RST_OUTPUT_SHIFT 0
  33. @@ -119,15 +121,18 @@ static void iproc_pcie_reset(struct ipro
  34. u32 val;
  35. /*
  36. - * Configure the PCIe controller as root complex and send a downstream
  37. - * reset
  38. + * Select perst_b signal as reset source. Put the device into reset,
  39. + * and then bring it out of reset
  40. */
  41. - val = EP_MODE_SURVIVE_PERST | RC_PCIE_RST_OUTPUT;
  42. + val = readl(pcie->base + CLK_CONTROL_OFFSET);
  43. + val &= ~EP_PERST_SOURCE_SELECT & ~EP_MODE_SURVIVE_PERST &
  44. + ~RC_PCIE_RST_OUTPUT;
  45. writel(val, pcie->base + CLK_CONTROL_OFFSET);
  46. udelay(250);
  47. - val &= ~EP_MODE_SURVIVE_PERST;
  48. +
  49. + val |= RC_PCIE_RST_OUTPUT;
  50. writel(val, pcie->base + CLK_CONTROL_OFFSET);
  51. - msleep(250);
  52. + msleep(100);
  53. }
  54. static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus)