mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] PCI: imx6: Separate PERST# assertion from core reset functions
@ 2026-03-06  3:04 Sherry Sun
  2026-03-06  3:09 ` Hongxing Zhu
  2026-03-26 17:13 ` Manivannan Sadhasivam
  0 siblings, 2 replies; 3+ messages in thread
From: Sherry Sun @ 2026-03-06  3:04 UTC (permalink / raw)
  To: hongxing.zhu, l.stach, Frank.Li, bhelgaas, lpieralisi,
	kwilczynski, mani, robh, s.hauer, festevam
  Cc: imx, kernel, linux-pci, linux-arm-kernel, linux-kernel

The imx_pcie_assert_core_reset() and imx_pcie_deassert_core_reset()
functions are primarily intended to reset the RC controller itself, not
the remote PCIe endpoint devices. However, the PERST# GPIO control was
previously embedded within these functions, which conflates two distinct
reset operations.

Move the PERST# GPIO handling into a dedicated function
imx_pcie_assert_perst(). This makes the code more maintainable and
prepares for parsing the reset-gpios property according to the new
Root Port DT binding in subsequent patches.

No functional change is intended.

Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
 drivers/pci/controller/dwc/pci-imx6.c | 29 +++++++++++++++++----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index ba6e7c7ee625..d80d3be28ee5 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -901,9 +901,6 @@ static void imx_pcie_assert_core_reset(struct imx_pcie *imx_pcie)
 
 	if (imx_pcie->drvdata->core_reset)
 		imx_pcie->drvdata->core_reset(imx_pcie, true);
-
-	/* Some boards don't have PCIe reset GPIO. */
-	gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 1);
 }
 
 static void imx_pcie_deassert_core_reset(struct imx_pcie *imx_pcie)
@@ -912,14 +909,6 @@ static void imx_pcie_deassert_core_reset(struct imx_pcie *imx_pcie)
 
 	if (imx_pcie->drvdata->core_reset)
 		imx_pcie->drvdata->core_reset(imx_pcie, false);
-
-	/* Some boards don't have PCIe reset GPIO. */
-	if (imx_pcie->reset_gpiod) {
-		msleep(100);
-		gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 0);
-		/* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */
-		msleep(100);
-	}
 }
 
 static int imx_pcie_wait_for_speed_change(struct imx_pcie *imx_pcie)
@@ -1231,6 +1220,19 @@ static void imx_pcie_disable_device(struct pci_host_bridge *bridge,
 	imx_pcie_remove_lut(imx_pcie, pci_dev_id(pdev));
 }
 
+static void imx_pcie_assert_perst(struct imx_pcie *imx_pcie, bool assert)
+{
+	if (assert) {
+		gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 1);
+	} else {
+		if (imx_pcie->reset_gpiod) {
+			msleep(PCIE_T_PVPERL_MS);
+			gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 0);
+			msleep(PCIE_RESET_CONFIG_WAIT_MS);
+		}
+	}
+}
+
 static int imx_pcie_host_init(struct dw_pcie_rp *pp)
 {
 	struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
@@ -1253,6 +1255,7 @@ static int imx_pcie_host_init(struct dw_pcie_rp *pp)
 	}
 
 	imx_pcie_assert_core_reset(imx_pcie);
+	imx_pcie_assert_perst(imx_pcie, true);
 
 	if (imx_pcie->drvdata->init_phy)
 		imx_pcie->drvdata->init_phy(imx_pcie);
@@ -1291,6 +1294,7 @@ static int imx_pcie_host_init(struct dw_pcie_rp *pp)
 	imx_pcie_ltssm_disable(dev);
 
 	imx_pcie_deassert_core_reset(imx_pcie);
+	imx_pcie_assert_perst(imx_pcie, false);
 
 	if (imx_pcie->drvdata->wait_pll_lock) {
 		ret = imx_pcie->drvdata->wait_pll_lock(imx_pcie);
@@ -1587,6 +1591,7 @@ static int imx_pcie_suspend_noirq(struct device *dev)
 		 * clock which saves some power.
 		 */
 		imx_pcie_assert_core_reset(imx_pcie);
+		imx_pcie_assert_perst(imx_pcie, true);
 		imx_pcie->drvdata->enable_ref_clk(imx_pcie, false);
 	} else {
 		return dw_pcie_suspend_noirq(imx_pcie->pci);
@@ -1608,6 +1613,7 @@ static int imx_pcie_resume_noirq(struct device *dev)
 		if (ret)
 			return ret;
 		imx_pcie_deassert_core_reset(imx_pcie);
+		imx_pcie_assert_perst(imx_pcie, false);
 
 		/*
 		 * Using PCIE_TEST_PD seems to disable MSI and powers down the
@@ -1845,6 +1851,7 @@ static void imx_pcie_shutdown(struct platform_device *pdev)
 
 	/* bring down link, so bootloader gets clean state in case of reboot */
 	imx_pcie_assert_core_reset(imx_pcie);
+	imx_pcie_assert_perst(imx_pcie, true);
 }
 
 static const struct imx_pcie_drvdata drvdata[] = {
-- 
2.37.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] PCI: imx6: Separate PERST# assertion from core reset functions
  2026-03-06  3:04 [PATCH] PCI: imx6: Separate PERST# assertion from core reset functions Sherry Sun
@ 2026-03-06  3:09 ` Hongxing Zhu
  2026-03-26 17:13 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 3+ messages in thread
From: Hongxing Zhu @ 2026-03-06  3:09 UTC (permalink / raw)
  To: Sherry Sun, l.stach, Frank Li, bhelgaas, lpieralisi, kwilczynski,
	mani, robh, s.hauer, festevam
  Cc: imx, kernel, linux-pci, linux-arm-kernel, linux-kernel

> -----Original Message-----
> From: Sherry Sun <sherry.sun@nxp.com>
> Sent: 2026年3月6日 11:05
> To: Hongxing Zhu <hongxing.zhu@nxp.com>; l.stach@pengutronix.de; Frank
> Li <frank.li@nxp.com>; bhelgaas@google.com; lpieralisi@kernel.org;
> kwilczynski@kernel.org; mani@kernel.org; robh@kernel.org;
> s.hauer@pengutronix.de; festevam@gmail.com
> Cc: imx@lists.linux.dev; kernel@pengutronix.de; linux-pci@vger.kernel.org;
> linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org
> Subject: [PATCH] PCI: imx6: Separate PERST# assertion from core reset
> functions
> 
> The imx_pcie_assert_core_reset() and imx_pcie_deassert_core_reset()
> functions are primarily intended to reset the RC controller itself, not the
> remote PCIe endpoint devices. However, the PERST# GPIO control was
> previously embedded within these functions, which conflates two distinct
> reset operations.
> 
> Move the PERST# GPIO handling into a dedicated function
> imx_pcie_assert_perst(). This makes the code more maintainable and
> prepares for parsing the reset-gpios property according to the new Root
> Port DT binding in subsequent patches.
> 
> No functional change is intended.
> 
> Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>

Best Regards
Richard Zhu
> ---
>  drivers/pci/controller/dwc/pci-imx6.c | 29 +++++++++++++++++----------
>  1 file changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c
> b/drivers/pci/controller/dwc/pci-imx6.c
> index ba6e7c7ee625..d80d3be28ee5 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -901,9 +901,6 @@ static void imx_pcie_assert_core_reset(struct
> imx_pcie *imx_pcie)
> 
>  	if (imx_pcie->drvdata->core_reset)
>  		imx_pcie->drvdata->core_reset(imx_pcie, true);
> -
> -	/* Some boards don't have PCIe reset GPIO. */
> -	gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 1);
>  }
> 
>  static void imx_pcie_deassert_core_reset(struct imx_pcie *imx_pcie) @@
> -912,14 +909,6 @@ static void imx_pcie_deassert_core_reset(struct
> imx_pcie *imx_pcie)
> 
>  	if (imx_pcie->drvdata->core_reset)
>  		imx_pcie->drvdata->core_reset(imx_pcie, false);
> -
> -	/* Some boards don't have PCIe reset GPIO. */
> -	if (imx_pcie->reset_gpiod) {
> -		msleep(100);
> -		gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 0);
> -		/* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */
> -		msleep(100);
> -	}
>  }
> 
>  static int imx_pcie_wait_for_speed_change(struct imx_pcie *imx_pcie) @@
> -1231,6 +1220,19 @@ static void imx_pcie_disable_device(struct
> pci_host_bridge *bridge,
>  	imx_pcie_remove_lut(imx_pcie, pci_dev_id(pdev));  }
> 
> +static void imx_pcie_assert_perst(struct imx_pcie *imx_pcie, bool
> +assert) {
> +	if (assert) {
> +		gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 1);
> +	} else {
> +		if (imx_pcie->reset_gpiod) {
> +			msleep(PCIE_T_PVPERL_MS);
> +			gpiod_set_value_cansleep(imx_pcie->reset_gpiod, 0);
> +			msleep(PCIE_RESET_CONFIG_WAIT_MS);
> +		}
> +	}
> +}
> +
>  static int imx_pcie_host_init(struct dw_pcie_rp *pp)  {
>  	struct dw_pcie *pci = to_dw_pcie_from_pp(pp); @@ -1253,6 +1255,7
> @@ static int imx_pcie_host_init(struct dw_pcie_rp *pp)
>  	}
> 
>  	imx_pcie_assert_core_reset(imx_pcie);
> +	imx_pcie_assert_perst(imx_pcie, true);
> 
>  	if (imx_pcie->drvdata->init_phy)
>  		imx_pcie->drvdata->init_phy(imx_pcie);
> @@ -1291,6 +1294,7 @@ static int imx_pcie_host_init(struct dw_pcie_rp
> *pp)
>  	imx_pcie_ltssm_disable(dev);
> 
>  	imx_pcie_deassert_core_reset(imx_pcie);
> +	imx_pcie_assert_perst(imx_pcie, false);
> 
>  	if (imx_pcie->drvdata->wait_pll_lock) {
>  		ret = imx_pcie->drvdata->wait_pll_lock(imx_pcie);
> @@ -1587,6 +1591,7 @@ static int imx_pcie_suspend_noirq(struct device
> *dev)
>  		 * clock which saves some power.
>  		 */
>  		imx_pcie_assert_core_reset(imx_pcie);
> +		imx_pcie_assert_perst(imx_pcie, true);
>  		imx_pcie->drvdata->enable_ref_clk(imx_pcie, false);
>  	} else {
>  		return dw_pcie_suspend_noirq(imx_pcie->pci);
> @@ -1608,6 +1613,7 @@ static int imx_pcie_resume_noirq(struct device
> *dev)
>  		if (ret)
>  			return ret;
>  		imx_pcie_deassert_core_reset(imx_pcie);
> +		imx_pcie_assert_perst(imx_pcie, false);
> 
>  		/*
>  		 * Using PCIE_TEST_PD seems to disable MSI and powers down the
> @@ -1845,6 +1851,7 @@ static void imx_pcie_shutdown(struct
> platform_device *pdev)
> 
>  	/* bring down link, so bootloader gets clean state in case of reboot */
>  	imx_pcie_assert_core_reset(imx_pcie);
> +	imx_pcie_assert_perst(imx_pcie, true);
>  }
> 
>  static const struct imx_pcie_drvdata drvdata[] = {
> --
> 2.37.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] PCI: imx6: Separate PERST# assertion from core reset functions
  2026-03-06  3:04 [PATCH] PCI: imx6: Separate PERST# assertion from core reset functions Sherry Sun
  2026-03-06  3:09 ` Hongxing Zhu
@ 2026-03-26 17:13 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 3+ messages in thread
From: Manivannan Sadhasivam @ 2026-03-26 17:13 UTC (permalink / raw)
  To: hongxing.zhu, l.stach, Frank.Li, bhelgaas, lpieralisi,
	kwilczynski, robh, s.hauer, festevam, Sherry Sun
  Cc: imx, kernel, linux-pci, linux-arm-kernel, linux-kernel


On Fri, 06 Mar 2026 11:04:56 +0800, Sherry Sun wrote:
> The imx_pcie_assert_core_reset() and imx_pcie_deassert_core_reset()
> functions are primarily intended to reset the RC controller itself, not
> the remote PCIe endpoint devices. However, the PERST# GPIO control was
> previously embedded within these functions, which conflates two distinct
> reset operations.
> 
> Move the PERST# GPIO handling into a dedicated function
> imx_pcie_assert_perst(). This makes the code more maintainable and
> prepares for parsing the reset-gpios property according to the new
> Root Port DT binding in subsequent patches.
> 
> [...]

Applied, thanks!

[1/1] PCI: imx6: Separate PERST# assertion from core reset functions
      commit: 180ea823bb45eb71dd5ed0dc0b78633accd21096

Best regards,
-- 
Manivannan Sadhasivam <mani@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-26 17:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-06  3:04 [PATCH] PCI: imx6: Separate PERST# assertion from core reset functions Sherry Sun
2026-03-06  3:09 ` Hongxing Zhu
2026-03-26 17:13 ` Manivannan Sadhasivam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®