Re: [PATCH v1 1/3] PCI: imx6: Add a function to deassert the reset gpio
From: Frank Li
Date: Mon Aug 19 2024 - 10:49:37 EST
On Mon, Aug 19, 2024 at 11:03:17AM +0200, Stefan Eichenberger wrote:
> From: Stefan Eichenberger <stefan.eichenberger@xxxxxxxxxxx>
>
> To avoid code duplication, move the code to disable the reset GPIO to a
> separate function.
Add help function imx6_pcie_deassert_reset_gpio() to handle reset GPIO.
>
> Signed-off-by: Stefan Eichenberger <stefan.eichenberger@xxxxxxxxxxx>
> ---
> drivers/pci/controller/dwc/pci-imx6.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index 964d67756eb2b..fda704d82431f 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -722,6 +722,17 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie)
> gpiod_set_value_cansleep(imx6_pcie->reset_gpiod, 1);
> }
>
> +static void imx6_pcie_deassert_reset_gpio(struct imx6_pcie *imx6_pcie)
> +{
> + /* Some boards don't have PCIe reset GPIO. */
> + if (imx6_pcie->reset_gpiod) {
> + msleep(100);
> + gpiod_set_value_cansleep(imx6_pcie->reset_gpiod, 0);
> + /* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */
> + msleep(100);
> + }
> +}
> +
> static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
> {
> struct dw_pcie *pci = imx6_pcie->pci;
> @@ -766,13 +777,7 @@ static int imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
> break;
> }
>
> - /* Some boards don't have PCIe reset GPIO. */
> - if (imx6_pcie->reset_gpiod) {
> - msleep(100);
> - gpiod_set_value_cansleep(imx6_pcie->reset_gpiod, 0);
> - /* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */
> - msleep(100);
> - }
> + imx6_pcie_deassert_reset_gpio(imx6_pcie);
>
> return 0;
> }
> --
> 2.43.0
>