Skip to content

Commit 935ea58

Browse files
dolcinismb49
authored andcommitted
PCI: imx6: Fix PERST# start-up sequence
BugLink: https://bugs.launchpad.net/bugs/1982409 [ Upstream commit a680994 ] According to the PCIe standard the PERST# signal (reset-gpio in fsl,imx* compatible dts) should be kept asserted for at least 100 usec before the PCIe refclock is stable, should be kept asserted for at least 100 msec after the power rails are stable and the host should wait at least 100 msec after it is de-asserted before accessing the configuration space of any attached device. From PCIe CEM r2.0, sec 2.6.2 T-PVPERL: Power stable to PERST# inactive - 100 msec T-PERST-CLK: REFCLK stable before PERST# inactive - 100 usec. From PCIe r5.0, sec 6.6.1 With a Downstream Port that does not support Link speeds greater than 5.0 GT/s, software must wait a minimum of 100 ms before sending a Configuration Request to the device immediately below that Port. Failure to do so could prevent PCIe devices to be working correctly, and this was experienced with real devices. Move reset assert to imx6_pcie_assert_core_reset(), this way we ensure that PERST# is asserted before enabling any clock, move de-assert to the end of imx6_pcie_deassert_core_reset() after the clock is enabled and deemed stable and add a new delay of 100 msec just afterward. Link: https://lore.kernel.org/all/20220211152550.286821-1-francesco.dolcini@toradex.com Link: https://lore.kernel.org/r/20220404081509.94356-1-francesco.dolcini@toradex.com Fixes: bb38919 ("PCI: imx6: Add support for i.MX6 PCIe controller") Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Reviewed-by: Lucas Stach <l.stach@pengutronix.de> Acked-by: Richard Zhu <hongxing.zhu@nxp.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 8036eb8 commit 935ea58

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

drivers/pci/controller/dwc/pci-imx6.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie)
413413
dev_err(dev, "failed to disable vpcie regulator: %d\n",
414414
ret);
415415
}
416+
417+
/* Some boards don't have PCIe reset GPIO. */
418+
if (gpio_is_valid(imx6_pcie->reset_gpio))
419+
gpio_set_value_cansleep(imx6_pcie->reset_gpio,
420+
imx6_pcie->gpio_active_high);
416421
}
417422

418423
static unsigned int imx6_pcie_grp_offset(const struct imx6_pcie *imx6_pcie)
@@ -535,15 +540,6 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
535540
/* allow the clocks to stabilize */
536541
usleep_range(200, 500);
537542

538-
/* Some boards don't have PCIe reset GPIO. */
539-
if (gpio_is_valid(imx6_pcie->reset_gpio)) {
540-
gpio_set_value_cansleep(imx6_pcie->reset_gpio,
541-
imx6_pcie->gpio_active_high);
542-
msleep(100);
543-
gpio_set_value_cansleep(imx6_pcie->reset_gpio,
544-
!imx6_pcie->gpio_active_high);
545-
}
546-
547543
switch (imx6_pcie->drvdata->variant) {
548544
case IMX8MQ:
549545
reset_control_deassert(imx6_pcie->pciephy_reset);
@@ -586,6 +582,15 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
586582
break;
587583
}
588584

585+
/* Some boards don't have PCIe reset GPIO. */
586+
if (gpio_is_valid(imx6_pcie->reset_gpio)) {
587+
msleep(100);
588+
gpio_set_value_cansleep(imx6_pcie->reset_gpio,
589+
!imx6_pcie->gpio_active_high);
590+
/* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */
591+
msleep(100);
592+
}
593+
589594
return;
590595

591596
err_ref_clk:

0 commit comments

Comments
 (0)