Skip to contentSkip to conversation

PCI: apple: Fix REFCLK1 enable/poll logic

PATCH Applied Hector Martin 3 participants 5 messages Nov 17, 2021 – Dec 6, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: apple: Fix REFCLK1 enable/poll logic

REFCLK1 has req/ack bits just like REFCLK0

---
 drivers/pci/controller/pcie-apple.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/pci/controller/pcie-apple.c +4 -3
index b665d29af77a..420c291a5c68 100644
@@ -42,8 +42,9 @@
 #define   CORE_FABRIC_STAT_MASK		0x001F001F
 #define CORE_LANE_CFG(port)		(0x84000 + 0x4000 * (port))
 #define   CORE_LANE_CFG_REFCLK0REQ	BIT(0)
-#define   CORE_LANE_CFG_REFCLK1		BIT(1)
+#define   CORE_LANE_CFG_REFCLK1REQ	BIT(1)
 #define   CORE_LANE_CFG_REFCLK0ACK	BIT(2)
+#define   CORE_LANE_CFG_REFCLK1ACK	BIT(3)
 #define   CORE_LANE_CFG_REFCLKEN	(BIT(9) | BIT(10))
 #define CORE_LANE_CTL(port)		(0x84004 + 0x4000 * (port))
 #define   CORE_LANE_CTL_CFGACC		BIT(15)
@@ -481,9 +482,9 @@ static int apple_pcie_setup_refclk(struct apple_pcie *pcie,
 	if (res < 0)
 		return res;
 
-	rmw_set(CORE_LANE_CFG_REFCLK1, pcie->base + CORE_LANE_CFG(port->idx));
+	rmw_set(CORE_LANE_CFG_REFCLK1REQ, pcie->base + CORE_LANE_CFG(port->idx));
 	res = readl_relaxed_poll_timeout(pcie->base + CORE_LANE_CFG(port->idx),
-					 stat, stat & CORE_LANE_CFG_REFCLK1,
+					 stat, stat & CORE_LANE_CFG_REFCLK1ACK,
 					 100, 50000);
 
 	if (res < 0)
Signature · 1 line
2.33.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 39 lines · Hector Martin

REFCLK1 has req/ack bits just like REFCLK0

---
 drivers/pci/controller/pcie-apple.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/pci/controller/pcie-apple.c +4 -3
index b665d29af77a..420c291a5c68 100644
@@ -42,8 +42,9 @@
 #define   CORE_FABRIC_STAT_MASK		0x001F001F
 #define CORE_LANE_CFG(port)		(0x84000 + 0x4000 * (port))
 #define   CORE_LANE_CFG_REFCLK0REQ	BIT(0)
-#define   CORE_LANE_CFG_REFCLK1		BIT(1)
+#define   CORE_LANE_CFG_REFCLK1REQ	BIT(1)
 #define   CORE_LANE_CFG_REFCLK0ACK	BIT(2)
+#define   CORE_LANE_CFG_REFCLK1ACK	BIT(3)
 #define   CORE_LANE_CFG_REFCLKEN	(BIT(9) | BIT(10))
 #define CORE_LANE_CTL(port)		(0x84004 + 0x4000 * (port))
 #define   CORE_LANE_CTL_CFGACC		BIT(15)
@@ -481,9 +482,9 @@ static int apple_pcie_setup_refclk(struct apple_pcie *pcie,
 	if (res < 0)
 		return res;
 
-	rmw_set(CORE_LANE_CFG_REFCLK1, pcie->base + CORE_LANE_CFG(port->idx));
+	rmw_set(CORE_LANE_CFG_REFCLK1REQ, pcie->base + CORE_LANE_CFG(port->idx));
 	res = readl_relaxed_poll_timeout(pcie->base + CORE_LANE_CFG(port->idx),
-					 stat, stat & CORE_LANE_CFG_REFCLK1,
+					 stat, stat & CORE_LANE_CFG_REFCLK1ACK,
 					 100, 50000);
 
 	if (res < 0)
Signature · 1 line
2.33.0
Fixes 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")
	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#2 lore raw
Quoted 36 lines · Marc Zyngier
Quoted 34 lines · Hector Martin

REFCLK1 has req/ack bits just like REFCLK0

---
 drivers/pci/controller/pcie-apple.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/pci/controller/pcie-apple.c +4 -3
index b665d29af77a..420c291a5c68 100644
@@ -42,8 +42,9 @@
 #define   CORE_FABRIC_STAT_MASK		0x001F001F
 #define CORE_LANE_CFG(port)		(0x84000 + 0x4000 * (port))
 #define   CORE_LANE_CFG_REFCLK0REQ	BIT(0)
-#define   CORE_LANE_CFG_REFCLK1		BIT(1)
+#define   CORE_LANE_CFG_REFCLK1REQ	BIT(1)
 #define   CORE_LANE_CFG_REFCLK0ACK	BIT(2)
+#define   CORE_LANE_CFG_REFCLK1ACK	BIT(3)
 #define   CORE_LANE_CFG_REFCLKEN	(BIT(9) | BIT(10))
 #define CORE_LANE_CTL(port)		(0x84004 + 0x4000 * (port))
 #define   CORE_LANE_CTL_CFGACC		BIT(15)
@@ -481,9 +482,9 @@ static int apple_pcie_setup_refclk(struct apple_pcie *pcie,
 	if (res < 0)
 		return res;
 
-	rmw_set(CORE_LANE_CFG_REFCLK1, pcie->base + CORE_LANE_CFG(port->idx));
+	rmw_set(CORE_LANE_CFG_REFCLK1REQ, pcie->base + CORE_LANE_CFG(port->idx));
 	res = readl_relaxed_poll_timeout(pcie->base + CORE_LANE_CFG(port->idx),
-					 stat, stat & CORE_LANE_CFG_REFCLK1,
+					 stat, stat & CORE_LANE_CFG_REFCLK1ACK,
 					 100, 50000);
 
Quoted 8 lines
Quoted 5 lines
drivers/pci/controller/pcie-apple.c +0 -0
 	if (res < 0)
Signature · 1 line
2.33.0
Fixes 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")

Hi Hector, Bjorn,

if this is a fix we can aim at one of the upcoming -rcX.

It would be nicer though to explain a bit better what it is fixing in the commit log (and what's broken if we don't merge it), as it stands it is a bit terse.

Thanks,
Lorenzo

#3 lore raw
Quoted 46 lines · Lorenzo Pieralisi
Quoted 36 lines · Marc Zyngier
Quoted 34 lines · Hector Martin

REFCLK1 has req/ack bits just like REFCLK0

---
  drivers/pci/controller/pcie-apple.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/pci/controller/pcie-apple.c +4 -3
index b665d29af77a..420c291a5c68 100644
@@ -42,8 +42,9 @@
  #define   CORE_FABRIC_STAT_MASK		0x001F001F
  #define CORE_LANE_CFG(port)		(0x84000 + 0x4000 * (port))
  #define   CORE_LANE_CFG_REFCLK0REQ	BIT(0)
-#define   CORE_LANE_CFG_REFCLK1		BIT(1)
+#define   CORE_LANE_CFG_REFCLK1REQ	BIT(1)
  #define   CORE_LANE_CFG_REFCLK0ACK	BIT(2)
+#define   CORE_LANE_CFG_REFCLK1ACK	BIT(3)
  #define   CORE_LANE_CFG_REFCLKEN	(BIT(9) | BIT(10))
  #define CORE_LANE_CTL(port)		(0x84004 + 0x4000 * (port))
  #define   CORE_LANE_CTL_CFGACC		BIT(15)
@@ -481,9 +482,9 @@ static int apple_pcie_setup_refclk(struct apple_pcie *pcie,
  	if (res < 0)
  		return res;
 
-	rmw_set(CORE_LANE_CFG_REFCLK1, pcie->base + CORE_LANE_CFG(port->idx));
+	rmw_set(CORE_LANE_CFG_REFCLK1REQ, pcie->base + CORE_LANE_CFG(port->idx));
  	res = readl_relaxed_poll_timeout(pcie->base + CORE_LANE_CFG(port->idx),
-					 stat, stat & CORE_LANE_CFG_REFCLK1,
+					 stat, stat & CORE_LANE_CFG_REFCLK1ACK,
  					 100, 50000);
 
Quoted 8 lines
Quoted 5 lines
drivers/pci/controller/pcie-apple.c +0 -0
  	if (res < 0)
Signature · 1 line
2.33.0
Fixes 1e33888fbe44 ("PCI: apple: Add initial hardware bring-up")
Quoted 7 lines

Hi Hector, Bjorn,

if this is a fix we can aim at one of the upcoming -rcX.

It would be nicer though to explain a bit better what it is fixing in the commit log (and what's broken if we don't merge it), as it stands it is a bit terse.

I don't think anything is broken per se, it still works without this patch (probably because the refclk gets enabled fast enough that we don't have to wait for it); it's just that I think this is the correct logic. This is all reverse engineered anyway, so ultimately there is no hardware documentation to point to to say what's right and what's wrong...

Signature · 2 lines
Hector Martin ([email protected])
Public Key: https://mrcn.st/pub