[PATCH v2] PCI: spacemit: Ignore PERST# input in RC mode on K1

Encrow Thorne encrow.thorne at linux.spacemit.com
Thu Nov 5 18:13:53 PST 2026


In RC mode, the K1 PERST# pad input also affects the local controller.
Without PCIE_IGNORE_PERSTN set, asserting PERST# to reset the endpoint
also resets the RC, losing previously programmed register values,
including the vendor and device IDs.

Set PCIE_IGNORE_PERSTN during RC initialization to prevent this
feedback. Set it before the first DBI access, since PERST# may already
be low when initialization starts, causing the access to hang.

Fixes: ff64e078e45f ("PCI: spacemit: Add SpacemiT PCIe host driver")
Reported-by: Bruno Banelli <bbanelli at gmail.com>
Link: https://lore.kernel.org/all/20260825052249.66921-1-bbanelli@gmail.com/
Signed-off-by: Encrow Thorne <encrow.thorne at linux.spacemit.com>
---
Changes in v2:
- Rebase onto v7.4-rc1.
- Explain the PERST# pad input feedback into the local RC.
- Use PERST# in the subject, commit log and code comment.
- Add Fixes, Reported-by and Link tags.
- Link to v1: https://lore.kernel.org/r/20260924-spacemit-k1-pcie-fix-v1-1-002b5c1ba9fc@linux.spacemit.com
---
 drivers/pci/controller/dwc/pcie-spacemit-k1.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/pci/controller/dwc/pcie-spacemit-k1.c b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
index 92a71ea90ac3..bb60a35c2885 100644
--- a/drivers/pci/controller/dwc/pcie-spacemit-k1.c
+++ b/drivers/pci/controller/dwc/pcie-spacemit-k1.c
@@ -47,6 +47,7 @@
 
 #define PCIE_CONTROL_LOGIC			0x0004
 #define PCIE_SOFT_RESET			BIT(0)
+#define PCIE_IGNORE_PERSTN			BIT(2)
 
 struct k1_pcie {
 	struct dw_pcie pci;
@@ -140,6 +141,13 @@ static int k1_pcie_init(struct dw_pcie_rp *pp)
 	if (ret)
 		return ret;
 
+	/*
+	 * Ignore the PERST# pad input in RC mode so asserting PERST# to
+	 * reset the endpoint does not also reset the local controller.
+	 */
+	regmap_set_bits(k1->pmu, k1->pmu_off + PCIE_CONTROL_LOGIC,
+			PCIE_IGNORE_PERSTN);
+
 	/* Set the PCI vendor and device ID */
 	dw_pcie_dbi_ro_wr_en(pci);
 	dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, PCI_VENDOR_ID_SPACEMIT);

---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20260921-spacemit-k1-pcie-fix-256ffa8d382d

Best regards,
-- 
Encrow Thorne <encrow.thorne at linux.spacemit.com>




More information about the linux-riscv mailing list