Skip to contentSkip to conversation

Add L1 substates support for Rockchip platforms

PATCH In review Shawn Lin 5 participants 17 messages Oct 21, 2025 – Oct 22, 2025

Subsystems (5)
lore
Share & tools
lore

Shawn Lin

author
#0 lore raw

cover Add L1 substates support for Rockchip platforms

This patch-set adds ASPM L1 substates support for Rockchip platform. As supports-clkreq is used by some more host drivers, patch 1 creates of_pci_clkreq_present() and patch 2 reuse it. Patch 3 enables or disables L1 substates on Rockchip driver by checking if clkreq# is ready. Patch 4 enable L1 substates on RK3588-EVB1.

This series of patches is tested on RK3588-EVB1 with a NVMe connected to the pcie3x4 slot(actually I tested several NVMes), A RTL8111 NIC card connected pcie2x1l1 and a broadcom Wi-Fi connected to pcie2x1l0. All works fine under L1 substates by checking the LTSSM.

Shawn Lin (1):
arm64: dts: rockchip: Add PCIe clkreq stuff for RK3588 EVB1
PCI: dw-rockchip: Add L1sub support
PCI: tegra194: Use of_pci_clkreq_present() instead
PCI: of: Add of_pci_clkreq_present()

 arch/arm64/boot/dts/rockchip/rk3588-evb1-v10.dts | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
Signature · 7 lines
2.7.4


_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip
author
#1 lore raw

PATCH 1/4 PCI: of: Add of_pci_clkreq_present()

of_pci_clkreq_present() is used by host drivers to decide whether the clkreq# is properly connected and could enable L1.1/L1.2 support.

---
 drivers/pci/of.c  | 18 ++++++++++++++++++
 drivers/pci/pci.h |  6 ++++++
 2 files changed, 24 insertions(+)
drivers/pci/of.c +18 -0
index 3579265f1198..52c6d365083b 100644
@@ -1010,3 +1010,21 @@ int of_pci_get_equalization_presets(struct device *dev,
 	return 0;
 }
 EXPORT_SYMBOL_GPL(of_pci_get_equalization_presets);
+
+/**
+ * of_pci_clkreq_present() - Check if the "supports-clkreq" is present
+ * @np: Device tree node
+ *
+ * If the property is present, it means CLKREQ# is properly connected
+ * and the hardware is ready to support L1.1/L1.2
+ *
+ * Return: true if the property is available, false otherwise.
+ */
+bool of_pci_clkreq_present(struct device_node *np)
+{
+	if (!np)
+		return false;
+
+	return of_property_present(np, "supports-clkreq");
+}
+EXPORT_SYMBOL_GPL(of_pci_clkreq_present);
drivers/pci/pci.h +6 -0
index 4492b809094b..2421e39e6e48 100644
@@ -1061,6 +1061,7 @@ bool of_pci_supply_present(struct device_node *np);
 int of_pci_get_equalization_presets(struct device *dev,
 				    struct pci_eq_presets *presets,
 				    int num_lanes);
+bool of_pci_clkreq_present(struct device_node *np);
 #else
 static inline int
 of_get_pci_domain_nr(struct device_node *node)
@@ -1106,6 +1107,11 @@ static inline bool of_pci_supply_present(struct device_node *np)
 	return false;
 }
 
+static inline bool of_pci_clkreq_present(struct device_node *np)
+{
+	return false;
+}
+
 static inline int of_pci_get_equalization_presets(struct device *dev,
 						  struct pci_eq_presets *presets,
 						  int num_lanes)
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/4] PCI: of: Add of_pci_clkreq_present()

Quoted 25 lines · Shawn Lin

of_pci_clkreq_present() is used by host drivers to decide whether the clkreq# is properly connected and could enable L1.1/L1.2 support.

---
 drivers/pci/of.c  | 18 ++++++++++++++++++
 drivers/pci/pci.h |  6 ++++++
 2 files changed, 24 insertions(+)
drivers/pci/of.c +8 -0
index 3579265f1198..52c6d365083b 100644
@@ -1010,3 +1010,21 @@ int of_pci_get_equalization_presets(struct device *dev,
 	return 0;
 }
 EXPORT_SYMBOL_GPL(of_pci_get_equalization_presets);
+
+/**
+ * of_pci_clkreq_present() - Check if the "supports-clkreq" is present
+ * @np: Device tree node
+ *
+ * If the property is present, it means CLKREQ# is properly connected
+ * and the hardware is ready to support L1.1/L1.2
+ *

drivers/pci/of.c int of_pci_get_equalization_presets(struct device *dev, · line 1030

Quoted 10 lines
drivers/pci/of.c +10 -0
+ * Return: true if the property is available, false otherwise.
+ */
+bool of_pci_clkreq_present(struct device_node *np)
+{
+	if (!np)
+		return false;
+
+	return of_property_present(np, "supports-clkreq");
+}
+EXPORT_SYMBOL_GPL(of_pci_clkreq_present);

This helper function is quite small. I suggest direct put inline function into pci.h to keep simple.

static inline bool of_pci_clkreq_present(struct device_node *np)

{
	return np && of_property_present(np, "supports-clkreq");
}

Frank

Quoted 27 lines
drivers/pci/pci.h +6 -1
index 4492b809094b..2421e39e6e48 100644
@@ -1061,6 +1061,7 @@ bool of_pci_supply_present(struct device_node *np);
 int of_pci_get_equalization_presets(struct device *dev,
 				    struct pci_eq_presets *presets,
 				    int num_lanes);
+bool of_pci_clkreq_present(struct device_node *np);
 #else
 static inline int
 of_get_pci_domain_nr(struct device_node *node)
@@ -1106,6 +1107,11 @@ static inline bool of_pci_supply_present(struct device_node *np)
 	return false;
 }
 
+static inline bool of_pci_clkreq_present(struct device_node *np)
+{
+	return false;
+}
+
 static inline int of_pci_get_equalization_presets(struct device *dev,
 						  struct pci_eq_presets *presets,
 						  int num_lanes)
--

2.43.0

author
#3 lore raw

Re: [PATCH 1/4] PCI: of: Add of_pci_clkreq_present()

Quoted 31 lines · Frank Li
Quoted 30 lines · Shawn Lin

of_pci_clkreq_present() is used by host drivers to decide whether the clkreq# is properly connected and could enable L1.1/L1.2 support.

---
  drivers/pci/of.c  | 18 ++++++++++++++++++
  drivers/pci/pci.h |  6 ++++++
  2 files changed, 24 insertions(+)
drivers/pci/of.c +13 -0
index 3579265f1198..52c6d365083b 100644
@@ -1010,3 +1010,21 @@ int of_pci_get_equalization_presets(struct device *dev,
  	return 0;
  }
  EXPORT_SYMBOL_GPL(of_pci_get_equalization_presets);
+
+/**
+ * of_pci_clkreq_present() - Check if the "supports-clkreq" is present
+ * @np: Device tree node
+ *
+ * If the property is present, it means CLKREQ# is properly connected
+ * and the hardware is ready to support L1.1/L1.2
+ *
+ * Return: true if the property is available, false otherwise.
+ */
+bool of_pci_clkreq_present(struct device_node *np)
+{
+	if (!np)
Quoted 8 lines

drivers/pci/of.c int of_pci_get_equalization_presets(struct device *dev, · line 1030

Quoted 5 lines
drivers/pci/of.c +5 -0
+		return false;
+
+	return of_property_present(np, "supports-clkreq");
+}
+EXPORT_SYMBOL_GPL(of_pci_clkreq_present);

This helper function is quite small. I suggest direct put inline function into pci.h to keep simple.

Sounds reasonable, will wait for other comments and fix your comment together in V2.

Quoted 41 lines

static inline bool of_pci_clkreq_present(struct device_node *np)

{
	return np && of_property_present(np, "supports-clkreq");
}

Frank

Quoted 25 lines
drivers/pci/pci.h +6 -1
index 4492b809094b..2421e39e6e48 100644
@@ -1061,6 +1061,7 @@ bool of_pci_supply_present(struct device_node *np);
  int of_pci_get_equalization_presets(struct device *dev,
  				    struct pci_eq_presets *presets,
  				    int num_lanes);
+bool of_pci_clkreq_present(struct device_node *np);
  #else
  static inline int
  of_get_pci_domain_nr(struct device_node *node)
@@ -1106,6 +1107,11 @@ static inline bool of_pci_supply_present(struct device_node *np)
  	return false;
  }
 
+static inline bool of_pci_clkreq_present(struct device_node *np)
+{
+	return false;
+}
+
  static inline int of_pci_get_equalization_presets(struct device *dev,
  						  struct pci_eq_presets *presets,
  						  int num_lanes)
--
Quoted 2 lines

2.43.0

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

#4 lore raw

Re: [PATCH 1/4] PCI: of: Add of_pci_clkreq_present()

In reply to Shawn Lin
Quoted 14 lines · Shawn Lin

of_pci_clkreq_present() is used by host drivers to decide whether the clkreq# is properly connected and could enable L1.1/L1.2 support.

---
 drivers/pci/of.c  | 18 ++++++++++++++++++
 drivers/pci/pci.h |  6 ++++++
 2 files changed, 24 insertions(+)
drivers/pci/of.c +0 -0
index 3579265f1198..52c6d365083b 100644

drivers/pci/of.c int of_pci_get_equalization_presets(struct device *dev, · line 1015

Quoted 6 lines
drivers/pci/of.c +3 -0
@@ -1010,3 +1010,21 @@ int of_pci_get_equalization_presets(struct device *dev,
 	return 0;
 }
 EXPORT_SYMBOL_GPL(of_pci_get_equalization_presets);
+
+/**
+ * of_pci_clkreq_present() - Check if the "supports-clkreq" is present

I don't see a benefit of this API, tbh. The API name creates an impression that the API will check for the presence of CLKREQ# signal in DT, but it checks for the presence of the 'supports-clkreq' property. Even though the presence of the property implies that the CLKREQ# routing is available, I'd prefer to check for the property explicitly instead of hiding it inside this API.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
author
#5 lore raw

Re: [PATCH 1/4] PCI: of: Add of_pci_clkreq_present()

Hi Mani

Quoted 19 lines · Manivannan Sadhasivam
Quoted 18 lines · Shawn Lin

of_pci_clkreq_present() is used by host drivers to decide whether the clkreq# is properly connected and could enable L1.1/L1.2 support.

---
  drivers/pci/of.c  | 18 ++++++++++++++++++
  drivers/pci/pci.h |  6 ++++++
  2 files changed, 24 insertions(+)
drivers/pci/of.c +1 -0
index 3579265f1198..52c6d365083b 100644
@@ -1010,3 +1010,21 @@ int of_pci_get_equalization_presets(struct device *dev,
  	return 0;
  }
  EXPORT_SYMBOL_GPL(of_pci_get_equalization_presets);
+
Quoted 8 lines

drivers/pci/of.c int of_pci_get_equalization_presets(struct device *dev, · line 1015

Quoted 2 lines
drivers/pci/of.c +2 -0
+/**
+ * of_pci_clkreq_present() - Check if the "supports-clkreq" is present

I don't see a benefit of this API, tbh. The API name creates an impression that the API will check for the presence of CLKREQ# signal in DT, but it checks for the presence of the 'supports-clkreq' property. Even though the presence of the property implies that the CLKREQ# routing is available, I'd prefer to check for the property explicitly instead of hiding it inside this API.

It makes sense.

Will the name of_pci_supports_clkreq_present() look good? Or we just drop it and let host drivers to explicitly check supports-clkreq inside their code?

Quoted 3 lines

- Mani

#6 lore raw

Re: [PATCH 1/4] PCI: of: Add of_pci_clkreq_present()

Quoted 31 lines · Shawn Lin

Hi Mani

Quoted 19 lines · Manivannan Sadhasivam
Quoted 18 lines · Shawn Lin

of_pci_clkreq_present() is used by host drivers to decide whether the clkreq# is properly connected and could enable L1.1/L1.2 support.

---
  drivers/pci/of.c  | 18 ++++++++++++++++++
  drivers/pci/pci.h |  6 ++++++
  2 files changed, 24 insertions(+)
drivers/pci/of.c +1 -0
index 3579265f1198..52c6d365083b 100644
@@ -1010,3 +1010,21 @@ int of_pci_get_equalization_presets(struct device *dev,
  	return 0;
  }
  EXPORT_SYMBOL_GPL(of_pci_get_equalization_presets);
+
Quoted 8 lines

drivers/pci/of.c int of_pci_get_equalization_presets(struct device *dev, · line 1015

Quoted 2 lines
drivers/pci/of.c +2 -0
+/**
+ * of_pci_clkreq_present() - Check if the "supports-clkreq" is present

I don't see a benefit of this API, tbh. The API name creates an impression that the API will check for the presence of CLKREQ# signal in DT, but it checks for the presence of the 'supports-clkreq' property. Even though the presence of the property implies that the CLKREQ# routing is available, I'd prefer to check for the property explicitly instead of hiding it inside this API.

Quoted 6 lines

It makes sense.

Will the name of_pci_supports_clkreq_present() look good? Or we just drop it and let host drivers to explicitly check supports-clkreq inside their code?

I'd prefer to drop the API.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#7 lore raw

Re: [PATCH 1/4] PCI: of: Add of_pci_clkreq_present()

Quoted 32 lines · Manivannan Sadhasivam
Quoted 31 lines · Shawn Lin
Quoted 29 lines · Manivannan Sadhasivam
Quoted 14 lines · Shawn Lin

of_pci_clkreq_present() is used by host drivers to decide whether the clkreq# is properly connected and could enable L1.1/L1.2 support.

---
  drivers/pci/of.c  | 18 ++++++++++++++++++
  drivers/pci/pci.h |  6 ++++++
  2 files changed, 24 insertions(+)
drivers/pci/of.c +0 -0
index 3579265f1198..52c6d365083b 100644

drivers/pci/of.c int of_pci_get_equalization_presets(struct device *dev, · line 1015

Quoted 6 lines
drivers/pci/of.c +3 -0
@@ -1010,3 +1010,21 @@ int of_pci_get_equalization_presets(struct device *dev,
  	return 0;
  }
  EXPORT_SYMBOL_GPL(of_pci_get_equalization_presets);
+
+/**
+ * of_pci_clkreq_present() - Check if the "supports-clkreq" is present

I don't see a benefit of this API, tbh. The API name creates an impression that the API will check for the presence of CLKREQ# signal in DT, but it checks for the presence of the 'supports-clkreq' property. Even though the presence of the property implies that the CLKREQ# routing is available, I'd prefer to check for the property explicitly instead of hiding it inside this API.

Quoted 7 lines
Quoted 5 lines

It makes sense.

Will the name of_pci_supports_clkreq_present() look good? Or we just drop it and let host drivers to explicitly check supports-clkreq inside their code?

I'd prefer to drop the API.

An API might help with consistency across DT bindings. We don't want drivers to pick their own names for 'supports-clkreq'.

But the pci-bus-common schema already includes 'supports-clkreq', and that's probably enough:
https://github.com/devicetree-org/dt-schema/blob/979fea8f3c18/dtschema/schemas/pci/pci-bus-common.yaml#L155

#8 lore raw

Re: [PATCH 1/4] PCI: of: Add of_pci_clkreq_present()

Quoted 35 lines · Bjorn Helgaas
Quoted 34 lines · Manivannan Sadhasivam
Quoted 33 lines · Shawn Lin
Quoted 22 lines · Manivannan Sadhasivam
Quoted 14 lines · Shawn Lin

of_pci_clkreq_present() is used by host drivers to decide whether the clkreq# is properly connected and could enable L1.1/L1.2 support.

---
  drivers/pci/of.c  | 18 ++++++++++++++++++
  drivers/pci/pci.h |  6 ++++++
  2 files changed, 24 insertions(+)
drivers/pci/of.c +0 -0
index 3579265f1198..52c6d365083b 100644

drivers/pci/of.c int of_pci_get_equalization_presets(struct device *dev, · line 1015

Quoted 6 lines
drivers/pci/of.c +3 -0
@@ -1010,3 +1010,21 @@ int of_pci_get_equalization_presets(struct device *dev,
  	return 0;
  }
  EXPORT_SYMBOL_GPL(of_pci_get_equalization_presets);
+
+/**
+ * of_pci_clkreq_present() - Check if the "supports-clkreq" is present
Quoted 7 lines

I don't see a benefit of this API, tbh. The API name creates an impression that the API will check for the presence of CLKREQ# signal in DT, but it checks for the presence of the 'supports-clkreq' property. Even though the presence of the property implies that the CLKREQ# routing is available, I'd prefer to check for the property explicitly instead of hiding it inside this API.

It makes sense.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Will the name of_pci_supports_clkreq_present() look good? Or we just drop it and let host drivers to explicitly check supports-clkreq inside their code?

I'd prefer to drop the API.

An API might help with consistency across DT bindings. We don't want drivers to pick their own names for 'supports-clkreq'.

I don't know what you mean by 'drivers to pick their own names'. With or without this API, the drivers have to use a local variable:

- pcie->supports_clkreq =
- of_property_read_bool(pcie->dev->of_node, "supports-clkreq");
+ pcie->supports_clkreq = of_pci_clkreq_present(pcie->dev->of_node);

What this API does is, just hiding the 'supports-clkreq' property, nothing more.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#9 lore raw

Re: [PATCH 1/4] PCI: of: Add of_pci_clkreq_present()

Quoted 40 lines · Manivannan Sadhasivam
Quoted 39 lines · Bjorn Helgaas
Quoted 38 lines · Manivannan Sadhasivam
Quoted 36 lines · Shawn Lin
Quoted 22 lines · Manivannan Sadhasivam
Quoted 14 lines · Shawn Lin

of_pci_clkreq_present() is used by host drivers to decide whether the clkreq# is properly connected and could enable L1.1/L1.2 support.

---
  drivers/pci/of.c  | 18 ++++++++++++++++++
  drivers/pci/pci.h |  6 ++++++
  2 files changed, 24 insertions(+)
drivers/pci/of.c +0 -0
index 3579265f1198..52c6d365083b 100644

drivers/pci/of.c int of_pci_get_equalization_presets(struct device *dev, · line 1015

Quoted 6 lines
drivers/pci/of.c +3 -0
@@ -1010,3 +1010,21 @@ int of_pci_get_equalization_presets(struct device *dev,
  	return 0;
  }
  EXPORT_SYMBOL_GPL(of_pci_get_equalization_presets);
+
+/**
+ * of_pci_clkreq_present() - Check if the "supports-clkreq" is present
Quoted 7 lines

I don't see a benefit of this API, tbh. The API name creates an impression that the API will check for the presence of CLKREQ# signal in DT, but it checks for the presence of the 'supports-clkreq' property. Even though the presence of the property implies that the CLKREQ# routing is available, I'd prefer to check for the property explicitly instead of hiding it inside this API.

It makes sense.

Will the name of_pci_supports_clkreq_present() look good? Or we just drop it and let host drivers to explicitly check supports-clkreq inside their code?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I'd prefer to drop the API.

An API might help with consistency across DT bindings. We don't want drivers to pick their own names for 'supports-clkreq'.

I don't know what you mean by 'drivers to pick their own names'. With or without this API, the drivers have to use a local variable:

I just meant different names for the 'supports-clkreq' DT property. But the schema I mentioned should be enough for that.

author
#10 lore raw

PATCH 2/4 PCI: tegra194: Use of_pci_clkreq_present() instead

In reply to Shawn Lin

No functional changes intended.

---
 drivers/pci/controller/dwc/pcie-tegra194.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +1 -2
index 10e74458e667..7a82a53e7c4d 100644
@@ -1161,8 +1161,7 @@ static int tegra_pcie_dw_parse_dt(struct tegra_pcie_dw *pcie)
 					      "nvidia,enable-ext-refclk");
 	}
 
-	pcie->supports_clkreq =
-		of_property_read_bool(pcie->dev->of_node, "supports-clkreq");
+	pcie->supports_clkreq = of_pci_clkreq_present(pcie->dev->of_node);
 
 	pcie->enable_cdm_check =
 		of_property_read_bool(np, "snps,enable-cdm-check");
Signature · 1 line
2.43.0
author
#11 lore raw

PATCH 3/4 PCI: dw-rockchip: Add L1sub support

In reply to Shawn Lin

The driver should set app_clk_req_n(clkreq ready) of PCIE_CLIENT_POWER reg to support L1sub. Otherwise, unset app_clk_req_n and pull down CLKREQ#.

---
 drivers/pci/controller/dwc/pcie-dw-rockchip.c | 31 ++++++++++++++-----
 1 file changed, 23 insertions(+), 8 deletions(-)
drivers/pci/controller/dwc/pcie-dw-rockchip.c +23 -8
index 87dd2dd188b4..8a52ff73ec46 100644
@@ -62,6 +62,12 @@
 /* Interrupt Mask Register Related to Miscellaneous Operation */
 #define PCIE_CLIENT_INTR_MASK_MISC	0x24
 
+/* Power Management Control Register */
+#define PCIE_CLIENT_POWER		0x2c
+#define  PCIE_CLKREQ_READY		0x10001
+#define  PCIE_CLKREQ_NOT_READY		0x10000
+#define  PCIE_CLKREQ_PULL_DOWN		0x30001000
+
 /* Hot Reset Control Register */
 #define PCIE_CLIENT_HOT_RESET_CTRL	0x180
 #define  PCIE_LTSSM_APP_DLY2_EN		BIT(1)
@@ -84,6 +90,7 @@ struct rockchip_pcie {
 	struct gpio_desc *rst_gpio;
 	struct irq_domain *irq_domain;
 	const struct rockchip_pcie_of_data *data;
+	bool supports_clkreq;
 };
 
 struct rockchip_pcie_of_data {
@@ -199,15 +206,21 @@ static bool rockchip_pcie_link_up(struct dw_pcie *pci)
 	return FIELD_GET(PCIE_LINKUP_MASK, val) == PCIE_LINKUP;
 }
 
-/*
- * See e.g. section '11.6.6.4 L1 Substate' in the RK3588 TRM V1.0 for the steps
- * needed to support L1 substates. Currently, not a single rockchip platform
- * performs these steps, so disable L1 substates until there is proper support.
- */
-static void rockchip_pcie_disable_l1sub(struct dw_pcie *pci)
+static void rockchip_pcie_enable_l1sub(struct dw_pcie *pci)
 {
+	struct rockchip_pcie *rockchip = to_rockchip_pcie(pci);
 	u32 cap, l1subcap;
 
+	/* Enable L1 substates if CLKREQ# is properly connected */
+	if (rockchip->supports_clkreq) {
+		/* Ready to have reference clock removed */
+		rockchip_pcie_writel_apb(rockchip, PCIE_CLKREQ_READY, PCIE_CLIENT_POWER);
+		return;
+	}
+
+	/* Otherwise, pull down CLKREQ# and disable L1 substates */
+	rockchip_pcie_writel_apb(rockchip, PCIE_CLKREQ_PULL_DOWN | PCIE_CLKREQ_NOT_READY,
+				 PCIE_CLIENT_POWER);
 	cap = dw_pcie_find_ext_capability(pci, PCI_EXT_CAP_ID_L1SS);
 	if (cap) {
 		l1subcap = dw_pcie_readl_dbi(pci, cap + PCI_L1SS_CAP);
@@ -282,7 +295,7 @@ static int rockchip_pcie_host_init(struct dw_pcie_rp *pp)
 	irq_set_chained_handler_and_data(irq, rockchip_pcie_intx_handler,
 					 rockchip);
 
-	rockchip_pcie_disable_l1sub(pci);
+	rockchip_pcie_enable_l1sub(pci);
 	rockchip_pcie_enable_l0s(pci);
 
 	return 0;
@@ -320,7 +333,7 @@ static void rockchip_pcie_ep_init(struct dw_pcie_ep *ep)
 	struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
 	enum pci_barno bar;
 
-	rockchip_pcie_disable_l1sub(pci);
+	rockchip_pcie_enable_l1sub(pci);
 	rockchip_pcie_enable_l0s(pci);
 	rockchip_pcie_ep_hide_broken_ats_cap_rk3588(ep);
 
@@ -432,6 +445,8 @@ static int rockchip_pcie_resource_get(struct platform_device *pdev,
 		return dev_err_probe(&pdev->dev, PTR_ERR(rockchip->rst),
 				     "failed to get reset lines\n");
 
+	rockchip->supports_clkreq = of_pci_clkreq_present(pdev->dev.of_node);
+
 	return 0;
 }
 
Signature · 1 line
2.43.0
#12 lore raw

Re: [PATCH 3/4] PCI: dw-rockchip: Add L1sub support

Quoted 36 lines · Shawn Lin

EXTERNAL EMAIL

The driver should set app_clk_req_n(clkreq ready) of PCIE_CLIENT_POWER reg to support L1sub. Otherwise, unset app_clk_req_n and pull down CLKREQ#.

---
  drivers/pci/controller/dwc/pcie-dw-rockchip.c | 31 ++++++++++++++-----
  1 file changed, 23 insertions(+), 8 deletions(-)
drivers/pci/controller/dwc/pcie-dw-rockchip.c +7 -0
index 87dd2dd188b4..8a52ff73ec46 100644
@@ -62,6 +62,12 @@
  /* Interrupt Mask Register Related to Miscellaneous Operation */
  #define PCIE_CLIENT_INTR_MASK_MISC     0x24
 
+/* Power Management Control Register */
+#define PCIE_CLIENT_POWER              0x2c
+#define  PCIE_CLKREQ_READY             0x10001
+#define  PCIE_CLKREQ_NOT_READY         0x10000
+#define  PCIE_CLKREQ_PULL_DOWN         0x30001000
+
  /* Hot Reset Control Register */
  #define PCIE_CLIENT_HOT_RESET_CTRL     0x180
  #define  PCIE_LTSSM_APP_DLY2_EN                BIT(1)
@@ -84,6 +90,7 @@ struct rockchip_pcie {
         struct gpio_desc *rst_gpio;
         struct irq_domain *irq_domain;
         const struct rockchip_pcie_of_data *data;
+       bool supports_clkreq;
  };
 
  struct rockchip_pcie_of_data {

drivers/pci/controller/dwc/pcie-dw-rockchip.c static bool rockchip_pcie_link_up(struct dw_pcie *pci) · line 207

Quoted 9 lines
drivers/pci/controller/dwc/pcie-dw-rockchip.c +0 -6
@@ -199,15 +206,21 @@ static bool rockchip_pcie_link_up(struct dw_pcie *pci)
         return FIELD_GET(PCIE_LINKUP_MASK, val) == PCIE_LINKUP;
  }
 
-/*
- * See e.g. section '11.6.6.4 L1 Substate' in the RK3588 TRM V1.0 for the steps
- * needed to support L1 substates. Currently, not a single rockchip platform
- * performs these steps, so disable L1 substates until there is proper support.
- */
-static void rockchip_pcie_disable_l1sub(struct dw_pcie *pci)

Hi,

https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/commit/?h=controller/dw-rockchip&id=40331c63e7901a2cc75ce6b5d24d50601efb833d

Mani has already placed this part in the above branch. Can it be removed?

Best regards,
Hans

Quoted 49 lines
drivers/pci/controller/dwc/pcie-dw-rockchip.c +16 -3
+static void rockchip_pcie_enable_l1sub(struct dw_pcie *pci)
  {
+       struct rockchip_pcie *rockchip = to_rockchip_pcie(pci);
         u32 cap, l1subcap;
 
+       /* Enable L1 substates if CLKREQ# is properly connected */
+       if (rockchip->supports_clkreq) {
+               /* Ready to have reference clock removed */
+               rockchip_pcie_writel_apb(rockchip, PCIE_CLKREQ_READY, PCIE_CLIENT_POWER);
+               return;
+       }
+
+       /* Otherwise, pull down CLKREQ# and disable L1 substates */
+       rockchip_pcie_writel_apb(rockchip, PCIE_CLKREQ_PULL_DOWN | PCIE_CLKREQ_NOT_READY,
+                                PCIE_CLIENT_POWER);
         cap = dw_pcie_find_ext_capability(pci, PCI_EXT_CAP_ID_L1SS);
         if (cap) {
                 l1subcap = dw_pcie_readl_dbi(pci, cap + PCI_L1SS_CAP);
@@ -282,7 +295,7 @@ static int rockchip_pcie_host_init(struct dw_pcie_rp *pp)
         irq_set_chained_handler_and_data(irq, rockchip_pcie_intx_handler,
                                          rockchip);
 
-       rockchip_pcie_disable_l1sub(pci);
+       rockchip_pcie_enable_l1sub(pci);
         rockchip_pcie_enable_l0s(pci);
 
         return 0;
@@ -320,7 +333,7 @@ static void rockchip_pcie_ep_init(struct dw_pcie_ep *ep)
         struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
         enum pci_barno bar;
 
-       rockchip_pcie_disable_l1sub(pci);
+       rockchip_pcie_enable_l1sub(pci);
         rockchip_pcie_enable_l0s(pci);
         rockchip_pcie_ep_hide_broken_ats_cap_rk3588(ep);
 
@@ -432,6 +445,8 @@ static int rockchip_pcie_resource_get(struct platform_device *pdev,
                 return dev_err_probe(&pdev->dev, PTR_ERR(rockchip->rst),
                                      "failed to get reset lines\n");
 
+       rockchip->supports_clkreq = of_pci_clkreq_present(pdev->dev.of_node);
+
         return 0;
  }
 
--

2.43.0

author
#13 lore raw

Re: [PATCH 3/4] PCI: dw-rockchip: Add L1sub support

Quoted 55 lines · Hans Zhang
Quoted 42 lines · Shawn Lin

EXTERNAL EMAIL

The driver should set app_clk_req_n(clkreq ready) of PCIE_CLIENT_POWER reg to support L1sub. Otherwise, unset app_clk_req_n and pull down CLKREQ#.

---
  drivers/pci/controller/dwc/pcie-dw-rockchip.c | 31 ++++++++++++++-----

  1 file changed, 23 insertions(+), 8 deletions(-)
drivers/pci/controller/dwc/pcie-dw-rockchip.c +7 -2
index 87dd2dd188b4..8a52ff73ec46 100644
@@ -62,6 +62,12 @@
   /* Interrupt Mask Register Related to Miscellaneous Operation */
   #define PCIE_CLIENT_INTR_MASK_MISC     0x24
 
+/* Power Management Control Register */
+#define PCIE_CLIENT_POWER              0x2c
+#define  PCIE_CLKREQ_READY             0x10001
+#define  PCIE_CLKREQ_NOT_READY         0x10000
+#define  PCIE_CLKREQ_PULL_DOWN         0x30001000
+
   /* Hot Reset Control Register */
   #define PCIE_CLIENT_HOT_RESET_CTRL     0x180
   #define  PCIE_LTSSM_APP_DLY2_EN                BIT(1)
@@ -84,6 +90,7 @@ struct rockchip_pcie {
          struct gpio_desc *rst_gpio;
          struct irq_domain *irq_domain;
          const struct rockchip_pcie_of_data *data;
+       bool supports_clkreq;
   };
 
   struct rockchip_pcie_of_data {
@@ -199,15 +206,21 @@ static bool rockchip_pcie_link_up(struct dw_pcie 
 *pci)
          return FIELD_GET(PCIE_LINKUP_MASK, val) == PCIE_LINKUP;
   }
 
-/*
- * See e.g. section '11.6.6.4 L1 Substate' in the RK3588 TRM V1.0 for 
Quoted 7 lines

the steps
- * needed to support L1 substates. Currently, not a single rockchip platform
- * performs these steps, so disable L1 substates until there is proper support.
- */
-static void rockchip_pcie_disable_l1sub(struct dw_pcie *pci)

Hi,

Quoted 4 lines

https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/commit/? h=controller/dw-rockchip&id=40331c63e7901a2cc75ce6b5d24d50601efb833d

Mani has already placed this part in the above branch. Can it be removed?

I think it's better to apply the changes on top of Niklas's commit rather than removing it, out of respect for Niklas's credit.

Quoted 61 lines

Best regards,
Hans

Quoted 55 lines

+static void rockchip_pcie_enable_l1sub(struct dw_pcie *pci) {
+       struct rockchip_pcie *rockchip = to_rockchip_pcie(pci); u32 cap, l1subcap;

+       /* Enable L1 substates if CLKREQ# is properly connected */ +       if (rockchip->supports_clkreq) {
+               /* Ready to have reference clock removed */ +               rockchip_pcie_writel_apb(rockchip, PCIE_CLKREQ_READY, PCIE_CLIENT_POWER);
+               return;
+       }
+
+       /* Otherwise, pull down CLKREQ# and disable L1 substates */ +       rockchip_pcie_writel_apb(rockchip, PCIE_CLKREQ_PULL_DOWN | PCIE_CLKREQ_NOT_READY,
+                                PCIE_CLIENT_POWER);
         cap = dw_pcie_find_ext_capability(pci, PCI_EXT_CAP_ID_L1SS); if (cap) {
                 l1subcap = dw_pcie_readl_dbi(pci, cap + PCI_L1SS_CAP);

drivers/pci/controller/dwc/pcie-dw-rockchip.c +1 -1
@@ -282,7 +295,7 @@ static int rockchip_pcie_host_init(struct 
 dw_pcie_rp *pp)
          irq_set_chained_handler_and_data(irq, rockchip_pcie_intx_handler,
                                           rockchip);
 
-       rockchip_pcie_disable_l1sub(pci);
+       rockchip_pcie_enable_l1sub(pci);
          rockchip_pcie_enable_l0s(pci);
 

         return 0;

drivers/pci/controller/dwc/pcie-dw-rockchip.c +3 -1
@@ -320,7 +333,7 @@ static void rockchip_pcie_ep_init(struct 
 dw_pcie_ep *ep)
          struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
          enum pci_barno bar;
 
-       rockchip_pcie_disable_l1sub(pci);
+       rockchip_pcie_enable_l1sub(pci);
          rockchip_pcie_enable_l0s(pci);
          rockchip_pcie_ep_hide_broken_ats_cap_rk3588(ep);
@@ -432,6 +445,8 @@ static int rockchip_pcie_resource_get(struct 
 platform_device *pdev,
                  return dev_err_probe(&pdev->dev, PTR_ERR(rockchip->rst),
                                       "failed to get reset lines\n");
 
+       rockchip->supports_clkreq = of_pci_clkreq_present(pdev- 
 >dev.of_node);
+
          return 0;

  }

Signature · 1 line
2.43.0
#14 lore raw

Re: [PATCH 3/4] PCI: dw-rockchip: Add L1sub support

Quoted 13 lines · Shawn Lin
Quoted 13 lines
Quoted 10 lines

-/*
- * See e.g. section '11.6.6.4 L1 Substate' in the RK3588 TRM V1.0 for the steps
- * needed to support L1 substates. Currently, not a single rockchip platform
- * performs these steps, so disable L1 substates until there is proper support.
- */
-static void rockchip_pcie_disable_l1sub(struct dw_pcie *pci)

Hi,

Quoted 8 lines
Quoted 5 lines

https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/commit/?
h=controller/dw-rockchip&id=40331c63e7901a2cc75ce6b5d24d50601efb833d

Mani has already placed this part in the above branch. Can it be removed?

I think it's better to apply the changes on top of Niklas's commit rather than removing it, out of respect for Niklas's credit.

Hi Shawn,

Sorry, maybe I'm just looking at this issue from the perspective of patch and understand what you mean.

Best regards,
Hans

#15 lore raw

Re: [PATCH 3/4] PCI: dw-rockchip: Add L1sub support

In reply to Shawn Lin
Quoted 59 lines · Shawn Lin
Quoted 57 lines · Hans Zhang
Quoted 44 lines · Shawn Lin

EXTERNAL EMAIL

The driver should set app_clk_req_n(clkreq ready) of PCIE_CLIENT_POWER reg
to support L1sub. Otherwise, unset app_clk_req_n and pull down CLKREQ#.

---
  drivers/pci/controller/dwc/pcie-dw-rockchip.c | 31 ++++++++++++++-----

  1 file changed, 23 insertions(+), 8 deletions(-)
(quoted diff) +0 -0

b/drivers/ pci/controller/dwc/pcie-dw-rockchip.c
index 87dd2dd188b4..8a52ff73ec46 100644

drivers/pci/controller/dwc/pcie-dw-rockchip.c +7 -2
@@ -62,6 +62,12 @@
   /* Interrupt Mask Register Related to Miscellaneous Operation */
   #define PCIE_CLIENT_INTR_MASK_MISC     0x24
 
+/* Power Management Control Register */
+#define PCIE_CLIENT_POWER              0x2c
+#define  PCIE_CLKREQ_READY             0x10001
+#define  PCIE_CLKREQ_NOT_READY         0x10000
+#define  PCIE_CLKREQ_PULL_DOWN         0x30001000
+
   /* Hot Reset Control Register */
   #define PCIE_CLIENT_HOT_RESET_CTRL     0x180
   #define  PCIE_LTSSM_APP_DLY2_EN                BIT(1)
@@ -84,6 +90,7 @@ struct rockchip_pcie {
          struct gpio_desc *rst_gpio;
          struct irq_domain *irq_domain;
          const struct rockchip_pcie_of_data *data;
+       bool supports_clkreq;
   };
 
   struct rockchip_pcie_of_data {
@@ -199,15 +206,21 @@ static bool rockchip_pcie_link_up(struct
 dw_pcie *pci)
          return FIELD_GET(PCIE_LINKUP_MASK, val) == PCIE_LINKUP;
   }
 
-/*
- * See e.g. section '11.6.6.4 L1 Substate' in the RK3588 TRM V1.0
Quoted 7 lines

for the steps
- * needed to support L1 substates. Currently, not a single rockchip platform
- * performs these steps, so disable L1 substates until there is proper support.
- */
-static void rockchip_pcie_disable_l1sub(struct dw_pcie *pci)

Hi,

Quoted 9 lines
Quoted 5 lines

https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git/commit/?
h=controller/dw-rockchip&id=40331c63e7901a2cc75ce6b5d24d50601efb833d

Mani has already placed this part in the above branch. Can it be removed?

I think it's better to apply the changes on top of Niklas's commit rather than removing it, out of respect for Niklas's credit.

There is no point in removing a feature in one patch and adding it back in another patch in the same release. Once this series materializes, I'll drop the patch from Niklas.

- Mani

Signature · 1 line
மணிவண்ணன் சதாசிவம்
author
#16 lore raw

PATCH 4/4 arm64: dts: rockchip: Add PCIe clkreq stuff for RK3588 EVB1

In reply to Shawn Lin

Add supports-clkreq and pinmux for PCIe ASPM L1 substates.

---
 arch/arm64/boot/dts/rockchip/rk3588-evb1-v10.dts | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/rockchip/rk3588-evb1-v10.dts +5 -2
index ff1ba5ed56ef..c9d284cb738b 100644
@@ -522,6 +522,7 @@ &pcie2x1l0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pcie2_0_rst>, <&pcie2_0_wake>, <&pcie2_0_clkreq>, <&wifi_host_wake_irq>;
 	reset-gpios = <&gpio4 RK_PA5 GPIO_ACTIVE_HIGH>;
+	supports-clkreq;
 	vpcie3v3-supply = <&vcc3v3_wlan>;
 	status = "okay";
 
@@ -545,7 +546,8 @@ wifi: wifi@0,0 {
 &pcie2x1l1 {
 	reset-gpios = <&gpio4 RK_PA2 GPIO_ACTIVE_HIGH>;
 	pinctrl-names = "default";
-	pinctrl-0 = <&pcie2_1_rst>, <&rtl8111_isolate>;
+	pinctrl-0 = <&pcie2_1_rst>, <&rtl8111_isolate>, <&pcie30x1m1_1_clkreqn>;
+	supports-clkreq;
 	status = "okay";
 };
 
@@ -555,7 +557,8 @@ &pcie30phy {
 
 &pcie3x4 {
 	pinctrl-names = "default";
-	pinctrl-0 = <&pcie3_reset>;
+	pinctrl-0 = <&pcie3_reset>, <&pcie30x4m1_clkreqn>;
+	supports-clkreq;
 	reset-gpios = <&gpio4 RK_PB6 GPIO_ACTIVE_HIGH>;
 	vpcie3v3-supply = <&vcc3v3_pcie30>;
 	status = "okay";
Signature · 1 line
2.43.0