* [PATCH v6 00/10] PCI: dw-rockchip: add system suspend support
@ 2026-09-08 14:51 Sebastian Reichel
2026-09-08 14:51 ` [PATCH v6 01/10] PCI: dw-rockchip: Fix LTSSM set functions Sebastian Reichel
` (9 more replies)
0 siblings, 10 replies; 20+ messages in thread
From: Sebastian Reichel @ 2026-09-08 14:51 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Shawn Lin, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: Alexey Charkov, linux-pci, linux-arm-kernel, linux-rockchip,
linux-kernel, kernel, Sebastian Reichel
I've been working on fixing up at least basic system suspend support on
the Rockchip RK3576 platform. The last open issue is missing support in
the PCIe driver. This series is a follow-up for Shawn Lin's series with
feedback from Niklas Cassel and Manivannan Sadhasivam being handled as
well as some of my own changes fixing up things I noticed.
I've tested this on multiple RK3576 and RK3588 boards and things look
good to me on the PCIe side.
On RK3588, I also needed [0] to fix PCIe IOMMU issues after resume. I
consider this an independent issue. Also on the Rockchip EVBs the
brcmfmac driver fails to suspend. The WIFI card is connected via PCIe,
but the problem is with the driver/firmware and unrelated to PCIe
itself. I will send a separate workaround patch for that. Additionally
on RK3588 the system will run into SError on resume due to a USB2
problem. This problem is also independent and will be handled
separately.
[0] https://lore.kernel.org/all/20260728210928.1050849-1-praan@google.com/
Changes since PATCHv5:
* https://lore.kernel.org/r/20260316-rockchip-pcie-system-suspend-v5-0-5bb5ad37d643@collabora.com
* Rebase to pci/next
* Minor changes to make checkpatch happy
* Update patch description of the last patch and drop RFC tag
according to feedback from Shawn Lin
* Prepend new patch, which fixes Nicolas Frattaroli's conversion
to FIELD_PREP_WM16 accidently dropping a flag.
* Add another new patch, which sets .broken_l1ss_resume to tell the
PCI core that the controller is powered off during suspend following
the Qcom example
Changes since PATCHv4:
* https://lore.kernel.org/r/20251029-rockchip-pcie-system-suspend-v4-0-ce2e1b0692d2@collabora.com
* rebase to v7.0-rc1
* Add an RFC patch at the end with some bits I found in the Rockchip vendor kernel;
* Made some tests on Rock 5B+ (RK3588); with this patch series suspending works
when setting pm_test to devices. A full system suspend fails in a later step,
but that is independent of PCIe.
Changes since PATCHv3:
* https://lore.kernel.org/linux-pci/1744940759-23823-1-git-send-email-shawn.lin@rock-chips.com/
* rename rockchip_pcie_get_ltssm to rockchip_pcie_get_ltssm_status_reg
in a separate patch (Niklas Cassel)
* rename rockchip_pcie_get_pure_ltssm to rockchip_pcie_get_ltssm_state
in a separate patch (Niklas Cassel)
* Move devm_phy_get out of phy_init to probe in a separate patch
(Manivannan Sadhasivam)
* Add helper function for enhanced LTSSM control mode in a separate patch
(Niklas Cassel)
* Add helper function for controller mode in a separate patch
(Niklas Cassel)
* Add helper function for DDL indicator in a separate patch
(Niklas Cassel)
* Move rockchip_pcie_pme_turn_off implementation in a separate patch
* Rebase to v6.18-rc3 using new FIELD_PREP_WM16()
* Improve readability of PME_TURN_OFF/PME_TO_ACK defines (Manivannan Sadhasivam)
* Fix usage of reverse Xmas (Manivannan Sadhasivam)
* Assert PERST# before turning off other resources (Manivannan Sadhasivam)
* Improve some error messages (Manivannan Sadhasivam)
* Rename goto labels as per their purpose (Manivannan Sadhasivam)
* Add extra patch for dw_pcie_resume_noirq, since I've seen errors
during resume on boards not having anything plugged into their PCIe
port
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
Sebastian Reichel (10):
PCI: dw-rockchip: Fix LTSSM set functions
PCI: dw-rockchip: Restore vpcie3v3 regulator handle
PCI: dw-rockchip: Move devm_phy_get out of phy_init
PCI: dw-rockchip: Add helper function for enhanced LTSSM control mode
PCI: dw-rockchip: Add helper function for controller mode
PCI: dw-rockchip: Add helper function for DDL indicator
PCI: dw-rockchip: Add pme_turn_off support
PCI: dw-rockchip: Set broken L1SS resume flag
PCI: dw-rockchip: Add system PM support
PCI: dw-rockchip: Clear debug buffer before entering L2
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 274 ++++++++++++++++++++++----
1 file changed, 235 insertions(+), 39 deletions(-)
---
base-commit: 39ee38a9fa2eaeff030a6c865abb244597c091eb
change-id: 20251028-rockchip-pcie-system-suspend-86cf08a7b229
Best regards,
--
Sebastian Reichel <sebastian.reichel@collabora.com>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v6 01/10] PCI: dw-rockchip: Fix LTSSM set functions
2026-09-08 14:51 [PATCH v6 00/10] PCI: dw-rockchip: add system suspend support Sebastian Reichel
@ 2026-09-08 14:51 ` Sebastian Reichel
2026-09-09 0:37 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 02/10] PCI: dw-rockchip: Restore vpcie3v3 regulator handle Sebastian Reichel
` (8 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reichel @ 2026-09-08 14:51 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Shawn Lin, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: Alexey Charkov, linux-pci, linux-arm-kernel, linux-rockchip,
linux-kernel, kernel, Sebastian Reichel
Before the Rockchip PCIe driver has been switched over to the
FIELD_PREP_WM16 macro, PCIE_CLIENT_ENABLE_LTSSM and
PCIE_CLIENT_DISABLE_LTSSM were setting bits with a mask of 0xc = 0b1100,
which means BIT 2 and BIT 3. After the conversion it only sets bit 2,
with bit 3 being handled by a separate define named
PCIE_CLIENT_LD_RQ_RST_GRT. Apparently the conversion missed to make use
of this new macros resulting in the third bit not being set.
Fixes: 30e919570581 ("PCI: dw-rockchip: Switch to FIELD_PREP_WM16 macro")
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index af26a07c0c9e..dc85564e5001 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -321,14 +321,16 @@ static void rockchip_pcie_ltssm_trace(struct rockchip_pcie *rockchip,
static void rockchip_pcie_enable_ltssm(struct rockchip_pcie *rockchip)
{
- rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_ENABLE_LTSSM,
- PCIE_CLIENT_GENERAL_CON);
+ u32 val = PCIE_CLIENT_ENABLE_LTSSM | PCIE_CLIENT_LD_RQ_RST_GRT;
+
+ rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_GENERAL_CON);
}
static void rockchip_pcie_disable_ltssm(struct rockchip_pcie *rockchip)
{
- rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_DISABLE_LTSSM,
- PCIE_CLIENT_GENERAL_CON);
+ u32 val = PCIE_CLIENT_DISABLE_LTSSM | PCIE_CLIENT_LD_RQ_RST_GRT;
+
+ rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_GENERAL_CON);
}
static bool rockchip_pcie_link_up(struct dw_pcie *pci)
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 02/10] PCI: dw-rockchip: Restore vpcie3v3 regulator handle
2026-09-08 14:51 [PATCH v6 00/10] PCI: dw-rockchip: add system suspend support Sebastian Reichel
2026-09-08 14:51 ` [PATCH v6 01/10] PCI: dw-rockchip: Fix LTSSM set functions Sebastian Reichel
@ 2026-09-08 14:51 ` Sebastian Reichel
2026-09-09 0:44 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 03/10] PCI: dw-rockchip: Move devm_phy_get out of phy_init Sebastian Reichel
` (7 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reichel @ 2026-09-08 14:51 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Shawn Lin, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: Alexey Charkov, linux-pci, linux-arm-kernel, linux-rockchip,
linux-kernel, kernel, Sebastian Reichel
This reverts commit c930b10f17c0 ("PCI: dw-rockchip: Simplify regulator
setup with devm_regulator_get_enable_optional()"), which nicely cleaned
up the code.
The vpcie3v3 regulator handle is needed to disable the regulator during
system suspend (to be added in its own patch).
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index dc85564e5001..f67ad3c31c35 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -112,6 +112,7 @@ struct rockchip_pcie {
unsigned int clk_cnt;
struct reset_control *rst;
struct gpio_desc *rst_gpio;
+ struct regulator *vpcie3v3;
struct irq_domain *irq_domain;
const struct rockchip_pcie_of_data *data;
bool supports_clkreq;
@@ -844,15 +845,22 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
return ret;
/* DON'T MOVE ME: must be enable before PHY init */
- ret = devm_regulator_get_enable_optional(dev, "vpcie3v3");
- if (ret < 0 && ret != -ENODEV)
- return dev_err_probe(dev, ret,
- "failed to enable vpcie3v3 regulator\n");
+ rockchip->vpcie3v3 = devm_regulator_get_optional(dev, "vpcie3v3");
+ if (IS_ERR(rockchip->vpcie3v3)) {
+ if (PTR_ERR(rockchip->vpcie3v3) != -ENODEV)
+ return dev_err_probe(dev, PTR_ERR(rockchip->vpcie3v3),
+ "failed to get vpcie3v3 regulator\n");
+ rockchip->vpcie3v3 = NULL;
+ } else {
+ ret = regulator_enable(rockchip->vpcie3v3);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "failed to enable vpcie3v3 regulator\n");
+ }
ret = rockchip_pcie_phy_init(rockchip);
if (ret)
- return dev_err_probe(dev, ret,
- "failed to initialize the phy\n");
+ goto disable_regulator;
ret = reset_control_deassert(rockchip->rst);
if (ret)
@@ -885,6 +893,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
clk_bulk_disable_unprepare(rockchip->clk_cnt, rockchip->clks);
deinit_phy:
rockchip_pcie_phy_deinit(rockchip);
+disable_regulator:
+ if (rockchip->vpcie3v3)
+ regulator_disable(rockchip->vpcie3v3);
return ret;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 03/10] PCI: dw-rockchip: Move devm_phy_get out of phy_init
2026-09-08 14:51 [PATCH v6 00/10] PCI: dw-rockchip: add system suspend support Sebastian Reichel
2026-09-08 14:51 ` [PATCH v6 01/10] PCI: dw-rockchip: Fix LTSSM set functions Sebastian Reichel
2026-09-08 14:51 ` [PATCH v6 02/10] PCI: dw-rockchip: Restore vpcie3v3 regulator handle Sebastian Reichel
@ 2026-09-08 14:51 ` Sebastian Reichel
2026-09-09 0:54 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 04/10] PCI: dw-rockchip: Add helper function for enhanced LTSSM control mode Sebastian Reichel
` (6 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reichel @ 2026-09-08 14:51 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Shawn Lin, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: Alexey Charkov, linux-pci, linux-arm-kernel, linux-rockchip,
linux-kernel, kernel, Sebastian Reichel
By moving devm_phy_get() to the probe routine, rockchip_pcie_phy_init()
can be used to re-initialize the PCIe PHY, which is for example needed
after a system suspend/resume cycle.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index f67ad3c31c35..7472ec78b473 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -612,14 +612,8 @@ static int rockchip_pcie_resource_get(struct platform_device *pdev,
static int rockchip_pcie_phy_init(struct rockchip_pcie *rockchip)
{
- struct device *dev = rockchip->pci.dev;
int ret;
- rockchip->phy = devm_phy_get(dev, "pcie-phy");
- if (IS_ERR(rockchip->phy))
- return dev_err_probe(dev, PTR_ERR(rockchip->phy),
- "missing PHY\n");
-
ret = phy_init(rockchip->phy);
if (ret < 0)
return ret;
@@ -858,6 +852,13 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
"failed to enable vpcie3v3 regulator\n");
}
+ rockchip->phy = devm_phy_get(dev, "pcie-phy");
+ if (IS_ERR(rockchip->phy)) {
+ ret = PTR_ERR(rockchip->phy);
+ dev_err_probe(dev, ret, "missing PHY\n");
+ goto disable_regulator;
+ }
+
ret = rockchip_pcie_phy_init(rockchip);
if (ret)
goto disable_regulator;
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 04/10] PCI: dw-rockchip: Add helper function for enhanced LTSSM control mode
2026-09-08 14:51 [PATCH v6 00/10] PCI: dw-rockchip: add system suspend support Sebastian Reichel
` (2 preceding siblings ...)
2026-09-08 14:51 ` [PATCH v6 03/10] PCI: dw-rockchip: Move devm_phy_get out of phy_init Sebastian Reichel
@ 2026-09-08 14:51 ` Sebastian Reichel
2026-09-09 0:56 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 05/10] PCI: dw-rockchip: Add helper function for controller mode Sebastian Reichel
` (5 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reichel @ 2026-09-08 14:51 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Shawn Lin, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: Alexey Charkov, linux-pci, linux-arm-kernel, linux-rockchip,
linux-kernel, kernel, Sebastian Reichel
Remove code duplication and improve readability by introducing a new
function to setup the enhanced LTSSM mode.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index 7472ec78b473..6f84b07406d4 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -696,6 +696,18 @@ static irqreturn_t rockchip_pcie_ep_sys_irq_thread(int irq, void *arg)
return IRQ_HANDLED;
}
+static void rockchip_pcie_enable_enhanced_ltssm_control_mode(struct rockchip_pcie *rockchip,
+ u32 flags)
+{
+ u32 val;
+
+ /* Enable the enhanced control mode of signal app_ltssm_enable */
+ val = FIELD_PREP_WM16(PCIE_LTSSM_ENABLE_ENHANCE, 1);
+ if (flags)
+ val |= FIELD_PREP_WM16(flags, 1);
+ rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_HOT_RESET_CTRL);
+}
+
static int rockchip_pcie_configure_rc(struct platform_device *pdev,
struct rockchip_pcie *rockchip)
{
@@ -719,9 +731,7 @@ static int rockchip_pcie_configure_rc(struct platform_device *pdev,
return ret;
}
- /* LTSSM enable control mode */
- val = FIELD_PREP_WM16(PCIE_LTSSM_ENABLE_ENHANCE, 1);
- rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_HOT_RESET_CTRL);
+ rockchip_pcie_enable_enhanced_ltssm_control_mode(rockchip, 0);
rockchip_pcie_writel_apb(rockchip,
PCIE_CLIENT_SET_MODE(PCIE_CLIENT_MODE_RC),
@@ -765,13 +775,7 @@ static int rockchip_pcie_configure_ep(struct platform_device *pdev,
return ret;
}
- /*
- * LTSSM enable control mode, and automatically delay link training on
- * hot reset/link-down reset.
- */
- val = FIELD_PREP_WM16(PCIE_LTSSM_ENABLE_ENHANCE, 1) |
- FIELD_PREP_WM16(PCIE_LTSSM_APP_DLY2_EN, 1);
- rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_HOT_RESET_CTRL);
+ rockchip_pcie_enable_enhanced_ltssm_control_mode(rockchip, PCIE_LTSSM_APP_DLY2_EN);
rockchip_pcie_writel_apb(rockchip,
PCIE_CLIENT_SET_MODE(PCIE_CLIENT_MODE_EP),
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 05/10] PCI: dw-rockchip: Add helper function for controller mode
2026-09-08 14:51 [PATCH v6 00/10] PCI: dw-rockchip: add system suspend support Sebastian Reichel
` (3 preceding siblings ...)
2026-09-08 14:51 ` [PATCH v6 04/10] PCI: dw-rockchip: Add helper function for enhanced LTSSM control mode Sebastian Reichel
@ 2026-09-08 14:51 ` Sebastian Reichel
2026-09-09 0:58 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 06/10] PCI: dw-rockchip: Add helper function for DDL indicator Sebastian Reichel
` (4 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reichel @ 2026-09-08 14:51 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Shawn Lin, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: Alexey Charkov, linux-pci, linux-arm-kernel, linux-rockchip,
linux-kernel, kernel, Sebastian Reichel
Remove code duplication and improve readability by introducing a new
function to setup the controller mode.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index 6f84b07406d4..211776bbcb99 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -708,6 +708,11 @@ static void rockchip_pcie_enable_enhanced_ltssm_control_mode(struct rockchip_pci
rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_HOT_RESET_CTRL);
}
+static void rockchip_pcie_set_controller_mode(struct rockchip_pcie *rockchip, u32 mode)
+{
+ rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_SET_MODE(mode), PCIE_CLIENT_GENERAL_CON);
+}
+
static int rockchip_pcie_configure_rc(struct platform_device *pdev,
struct rockchip_pcie *rockchip)
{
@@ -732,10 +737,7 @@ static int rockchip_pcie_configure_rc(struct platform_device *pdev,
}
rockchip_pcie_enable_enhanced_ltssm_control_mode(rockchip, 0);
-
- rockchip_pcie_writel_apb(rockchip,
- PCIE_CLIENT_SET_MODE(PCIE_CLIENT_MODE_RC),
- PCIE_CLIENT_GENERAL_CON);
+ rockchip_pcie_set_controller_mode(rockchip, PCIE_CLIENT_MODE_RC);
pp = &rockchip->pci.pp;
pp->ops = &rockchip_pcie_host_ops;
@@ -776,10 +778,7 @@ static int rockchip_pcie_configure_ep(struct platform_device *pdev,
}
rockchip_pcie_enable_enhanced_ltssm_control_mode(rockchip, PCIE_LTSSM_APP_DLY2_EN);
-
- rockchip_pcie_writel_apb(rockchip,
- PCIE_CLIENT_SET_MODE(PCIE_CLIENT_MODE_EP),
- PCIE_CLIENT_GENERAL_CON);
+ rockchip_pcie_set_controller_mode(rockchip, PCIE_CLIENT_MODE_EP);
rockchip->pci.ep.ops = &rockchip_pcie_ep_ops;
rockchip->pci.ep.page_size = SZ_64K;
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 06/10] PCI: dw-rockchip: Add helper function for DDL indicator
2026-09-08 14:51 [PATCH v6 00/10] PCI: dw-rockchip: add system suspend support Sebastian Reichel
` (4 preceding siblings ...)
2026-09-08 14:51 ` [PATCH v6 05/10] PCI: dw-rockchip: Add helper function for controller mode Sebastian Reichel
@ 2026-09-08 14:51 ` Sebastian Reichel
2026-09-09 0:58 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 07/10] PCI: dw-rockchip: Add pme_turn_off support Sebastian Reichel
` (3 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reichel @ 2026-09-08 14:51 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Shawn Lin, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: Alexey Charkov, linux-pci, linux-arm-kernel, linux-rockchip,
linux-kernel, kernel, Sebastian Reichel
Remove code duplication and improve readability by introducing a new
function to setup the DLL indicator.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index 211776bbcb99..1e48099e36e4 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -713,6 +713,16 @@ static void rockchip_pcie_set_controller_mode(struct rockchip_pcie *rockchip, u3
rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_SET_MODE(mode), PCIE_CLIENT_GENERAL_CON);
}
+static void rockchip_pcie_unmask_dll_indicator(struct rockchip_pcie *rockchip)
+{
+ u32 val;
+
+ /* unmask DLL up/down indicator and hot reset/link-down reset */
+ val = FIELD_PREP_WM16(PCIE_RDLH_LINK_UP_CHGED, 0) |
+ FIELD_PREP_WM16(PCIE_LINK_REQ_RST_NOT_INT, 0);
+ rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_INTR_MASK_MISC);
+}
+
static int rockchip_pcie_configure_rc(struct platform_device *pdev,
struct rockchip_pcie *rockchip)
{
@@ -760,7 +770,6 @@ static int rockchip_pcie_configure_ep(struct platform_device *pdev,
{
struct device *dev = &pdev->dev;
int irq, ret;
- u32 val;
if (!IS_ENABLED(CONFIG_PCIE_ROCKCHIP_DW_EP))
return -ENODEV;
@@ -800,10 +809,7 @@ static int rockchip_pcie_configure_ep(struct platform_device *pdev,
pci_epc_init_notify(rockchip->pci.ep.epc);
- /* unmask DLL up/down indicator and hot reset/link-down reset */
- val = FIELD_PREP_WM16(PCIE_RDLH_LINK_UP_CHGED, 0) |
- FIELD_PREP_WM16(PCIE_LINK_REQ_RST_NOT_INT, 0);
- rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_INTR_MASK_MISC);
+ rockchip_pcie_unmask_dll_indicator(rockchip);
return ret;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 07/10] PCI: dw-rockchip: Add pme_turn_off support
2026-09-08 14:51 [PATCH v6 00/10] PCI: dw-rockchip: add system suspend support Sebastian Reichel
` (5 preceding siblings ...)
2026-09-08 14:51 ` [PATCH v6 06/10] PCI: dw-rockchip: Add helper function for DDL indicator Sebastian Reichel
@ 2026-09-08 14:51 ` Sebastian Reichel
2026-09-09 1:07 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 08/10] PCI: dw-rockchip: Set broken L1SS resume flag Sebastian Reichel
` (2 subsequent siblings)
9 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reichel @ 2026-09-08 14:51 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Shawn Lin, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: Alexey Charkov, linux-pci, linux-arm-kernel, linux-rockchip,
linux-kernel, kernel, Sebastian Reichel
Prepare Rockchip PCIe controller for system suspend support by
adding the PME turn off operation.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 44 +++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index 1e48099e36e4..17530507e41b 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -45,6 +45,7 @@
#define PCIE_CLIENT_LD_RQ_RST_GRT FIELD_PREP_WM16(BIT(3), 1)
#define PCIE_CLIENT_ENABLE_LTSSM FIELD_PREP_WM16(BIT(2), 1)
#define PCIE_CLIENT_DISABLE_LTSSM FIELD_PREP_WM16(BIT(2), 0)
+#define PCIE_CLIENT_INTR_STATUS_MSG_RX 0x04
/* Interrupt Status Register Related to Legacy Interrupt */
#define PCIE_CLIENT_INTR_STATUS_LEGACY 0x8
@@ -64,6 +65,11 @@
/* Interrupt Mask Register Related to Miscellaneous Operation */
#define PCIE_CLIENT_INTR_MASK_MISC 0x24
+#define PCIE_CLIENT_POWER 0x2c
+#define PCIE_CLIENT_MSG_GEN 0x34
+#define PME_READY_ENTER_L23 BIT(3)
+#define PME_TURN_OFF FIELD_PREP_WM16(BIT(4), 1)
+#define PME_TO_ACK FIELD_PREP_WM16(BIT(9), 1)
/* Power Management Control Register */
#define PCIE_CLIENT_POWER_CON 0x2c
@@ -452,8 +458,46 @@ static int rockchip_pcie_host_init(struct dw_pcie_rp *pp)
return 0;
}
+static void rockchip_pcie_pme_turn_off(struct dw_pcie_rp *pp)
+{
+ struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
+ struct rockchip_pcie *rockchip = to_rockchip_pcie(pci);
+ struct device *dev = rockchip->pci.dev;
+ u32 status;
+ int ret;
+
+ /* 1. Broadcast PME_Turn_Off Message, bit 4 self-clear once done */
+ rockchip_pcie_writel_apb(rockchip, PME_TURN_OFF, PCIE_CLIENT_MSG_GEN);
+ ret = readl_poll_timeout(rockchip->apb_base + PCIE_CLIENT_MSG_GEN,
+ status, !(status & BIT(4)), PCIE_PME_TO_L2_TIMEOUT_US / 10,
+ PCIE_PME_TO_L2_TIMEOUT_US);
+ if (ret) {
+ dev_warn(dev, "Failed to send PME_Turn_Off\n");
+ return;
+ }
+
+ /* 2. Wait for PME_TO_Ack, bit 9 will be set once received */
+ ret = readl_poll_timeout(rockchip->apb_base + PCIE_CLIENT_INTR_STATUS_MSG_RX,
+ status, status & BIT(9), PCIE_PME_TO_L2_TIMEOUT_US / 10,
+ PCIE_PME_TO_L2_TIMEOUT_US);
+ if (ret) {
+ dev_warn(dev, "Failed to receive PME_TO_Ack\n");
+ return;
+ }
+
+ /* 3. Clear PME_TO_Ack and Wait for ready to enter L23 message */
+ rockchip_pcie_writel_apb(rockchip, PME_TO_ACK, PCIE_CLIENT_INTR_STATUS_MSG_RX);
+ ret = readl_poll_timeout(rockchip->apb_base + PCIE_CLIENT_POWER,
+ status, status & PME_READY_ENTER_L23,
+ PCIE_PME_TO_L2_TIMEOUT_US / 10,
+ PCIE_PME_TO_L2_TIMEOUT_US);
+ if (ret)
+ dev_err(dev, "Failed to get ready to enter L23 message\n");
+}
+
static const struct dw_pcie_host_ops rockchip_pcie_host_ops = {
.init = rockchip_pcie_host_init,
+ .pme_turn_off = rockchip_pcie_pme_turn_off,
};
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 08/10] PCI: dw-rockchip: Set broken L1SS resume flag
2026-09-08 14:51 [PATCH v6 00/10] PCI: dw-rockchip: add system suspend support Sebastian Reichel
` (6 preceding siblings ...)
2026-09-08 14:51 ` [PATCH v6 07/10] PCI: dw-rockchip: Add pme_turn_off support Sebastian Reichel
@ 2026-09-08 14:51 ` Sebastian Reichel
2026-09-09 1:11 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 09/10] PCI: dw-rockchip: Add system PM support Sebastian Reichel
2026-09-08 14:51 ` [PATCH v6 10/10] PCI: dw-rockchip: Clear debug buffer before entering L2 Sebastian Reichel
9 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reichel @ 2026-09-08 14:51 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Shawn Lin, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: Alexey Charkov, linux-pci, linux-arm-kernel, linux-rockchip,
linux-kernel, kernel, Sebastian Reichel
Setup the broken_l1ss_resume flag, so that pci_suspend_retains_context()
returns false on the Rockchip platform allowing PCIe peripheral device
drivers to act upon.
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index 17530507e41b..47d9cab909bc 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -458,6 +458,21 @@ static int rockchip_pcie_host_init(struct dw_pcie_rp *pp)
return 0;
}
+static void rockchip_pcie_host_post_init(struct dw_pcie_rp *pp)
+{
+ /*
+ * During system suspend, the Rockchip RC driver effectively powers off
+ * the controller. If the link is in L1SS and the endpoint asserts
+ * CLKREQ# to exit L1SS, the time required to wake the system and
+ * restore the PHY/REFCLK may exceed the L1SS exit timing
+ * (L10_REFCLK_ON + T_COMMONMODE), resulting in Link Down (LDn) and a
+ * reset of the endpoint. Set this flag to indicate this limitation to
+ * client drivers so that they can avoid relying on device state being
+ * preserved during system suspend.
+ */
+ pp->bridge->broken_l1ss_resume = true;
+}
+
static void rockchip_pcie_pme_turn_off(struct dw_pcie_rp *pp)
{
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
@@ -497,6 +512,7 @@ static void rockchip_pcie_pme_turn_off(struct dw_pcie_rp *pp)
static const struct dw_pcie_host_ops rockchip_pcie_host_ops = {
.init = rockchip_pcie_host_init,
+ .post_init = rockchip_pcie_host_post_init,
.pme_turn_off = rockchip_pcie_pme_turn_off,
};
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 09/10] PCI: dw-rockchip: Add system PM support
2026-09-08 14:51 [PATCH v6 00/10] PCI: dw-rockchip: add system suspend support Sebastian Reichel
` (7 preceding siblings ...)
2026-09-08 14:51 ` [PATCH v6 08/10] PCI: dw-rockchip: Set broken L1SS resume flag Sebastian Reichel
@ 2026-09-08 14:51 ` Sebastian Reichel
2026-09-08 14:51 ` [PATCH v6 10/10] PCI: dw-rockchip: Clear debug buffer before entering L2 Sebastian Reichel
9 siblings, 0 replies; 20+ messages in thread
From: Sebastian Reichel @ 2026-09-08 14:51 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Shawn Lin, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: Alexey Charkov, linux-pci, linux-arm-kernel, linux-rockchip,
linux-kernel, kernel, Sebastian Reichel
Add system PM support for Rockchip PCIe Designware Controllers.
I've tested this on the Rockchip RK3576 EVB1, the Radxa ROCK 4D
and the ArmSom Sige5 boards.
While I haven't experienced any issues, most of my tests have been done
without any devices attached (i.e. default board without any extras), so
there _might_ still be some problems. As system suspend does not work at
all right now, I think it makes sense to get at least the basic
configurations working as soon as possible as it will allow us to catch
regressions by enabling system suspend in CI systems like KernelCI.
Co-developed-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 100 ++++++++++++++++++++++++++
1 file changed, 100 insertions(+)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index 47d9cab909bc..e675918ba184 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -120,6 +120,7 @@ struct rockchip_pcie {
struct gpio_desc *rst_gpio;
struct regulator *vpcie3v3;
struct irq_domain *irq_domain;
+ u32 intx;
const struct rockchip_pcie_of_data *data;
bool supports_clkreq;
struct delayed_work trace_work;
@@ -1042,6 +1043,99 @@ static int rockchip_pcie_rc_reset_root_port(struct pci_host_bridge *bridge,
return ret;
}
+static int rockchip_pcie_suspend(struct device *dev)
+{
+ struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
+ struct dw_pcie *pci = &rockchip->pci;
+ int ret;
+
+ if (rockchip->data->mode == DW_PCIE_EP_TYPE) {
+ dev_err(dev, "suspend is not supported in EP mode\n");
+ return -EOPNOTSUPP;
+ }
+
+ rockchip->intx = rockchip_pcie_readl_apb(rockchip, PCIE_CLIENT_INTR_MASK_LEGACY);
+
+ ret = dw_pcie_suspend_noirq(pci);
+ if (ret)
+ return ret;
+
+ gpiod_set_value_cansleep(rockchip->rst_gpio, 0);
+ rockchip_pcie_phy_deinit(rockchip);
+ clk_bulk_disable_unprepare(rockchip->clk_cnt, rockchip->clks);
+ reset_control_assert(rockchip->rst);
+ if (rockchip->vpcie3v3)
+ regulator_disable(rockchip->vpcie3v3);
+
+ return 0;
+}
+
+static int rockchip_pcie_resume(struct device *dev)
+{
+ struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
+ struct dw_pcie *pci = &rockchip->pci;
+ int ret;
+
+ if (rockchip->data->mode == DW_PCIE_EP_TYPE) {
+ dev_err(dev, "resume is not supported in EP mode\n");
+ return -EOPNOTSUPP;
+ }
+
+ ret = clk_bulk_prepare_enable(rockchip->clk_cnt, rockchip->clks);
+ if (ret) {
+ dev_err(dev, "clock init failed: %d\n", ret);
+ return ret;
+ }
+
+ if (rockchip->vpcie3v3) {
+ ret = regulator_enable(rockchip->vpcie3v3);
+ if (ret)
+ goto err_disable_clk;
+ }
+
+ ret = rockchip_pcie_phy_init(rockchip);
+ if (ret) {
+ dev_err(dev, "phy init failed: %d\n", ret);
+ goto err_disable_regulator;
+ }
+
+ reset_control_deassert(rockchip->rst);
+
+ rockchip_pcie_writel_apb(rockchip, FIELD_PREP_WM16(0xffff, rockchip->intx),
+ PCIE_CLIENT_INTR_MASK_LEGACY);
+
+ rockchip_pcie_enable_enhanced_ltssm_control_mode(rockchip, 0);
+ rockchip_pcie_set_controller_mode(rockchip, PCIE_CLIENT_MODE_RC);
+ rockchip_pcie_unmask_dll_indicator(rockchip);
+
+ gpiod_set_value_cansleep(rockchip->rst_gpio, 1);
+
+ ret = dw_pcie_resume_noirq(pci);
+ if (ret) {
+ dev_err(dev, "failed to resume: %d\n", ret);
+ /*
+ * During resume, dw_pcie_wait_for_link() is called and when
+ * there is no device connected at all it returns -EIO with
+ * the message "Device found, but not active". Ignore it for
+ * now.
+ */
+ if (ret != -EIO)
+ goto err_deinit_phy;
+ }
+
+ return 0;
+
+err_deinit_phy:
+ gpiod_set_value_cansleep(rockchip->rst_gpio, 0);
+ rockchip_pcie_phy_deinit(rockchip);
+err_disable_regulator:
+ if (rockchip->vpcie3v3)
+ regulator_disable(rockchip->vpcie3v3);
+err_disable_clk:
+ clk_bulk_disable_unprepare(rockchip->clk_cnt, rockchip->clks);
+ return ret;
+}
+
static const struct rockchip_pcie_of_data rockchip_pcie_rc_of_data_rk3568 = {
.mode = DW_PCIE_RC_TYPE,
};
@@ -1072,11 +1166,17 @@ static const struct of_device_id rockchip_pcie_of_match[] = {
{},
};
+static const struct dev_pm_ops rockchip_pcie_pm_ops = {
+ NOIRQ_SYSTEM_SLEEP_PM_OPS(rockchip_pcie_suspend,
+ rockchip_pcie_resume)
+};
+
static struct platform_driver rockchip_pcie_driver = {
.driver = {
.name = "rockchip-dw-pcie",
.of_match_table = rockchip_pcie_of_match,
.suppress_bind_attrs = true,
+ .pm = &rockchip_pcie_pm_ops,
},
.probe = rockchip_pcie_probe,
};
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH v6 10/10] PCI: dw-rockchip: Clear debug buffer before entering L2
2026-09-08 14:51 [PATCH v6 00/10] PCI: dw-rockchip: add system suspend support Sebastian Reichel
` (8 preceding siblings ...)
2026-09-08 14:51 ` [PATCH v6 09/10] PCI: dw-rockchip: Add system PM support Sebastian Reichel
@ 2026-09-08 14:51 ` Sebastian Reichel
2026-09-09 1:14 ` Shawn Lin
9 siblings, 1 reply; 20+ messages in thread
From: Sebastian Reichel @ 2026-09-08 14:51 UTC (permalink / raw)
To: Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Shawn Lin, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: Alexey Charkov, linux-pci, linux-arm-kernel, linux-rockchip,
linux-kernel, kernel, Sebastian Reichel
Clear the debug buffer before entering the L2 state to ease debugging
link training issues on resume.
Cc: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/pci/controller/dwc/pcie-dw-rockchip.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
index e675918ba184..a508f4fffd2a 100644
--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
+++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
@@ -77,6 +77,9 @@
#define PCIE_CLKREQ_NOT_READY FIELD_PREP_WM16(BIT(0), 0)
#define PCIE_CLKREQ_PULL_DOWN FIELD_PREP_WM16(GENMASK(13, 12), 1)
+/* General Debug Register */
+#define PCIE_CLIENT_GENERAL_DEBUG 0x104
+
/* RASDES TBA information */
#define PCIE_CLIENT_CDM_RASDES_TBA_INFO_CMN 0x154
#define PCIE_CLIENT_CDM_RASDES_TBA_L1_1 BIT(4)
@@ -1043,6 +1046,11 @@ static int rockchip_pcie_rc_reset_root_port(struct pci_host_bridge *bridge,
return ret;
}
+static inline void rockchip_pcie_link_status_clear(struct rockchip_pcie *rockchip)
+{
+ rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_GENERAL_DEBUG, 0x0);
+}
+
static int rockchip_pcie_suspend(struct device *dev)
{
struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
@@ -1056,6 +1064,11 @@ static int rockchip_pcie_suspend(struct device *dev)
rockchip->intx = rockchip_pcie_readl_apb(rockchip, PCIE_CLIENT_INTR_MASK_LEGACY);
+ /* All sub-devices are in D3hot by PCIe stack */
+ dw_pcie_dbi_ro_wr_dis(pci);
+
+ rockchip_pcie_link_status_clear(rockchip);
+
ret = dw_pcie_suspend_noirq(pci);
if (ret)
return ret;
--
2.53.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH v6 01/10] PCI: dw-rockchip: Fix LTSSM set functions
2026-09-08 14:51 ` [PATCH v6 01/10] PCI: dw-rockchip: Fix LTSSM set functions Sebastian Reichel
@ 2026-09-09 0:37 ` Shawn Lin
0 siblings, 0 replies; 20+ messages in thread
From: Shawn Lin @ 2026-09-09 0:37 UTC (permalink / raw)
To: Sebastian Reichel, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: shawn.lin, Alexey Charkov, linux-pci, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel
在 2026/09/08 星期二 22:51, Sebastian Reichel 写道:
> Before the Rockchip PCIe driver has been switched over to the
> FIELD_PREP_WM16 macro, PCIE_CLIENT_ENABLE_LTSSM and
> PCIE_CLIENT_DISABLE_LTSSM were setting bits with a mask of 0xc = 0b1100,
> which means BIT 2 and BIT 3. After the conversion it only sets bit 2,
> with bit 3 being handled by a separate define named
> PCIE_CLIENT_LD_RQ_RST_GRT. Apparently the conversion missed to make use
> of this new macros resulting in the third bit not being set.
>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> Fixes: 30e919570581 ("PCI: dw-rockchip: Switch to FIELD_PREP_WM16 macro")
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> index af26a07c0c9e..dc85564e5001 100644
> --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> @@ -321,14 +321,16 @@ static void rockchip_pcie_ltssm_trace(struct rockchip_pcie *rockchip,
>
> static void rockchip_pcie_enable_ltssm(struct rockchip_pcie *rockchip)
> {
> - rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_ENABLE_LTSSM,
> - PCIE_CLIENT_GENERAL_CON);
> + u32 val = PCIE_CLIENT_ENABLE_LTSSM | PCIE_CLIENT_LD_RQ_RST_GRT;
> +
> + rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_GENERAL_CON);
> }
>
> static void rockchip_pcie_disable_ltssm(struct rockchip_pcie *rockchip)
> {
> - rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_DISABLE_LTSSM,
> - PCIE_CLIENT_GENERAL_CON);
> + u32 val = PCIE_CLIENT_DISABLE_LTSSM | PCIE_CLIENT_LD_RQ_RST_GRT;
> +
> + rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_GENERAL_CON);
> }
>
> static bool rockchip_pcie_link_up(struct dw_pcie *pci)
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 02/10] PCI: dw-rockchip: Restore vpcie3v3 regulator handle
2026-09-08 14:51 ` [PATCH v6 02/10] PCI: dw-rockchip: Restore vpcie3v3 regulator handle Sebastian Reichel
@ 2026-09-09 0:44 ` Shawn Lin
0 siblings, 0 replies; 20+ messages in thread
From: Shawn Lin @ 2026-09-09 0:44 UTC (permalink / raw)
To: Sebastian Reichel, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: shawn.lin, Alexey Charkov, linux-pci, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel
在 2026/09/08 星期二 22:51, Sebastian Reichel 写道:
> This reverts commit c930b10f17c0 ("PCI: dw-rockchip: Simplify regulator
> setup with devm_regulator_get_enable_optional()"), which nicely cleaned
> up the code.
>
> The vpcie3v3 regulator handle is needed to disable the regulator during
> system suspend (to be added in its own patch).
>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 23 +++++++++++++++++------
> 1 file changed, 17 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> index dc85564e5001..f67ad3c31c35 100644
> --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> @@ -112,6 +112,7 @@ struct rockchip_pcie {
> unsigned int clk_cnt;
> struct reset_control *rst;
> struct gpio_desc *rst_gpio;
> + struct regulator *vpcie3v3;
> struct irq_domain *irq_domain;
> const struct rockchip_pcie_of_data *data;
> bool supports_clkreq;
> @@ -844,15 +845,22 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
> return ret;
>
> /* DON'T MOVE ME: must be enable before PHY init */
> - ret = devm_regulator_get_enable_optional(dev, "vpcie3v3");
> - if (ret < 0 && ret != -ENODEV)
> - return dev_err_probe(dev, ret,
> - "failed to enable vpcie3v3 regulator\n");
> + rockchip->vpcie3v3 = devm_regulator_get_optional(dev, "vpcie3v3");
> + if (IS_ERR(rockchip->vpcie3v3)) {
> + if (PTR_ERR(rockchip->vpcie3v3) != -ENODEV)
> + return dev_err_probe(dev, PTR_ERR(rockchip->vpcie3v3),
> + "failed to get vpcie3v3 regulator\n");
> + rockchip->vpcie3v3 = NULL;
> + } else {
> + ret = regulator_enable(rockchip->vpcie3v3);
> + if (ret)
> + return dev_err_probe(dev, ret,
> + "failed to enable vpcie3v3 regulator\n");
> + }
>
> ret = rockchip_pcie_phy_init(rockchip);
> if (ret)
> - return dev_err_probe(dev, ret,
> - "failed to initialize the phy\n");
> + goto disable_regulator;
>
> ret = reset_control_deassert(rockchip->rst);
> if (ret)
> @@ -885,6 +893,9 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
> clk_bulk_disable_unprepare(rockchip->clk_cnt, rockchip->clks);
> deinit_phy:
> rockchip_pcie_phy_deinit(rockchip);
> +disable_regulator:
> + if (rockchip->vpcie3v3)
> + regulator_disable(rockchip->vpcie3v3);
>
> return ret;
> }
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 03/10] PCI: dw-rockchip: Move devm_phy_get out of phy_init
2026-09-08 14:51 ` [PATCH v6 03/10] PCI: dw-rockchip: Move devm_phy_get out of phy_init Sebastian Reichel
@ 2026-09-09 0:54 ` Shawn Lin
0 siblings, 0 replies; 20+ messages in thread
From: Shawn Lin @ 2026-09-09 0:54 UTC (permalink / raw)
To: Sebastian Reichel, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: shawn.lin, Alexey Charkov, linux-pci, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel
在 2026/09/08 星期二 22:51, Sebastian Reichel 写道:
> By moving devm_phy_get() to the probe routine, rockchip_pcie_phy_init()
> can be used to re-initialize the PCIe PHY, which is for example needed
> after a system suspend/resume cycle.
>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> index f67ad3c31c35..7472ec78b473 100644
> --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> @@ -612,14 +612,8 @@ static int rockchip_pcie_resource_get(struct platform_device *pdev,
>
> static int rockchip_pcie_phy_init(struct rockchip_pcie *rockchip)
> {
> - struct device *dev = rockchip->pci.dev;
> int ret;
>
> - rockchip->phy = devm_phy_get(dev, "pcie-phy");
> - if (IS_ERR(rockchip->phy))
> - return dev_err_probe(dev, PTR_ERR(rockchip->phy),
> - "missing PHY\n");
> -
> ret = phy_init(rockchip->phy);
> if (ret < 0)
> return ret;
> @@ -858,6 +852,13 @@ static int rockchip_pcie_probe(struct platform_device *pdev)
> "failed to enable vpcie3v3 regulator\n");
> }
>
> + rockchip->phy = devm_phy_get(dev, "pcie-phy");
> + if (IS_ERR(rockchip->phy)) {
> + ret = PTR_ERR(rockchip->phy);
> + dev_err_probe(dev, ret, "missing PHY\n");
> + goto disable_regulator;
> + }
> +
> ret = rockchip_pcie_phy_init(rockchip);
> if (ret)
> goto disable_regulator;
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 04/10] PCI: dw-rockchip: Add helper function for enhanced LTSSM control mode
2026-09-08 14:51 ` [PATCH v6 04/10] PCI: dw-rockchip: Add helper function for enhanced LTSSM control mode Sebastian Reichel
@ 2026-09-09 0:56 ` Shawn Lin
0 siblings, 0 replies; 20+ messages in thread
From: Shawn Lin @ 2026-09-09 0:56 UTC (permalink / raw)
To: Sebastian Reichel, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: shawn.lin, Alexey Charkov, linux-pci, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel
在 2026/09/08 星期二 22:51, Sebastian Reichel 写道:
> Remove code duplication and improve readability by introducing a new
> function to setup the enhanced LTSSM mode.
>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 24 ++++++++++++++----------
> 1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> index 7472ec78b473..6f84b07406d4 100644
> --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> @@ -696,6 +696,18 @@ static irqreturn_t rockchip_pcie_ep_sys_irq_thread(int irq, void *arg)
> return IRQ_HANDLED;
> }
>
> +static void rockchip_pcie_enable_enhanced_ltssm_control_mode(struct rockchip_pcie *rockchip,
> + u32 flags)
> +{
> + u32 val;
> +
> + /* Enable the enhanced control mode of signal app_ltssm_enable */
> + val = FIELD_PREP_WM16(PCIE_LTSSM_ENABLE_ENHANCE, 1);
> + if (flags)
> + val |= FIELD_PREP_WM16(flags, 1);
> + rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_HOT_RESET_CTRL);
> +}
> +
> static int rockchip_pcie_configure_rc(struct platform_device *pdev,
> struct rockchip_pcie *rockchip)
> {
> @@ -719,9 +731,7 @@ static int rockchip_pcie_configure_rc(struct platform_device *pdev,
> return ret;
> }
>
> - /* LTSSM enable control mode */
> - val = FIELD_PREP_WM16(PCIE_LTSSM_ENABLE_ENHANCE, 1);
> - rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_HOT_RESET_CTRL);
> + rockchip_pcie_enable_enhanced_ltssm_control_mode(rockchip, 0);
>
> rockchip_pcie_writel_apb(rockchip,
> PCIE_CLIENT_SET_MODE(PCIE_CLIENT_MODE_RC),
> @@ -765,13 +775,7 @@ static int rockchip_pcie_configure_ep(struct platform_device *pdev,
> return ret;
> }
>
> - /*
> - * LTSSM enable control mode, and automatically delay link training on
> - * hot reset/link-down reset.
> - */
> - val = FIELD_PREP_WM16(PCIE_LTSSM_ENABLE_ENHANCE, 1) |
> - FIELD_PREP_WM16(PCIE_LTSSM_APP_DLY2_EN, 1);
> - rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_HOT_RESET_CTRL);
> + rockchip_pcie_enable_enhanced_ltssm_control_mode(rockchip, PCIE_LTSSM_APP_DLY2_EN);
>
> rockchip_pcie_writel_apb(rockchip,
> PCIE_CLIENT_SET_MODE(PCIE_CLIENT_MODE_EP),
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 05/10] PCI: dw-rockchip: Add helper function for controller mode
2026-09-08 14:51 ` [PATCH v6 05/10] PCI: dw-rockchip: Add helper function for controller mode Sebastian Reichel
@ 2026-09-09 0:58 ` Shawn Lin
0 siblings, 0 replies; 20+ messages in thread
From: Shawn Lin @ 2026-09-09 0:58 UTC (permalink / raw)
To: Sebastian Reichel, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: shawn.lin, Alexey Charkov, linux-pci, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel
在 2026/09/08 星期二 22:51, Sebastian Reichel 写道:
> Remove code duplication and improve readability by introducing a new
> function to setup the controller mode.
>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> index 6f84b07406d4..211776bbcb99 100644
> --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> @@ -708,6 +708,11 @@ static void rockchip_pcie_enable_enhanced_ltssm_control_mode(struct rockchip_pci
> rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_HOT_RESET_CTRL);
> }
>
> +static void rockchip_pcie_set_controller_mode(struct rockchip_pcie *rockchip, u32 mode)
> +{
> + rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_SET_MODE(mode), PCIE_CLIENT_GENERAL_CON);
> +}
> +
> static int rockchip_pcie_configure_rc(struct platform_device *pdev,
> struct rockchip_pcie *rockchip)
> {
> @@ -732,10 +737,7 @@ static int rockchip_pcie_configure_rc(struct platform_device *pdev,
> }
>
> rockchip_pcie_enable_enhanced_ltssm_control_mode(rockchip, 0);
> -
> - rockchip_pcie_writel_apb(rockchip,
> - PCIE_CLIENT_SET_MODE(PCIE_CLIENT_MODE_RC),
> - PCIE_CLIENT_GENERAL_CON);
> + rockchip_pcie_set_controller_mode(rockchip, PCIE_CLIENT_MODE_RC);
>
> pp = &rockchip->pci.pp;
> pp->ops = &rockchip_pcie_host_ops;
> @@ -776,10 +778,7 @@ static int rockchip_pcie_configure_ep(struct platform_device *pdev,
> }
>
> rockchip_pcie_enable_enhanced_ltssm_control_mode(rockchip, PCIE_LTSSM_APP_DLY2_EN);
> -
> - rockchip_pcie_writel_apb(rockchip,
> - PCIE_CLIENT_SET_MODE(PCIE_CLIENT_MODE_EP),
> - PCIE_CLIENT_GENERAL_CON);
> + rockchip_pcie_set_controller_mode(rockchip, PCIE_CLIENT_MODE_EP);
>
> rockchip->pci.ep.ops = &rockchip_pcie_ep_ops;
> rockchip->pci.ep.page_size = SZ_64K;
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 06/10] PCI: dw-rockchip: Add helper function for DDL indicator
2026-09-08 14:51 ` [PATCH v6 06/10] PCI: dw-rockchip: Add helper function for DDL indicator Sebastian Reichel
@ 2026-09-09 0:58 ` Shawn Lin
0 siblings, 0 replies; 20+ messages in thread
From: Shawn Lin @ 2026-09-09 0:58 UTC (permalink / raw)
To: Sebastian Reichel, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: shawn.lin, Alexey Charkov, linux-pci, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel
在 2026/09/08 星期二 22:51, Sebastian Reichel 写道:
> Remove code duplication and improve readability by introducing a new
> function to setup the DLL indicator.
>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> index 211776bbcb99..1e48099e36e4 100644
> --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> @@ -713,6 +713,16 @@ static void rockchip_pcie_set_controller_mode(struct rockchip_pcie *rockchip, u3
> rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_SET_MODE(mode), PCIE_CLIENT_GENERAL_CON);
> }
>
> +static void rockchip_pcie_unmask_dll_indicator(struct rockchip_pcie *rockchip)
> +{
> + u32 val;
> +
> + /* unmask DLL up/down indicator and hot reset/link-down reset */
> + val = FIELD_PREP_WM16(PCIE_RDLH_LINK_UP_CHGED, 0) |
> + FIELD_PREP_WM16(PCIE_LINK_REQ_RST_NOT_INT, 0);
> + rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_INTR_MASK_MISC);
> +}
> +
> static int rockchip_pcie_configure_rc(struct platform_device *pdev,
> struct rockchip_pcie *rockchip)
> {
> @@ -760,7 +770,6 @@ static int rockchip_pcie_configure_ep(struct platform_device *pdev,
> {
> struct device *dev = &pdev->dev;
> int irq, ret;
> - u32 val;
>
> if (!IS_ENABLED(CONFIG_PCIE_ROCKCHIP_DW_EP))
> return -ENODEV;
> @@ -800,10 +809,7 @@ static int rockchip_pcie_configure_ep(struct platform_device *pdev,
>
> pci_epc_init_notify(rockchip->pci.ep.epc);
>
> - /* unmask DLL up/down indicator and hot reset/link-down reset */
> - val = FIELD_PREP_WM16(PCIE_RDLH_LINK_UP_CHGED, 0) |
> - FIELD_PREP_WM16(PCIE_LINK_REQ_RST_NOT_INT, 0);
> - rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_INTR_MASK_MISC);
> + rockchip_pcie_unmask_dll_indicator(rockchip);
>
> return ret;
> }
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 07/10] PCI: dw-rockchip: Add pme_turn_off support
2026-09-08 14:51 ` [PATCH v6 07/10] PCI: dw-rockchip: Add pme_turn_off support Sebastian Reichel
@ 2026-09-09 1:07 ` Shawn Lin
0 siblings, 0 replies; 20+ messages in thread
From: Shawn Lin @ 2026-09-09 1:07 UTC (permalink / raw)
To: Sebastian Reichel, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: shawn.lin, Alexey Charkov, linux-pci, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel
在 2026/09/08 星期二 22:51, Sebastian Reichel 写道:
> Prepare Rockchip PCIe controller for system suspend support by
> adding the PME turn off operation.
>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 44 +++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> index 1e48099e36e4..17530507e41b 100644
> --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> @@ -45,6 +45,7 @@
> #define PCIE_CLIENT_LD_RQ_RST_GRT FIELD_PREP_WM16(BIT(3), 1)
> #define PCIE_CLIENT_ENABLE_LTSSM FIELD_PREP_WM16(BIT(2), 1)
> #define PCIE_CLIENT_DISABLE_LTSSM FIELD_PREP_WM16(BIT(2), 0)
> +#define PCIE_CLIENT_INTR_STATUS_MSG_RX 0x04
>
> /* Interrupt Status Register Related to Legacy Interrupt */
> #define PCIE_CLIENT_INTR_STATUS_LEGACY 0x8
> @@ -64,6 +65,11 @@
>
> /* Interrupt Mask Register Related to Miscellaneous Operation */
> #define PCIE_CLIENT_INTR_MASK_MISC 0x24
> +#define PCIE_CLIENT_POWER 0x2c
> +#define PCIE_CLIENT_MSG_GEN 0x34
> +#define PME_READY_ENTER_L23 BIT(3)
> +#define PME_TURN_OFF FIELD_PREP_WM16(BIT(4), 1)
> +#define PME_TO_ACK FIELD_PREP_WM16(BIT(9), 1)
>
> /* Power Management Control Register */
> #define PCIE_CLIENT_POWER_CON 0x2c
> @@ -452,8 +458,46 @@ static int rockchip_pcie_host_init(struct dw_pcie_rp *pp)
> return 0;
> }
>
> +static void rockchip_pcie_pme_turn_off(struct dw_pcie_rp *pp)
> +{
> + struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
> + struct rockchip_pcie *rockchip = to_rockchip_pcie(pci);
> + struct device *dev = rockchip->pci.dev;
> + u32 status;
> + int ret;
> +
> + /* 1. Broadcast PME_Turn_Off Message, bit 4 self-clear once done */
> + rockchip_pcie_writel_apb(rockchip, PME_TURN_OFF, PCIE_CLIENT_MSG_GEN);
> + ret = readl_poll_timeout(rockchip->apb_base + PCIE_CLIENT_MSG_GEN,
> + status, !(status & BIT(4)), PCIE_PME_TO_L2_TIMEOUT_US / 10,
> + PCIE_PME_TO_L2_TIMEOUT_US);
> + if (ret) {
> + dev_warn(dev, "Failed to send PME_Turn_Off\n");
> + return;
> + }
> +
> + /* 2. Wait for PME_TO_Ack, bit 9 will be set once received */
> + ret = readl_poll_timeout(rockchip->apb_base + PCIE_CLIENT_INTR_STATUS_MSG_RX,
> + status, status & BIT(9), PCIE_PME_TO_L2_TIMEOUT_US / 10,
> + PCIE_PME_TO_L2_TIMEOUT_US);
> + if (ret) {
> + dev_warn(dev, "Failed to receive PME_TO_Ack\n");
> + return;
> + }
> +
> + /* 3. Clear PME_TO_Ack and Wait for ready to enter L23 message */
> + rockchip_pcie_writel_apb(rockchip, PME_TO_ACK, PCIE_CLIENT_INTR_STATUS_MSG_RX);
> + ret = readl_poll_timeout(rockchip->apb_base + PCIE_CLIENT_POWER,
> + status, status & PME_READY_ENTER_L23,
> + PCIE_PME_TO_L2_TIMEOUT_US / 10,
> + PCIE_PME_TO_L2_TIMEOUT_US);
> + if (ret)
> + dev_err(dev, "Failed to get ready to enter L23 message\n");
> +}
> +
> static const struct dw_pcie_host_ops rockchip_pcie_host_ops = {
> .init = rockchip_pcie_host_init,
> + .pme_turn_off = rockchip_pcie_pme_turn_off,
> };
>
> /*
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 08/10] PCI: dw-rockchip: Set broken L1SS resume flag
2026-09-08 14:51 ` [PATCH v6 08/10] PCI: dw-rockchip: Set broken L1SS resume flag Sebastian Reichel
@ 2026-09-09 1:11 ` Shawn Lin
0 siblings, 0 replies; 20+ messages in thread
From: Shawn Lin @ 2026-09-09 1:11 UTC (permalink / raw)
To: Sebastian Reichel, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: shawn.lin, Alexey Charkov, linux-pci, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel
在 2026/09/08 星期二 22:51, Sebastian Reichel 写道:
> Setup the broken_l1ss_resume flag, so that pci_suspend_retains_context()
> returns false on the Rockchip platform allowing PCIe peripheral device
> drivers to act upon.
>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> index 17530507e41b..47d9cab909bc 100644
> --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> @@ -458,6 +458,21 @@ static int rockchip_pcie_host_init(struct dw_pcie_rp *pp)
> return 0;
> }
>
> +static void rockchip_pcie_host_post_init(struct dw_pcie_rp *pp)
> +{
> + /*
> + * During system suspend, the Rockchip RC driver effectively powers off
> + * the controller. If the link is in L1SS and the endpoint asserts
> + * CLKREQ# to exit L1SS, the time required to wake the system and
> + * restore the PHY/REFCLK may exceed the L1SS exit timing
> + * (L10_REFCLK_ON + T_COMMONMODE), resulting in Link Down (LDn) and a
> + * reset of the endpoint. Set this flag to indicate this limitation to
> + * client drivers so that they can avoid relying on device state being
> + * preserved during system suspend.
> + */
Yes, this is ture for Rockchip platforms that powering off the
controller as well as PHY is a default action during system suspend.
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> + pp->bridge->broken_l1ss_resume = true;
> +}
> +
> static void rockchip_pcie_pme_turn_off(struct dw_pcie_rp *pp)
> {
> struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
> @@ -497,6 +512,7 @@ static void rockchip_pcie_pme_turn_off(struct dw_pcie_rp *pp)
>
> static const struct dw_pcie_host_ops rockchip_pcie_host_ops = {
> .init = rockchip_pcie_host_init,
> + .post_init = rockchip_pcie_host_post_init,
> .pme_turn_off = rockchip_pcie_pme_turn_off,
> };
>
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH v6 10/10] PCI: dw-rockchip: Clear debug buffer before entering L2
2026-09-08 14:51 ` [PATCH v6 10/10] PCI: dw-rockchip: Clear debug buffer before entering L2 Sebastian Reichel
@ 2026-09-09 1:14 ` Shawn Lin
0 siblings, 0 replies; 20+ messages in thread
From: Shawn Lin @ 2026-09-09 1:14 UTC (permalink / raw)
To: Sebastian Reichel, Lorenzo Pieralisi, Krzysztof Wilczyński,
Manivannan Sadhasivam, Rob Herring, Bjorn Helgaas, Heiko Stuebner,
Philipp Zabel, Jingoo Han, Liam Girdwood, Mark Brown,
Yury Norov (NVIDIA), Nicolas Frattaroli
Cc: shawn.lin, Alexey Charkov, linux-pci, linux-arm-kernel,
linux-rockchip, linux-kernel, kernel
在 2026/09/08 星期二 22:51, Sebastian Reichel 写道:
> Clear the debug buffer before entering the L2 state to ease debugging
> link training issues on resume.
>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> Cc: Shawn Lin <shawn.lin@rock-chips.com>
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
> drivers/pci/controller/dwc/pcie-dw-rockchip.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> index e675918ba184..a508f4fffd2a 100644
> --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c
> @@ -77,6 +77,9 @@
> #define PCIE_CLKREQ_NOT_READY FIELD_PREP_WM16(BIT(0), 0)
> #define PCIE_CLKREQ_PULL_DOWN FIELD_PREP_WM16(GENMASK(13, 12), 1)
>
> +/* General Debug Register */
> +#define PCIE_CLIENT_GENERAL_DEBUG 0x104
> +
> /* RASDES TBA information */
> #define PCIE_CLIENT_CDM_RASDES_TBA_INFO_CMN 0x154
> #define PCIE_CLIENT_CDM_RASDES_TBA_L1_1 BIT(4)
> @@ -1043,6 +1046,11 @@ static int rockchip_pcie_rc_reset_root_port(struct pci_host_bridge *bridge,
> return ret;
> }
>
> +static inline void rockchip_pcie_link_status_clear(struct rockchip_pcie *rockchip)
> +{
> + rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_GENERAL_DEBUG, 0x0);
> +}
> +
> static int rockchip_pcie_suspend(struct device *dev)
> {
> struct rockchip_pcie *rockchip = dev_get_drvdata(dev);
> @@ -1056,6 +1064,11 @@ static int rockchip_pcie_suspend(struct device *dev)
>
> rockchip->intx = rockchip_pcie_readl_apb(rockchip, PCIE_CLIENT_INTR_MASK_LEGACY);
>
> + /* All sub-devices are in D3hot by PCIe stack */
> + dw_pcie_dbi_ro_wr_dis(pci);
> +
> + rockchip_pcie_link_status_clear(rockchip);
> +
> ret = dw_pcie_suspend_noirq(pci);
> if (ret)
> return ret;
>
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2026-09-09 1:14 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-08 14:51 [PATCH v6 00/10] PCI: dw-rockchip: add system suspend support Sebastian Reichel
2026-09-08 14:51 ` [PATCH v6 01/10] PCI: dw-rockchip: Fix LTSSM set functions Sebastian Reichel
2026-09-09 0:37 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 02/10] PCI: dw-rockchip: Restore vpcie3v3 regulator handle Sebastian Reichel
2026-09-09 0:44 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 03/10] PCI: dw-rockchip: Move devm_phy_get out of phy_init Sebastian Reichel
2026-09-09 0:54 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 04/10] PCI: dw-rockchip: Add helper function for enhanced LTSSM control mode Sebastian Reichel
2026-09-09 0:56 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 05/10] PCI: dw-rockchip: Add helper function for controller mode Sebastian Reichel
2026-09-09 0:58 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 06/10] PCI: dw-rockchip: Add helper function for DDL indicator Sebastian Reichel
2026-09-09 0:58 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 07/10] PCI: dw-rockchip: Add pme_turn_off support Sebastian Reichel
2026-09-09 1:07 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 08/10] PCI: dw-rockchip: Set broken L1SS resume flag Sebastian Reichel
2026-09-09 1:11 ` Shawn Lin
2026-09-08 14:51 ` [PATCH v6 09/10] PCI: dw-rockchip: Add system PM support Sebastian Reichel
2026-09-08 14:51 ` [PATCH v6 10/10] PCI: dw-rockchip: Clear debug buffer before entering L2 Sebastian Reichel
2026-09-09 1:14 ` Shawn Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox