git: 9ae4c66bff69 - stable/14 - fu740_pci_dw: Fix PERST delay and keep asserted for rest of reset sequence

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Sat, 07 Sep 2024 01:48:12 UTC
The branch stable/14 has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=9ae4c66bff6927dc6fcc855f1aa539a2115b21bd

commit 9ae4c66bff6927dc6fcc855f1aa539a2115b21bd
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2024-06-02 20:42:18 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2024-09-07 01:47:00 +0000

    fu740_pci_dw: Fix PERST delay and keep asserted for rest of reset sequence
    
    DELAY takes microseconds not milliseconds, so 100 was too low. Moreover,
    when enabling hw.pci.clear_pcib, PCI emeration would still stop at one
    of the first bridges, but by asserting PERST for the rest of the reset
    sequence that appears to be reliably addressed.
    
    Fixes:  896e217a0eae ("fu740_pci_dw: Add SiFive FU740 PCIe controller driver")
    
    (cherry picked from commit 28aaa58fa64ecb89d47f0a8396954ad8ca82d8ef)
---
 sys/riscv/sifive/fu740_pci_dw.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sys/riscv/sifive/fu740_pci_dw.c b/sys/riscv/sifive/fu740_pci_dw.c
index fe741f4bb6e6..eff23a294985 100644
--- a/sys/riscv/sifive/fu740_pci_dw.c
+++ b/sys/riscv/sifive/fu740_pci_dw.c
@@ -216,12 +216,6 @@ fupci_phy_init(struct fupci_softc *sc)
 		return (error);
 	}
 
-	/* Hold PERST for 100ms as per the PCIe spec */
-	DELAY(100);
-
-	/* Deassert PERST_N */
-	FUDW_MGMT_WRITE(sc, FUDW_MGMT_PERST_N, 1);
-
 	/* Deassert core power-on reset (active low) */
 	error = gpio_pin_set_active(sc->porst_pin, true);
 	if (error != 0) {
@@ -281,6 +275,12 @@ fupci_phy_init(struct fupci_softc *sc)
 	/* Put the controller in Root Complex mode */
 	FUDW_MGMT_WRITE(sc, FUDW_MGMT_DEVICE_TYPE, FUDW_MGMT_DEVICE_TYPE_RC);
 
+	/* Hold PERST for 100ms as per the PCIe spec */
+	DELAY(100000);
+
+	/* Deassert PERST_N */
+	FUDW_MGMT_WRITE(sc, FUDW_MGMT_PERST_N, 1);
+
 	return (0);
 }