diff mbox series

[v1,2/3] PCI: imx6: move the wait for clock stabilization to enable ref clk

Message ID 20240819090428.17349-3-eichest@gmail.com
State New
Headers show
Series PCI: imx6: reset link after suspend/resume | expand

Commit Message

Stefan Eichenberger Aug. 19, 2024, 9:03 a.m. UTC
From: Stefan Eichenberger <stefan.eichenberger@toradex.com>

After enabling the ref clock, we should wait for the clock to stabilize.
To eliminate the need for code duplication in the future, move the
usleep to the enable_ref_clk function.

Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
---
 drivers/pci/controller/dwc/pci-imx6.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Frank Li Aug. 19, 2024, 2:45 p.m. UTC | #1
On Mon, Aug 19, 2024 at 11:03:18AM +0200, Stefan Eichenberger wrote:
> From: Stefan Eichenberger <stefan.eichenberger@toradex.com>
>
> After enabling the ref clock, we should wait for the clock to stabilize.
> To eliminate the need for code duplication in the future, move the
> usleep to the enable_ref_clk function.

Logically, it's better wait in imx6_pcie_clk_enable(). But not sure why
it can reduce duplication.

Frank

>
> Signed-off-by: Stefan Eichenberger <stefan.eichenberger@toradex.com>
> ---
>  drivers/pci/controller/dwc/pci-imx6.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index fda704d82431f..f17561791e35a 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -632,6 +632,9 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie)
>  		break;
>  	}
>
> +	/* allow the clocks to stabilize */
> +	usleep_range(200, 500);
> +
>  	return ret;
>  }
>
> @@ -672,8 +675,6 @@ static int imx6_pcie_clk_enable(struct imx6_pcie *imx6_pcie)
>  		goto err_ref_clk;
>  	}
>
> -	/* allow the clocks to stabilize */
> -	usleep_range(200, 500);
>  	return 0;
>
>  err_ref_clk:
> --
> 2.43.0
>
Stefan Eichenberger Aug. 20, 2024, 7:06 a.m. UTC | #2
On Mon, Aug 19, 2024 at 10:45:13AM -0400, Frank Li wrote:
> On Mon, Aug 19, 2024 at 11:03:18AM +0200, Stefan Eichenberger wrote:
> > From: Stefan Eichenberger <stefan.eichenberger@toradex.com>
> >
> > After enabling the ref clock, we should wait for the clock to stabilize.
> > To eliminate the need for code duplication in the future, move the
> > usleep to the enable_ref_clk function.
> 
> Logically, it's better wait in imx6_pcie_clk_enable(). But not sure why
> it can reduce duplication.

I'm using the imx6_pcie_clk_enable in the if statement on resume for the
i.MX6Q. If the sleep is not in there I have to add it there as well. I
will check if this is still necessary with your changes and if so would
update the commit message.
diff mbox series

Patch

diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index fda704d82431f..f17561791e35a 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -632,6 +632,9 @@  static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie)
 		break;
 	}
 
+	/* allow the clocks to stabilize */
+	usleep_range(200, 500);
+
 	return ret;
 }
 
@@ -672,8 +675,6 @@  static int imx6_pcie_clk_enable(struct imx6_pcie *imx6_pcie)
 		goto err_ref_clk;
 	}
 
-	/* allow the clocks to stabilize */
-	usleep_range(200, 500);
 	return 0;
 
 err_ref_clk: