Skip to content

Commit fd7155f

Browse files
committed
Merge branch 'pci/host-imx6' into for-linus
* pci/host-imx6: PCI: imx6: Put LTSSM in "Detect" state before disabling it MAINTAINERS: Add Lucas Stach as co-maintainer for i.MX6 PCI driver
2 parents 52addcf + 3e3e406 commit fd7155f

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎MAINTAINERS‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6870,7 +6870,7 @@ F: arch/x86/kernel/quirks.c
68706870

68716871
PCI DRIVER FOR IMX6
68726872
M: Richard Zhu <r65037@freescale.com>
6873-
M: Shawn Guo <shawn.guo@freescale.com>
6873+
M: Lucas Stach <l.stach@pengutronix.de>
68746874
L: linux-pci@vger.kernel.org
68756875
L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
68766876
S: Maintained

‎drivers/pci/host/pci-imx6.c‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ struct imx6_pcie {
4949

5050
/* PCIe Port Logic registers (memory-mapped) */
5151
#define PL_OFFSET 0x700
52+
#define PCIE_PL_PFLR (PL_OFFSET + 0x08)
53+
#define PCIE_PL_PFLR_LINK_STATE_MASK (0x3f << 16)
54+
#define PCIE_PL_PFLR_FORCE_LINK (1 << 15)
5255
#define PCIE_PHY_DEBUG_R0 (PL_OFFSET + 0x28)
5356
#define PCIE_PHY_DEBUG_R1 (PL_OFFSET + 0x2c)
5457
#define PCIE_PHY_DEBUG_R1_XMLH_LINK_IN_TRAINING (1 << 29)
@@ -214,6 +217,32 @@ static int imx6q_pcie_abort_handler(unsigned long addr,
214217
static int imx6_pcie_assert_core_reset(struct pcie_port *pp)
215218
{
216219
struct imx6_pcie *imx6_pcie = to_imx6_pcie(pp);
220+
u32 val, gpr1, gpr12;
221+
222+
/*
223+
* If the bootloader already enabled the link we need some special
224+
* handling to get the core back into a state where it is safe to
225+
* touch it for configuration. As there is no dedicated reset signal
226+
* wired up for MX6QDL, we need to manually force LTSSM into "detect"
227+
* state before completely disabling LTSSM, which is a prerequisite
228+
* for core configuration.
229+
*
230+
* If both LTSSM_ENABLE and REF_SSP_ENABLE are active we have a strong
231+
* indication that the bootloader activated the link.
232+
*/
233+
regmap_read(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, &gpr1);
234+
regmap_read(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, &gpr12);
235+
236+
if ((gpr1 & IMX6Q_GPR1_PCIE_REF_CLK_EN) &&
237+
(gpr12 & IMX6Q_GPR12_PCIE_CTL_2)) {
238+
val = readl(pp->dbi_base + PCIE_PL_PFLR);
239+
val &= ~PCIE_PL_PFLR_LINK_STATE_MASK;
240+
val |= PCIE_PL_PFLR_FORCE_LINK;
241+
writel(val, pp->dbi_base + PCIE_PL_PFLR);
242+
243+
regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12,
244+
IMX6Q_GPR12_PCIE_CTL_2, 0 << 10);
245+
}
217246

218247
regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
219248
IMX6Q_GPR1_PCIE_TEST_PD, 1 << 18);
@@ -589,6 +618,14 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
589618
return 0;
590619
}
591620

621+
static void imx6_pcie_shutdown(struct platform_device *pdev)
622+
{
623+
struct imx6_pcie *imx6_pcie = platform_get_drvdata(pdev);
624+
625+
/* bring down link, so bootloader gets clean state in case of reboot */
626+
imx6_pcie_assert_core_reset(&imx6_pcie->pp);
627+
}
628+
592629
static const struct of_device_id imx6_pcie_of_match[] = {
593630
{ .compatible = "fsl,imx6q-pcie", },
594631
{},
@@ -601,6 +638,7 @@ static struct platform_driver imx6_pcie_driver = {
601638
.owner = THIS_MODULE,
602639
.of_match_table = imx6_pcie_of_match,
603640
},
641+
.shutdown = imx6_pcie_shutdown,
604642
};
605643

606644
/* Freescale PCIe driver does not allow module unload */

0 commit comments

Comments
 (0)