From: Roberto Fichera <kernel@tekno-soft.it>
To: Fabio Estevam <festevam@gmail.com>
Cc: Lucas Stach <l.stach@pengutronix.de>,
Richard Zhu <hongxing.zhu@nxp.com>,
Bjorn Helgaas <helgaas@kernel.org>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
Richard Zhu <Richard.Zhu@freescale.com>
Subject: Re: iMX6q PCIe phy link never came up on kernel v4.4.x
Date: Tue, 15 Mar 2016 15:29:42 +0100 [thread overview]
Message-ID: <56E81C56.8060404@tekno-soft.it> (raw)
In-Reply-To: <CAOMZO5C9H92mMqTPiOwMYhywBCyQuXQen3Vw==ELE-ppTtogqg@mail.gmail.com>
On 03/15/2016 03:10 PM, Fabio Estevam wrote:
> On Tue, Mar 15, 2016 at 8:08 AM, Roberto Fichera <kernel@tekno-soft.it> wrote:
>
>> Just to say that I've fixed the problem by asserting PERST before to drop PCIe refclk and enable
>> power down. PERST is finally released at the usual place.
> Excellent! Do you plan to submit a patch to fix this issue?
I don't know, in my case the problem was related to the XIO2001 that require PERST to be
asserted before to drop PCIe refclk as reported by its datasheet:
@@ -214,6 +352,16 @@ static int imx6_pcie_assert_core_reset(struct pcie_port *pp)
struct imx6_pcie *imx6_pcie = to_imx6_pcie(pp);
u32 val, gpr1, gpr12;
+ /*
+ * Our PCIe link is connected to a TI XIO2001 PCIe-to-PCI
+ * bridge and this require PERST to be asserted before to
+ * drop PCIe ref_clk otherwise it will get "confused" and
+ * the PCIe link state will stuck in POLL_STATE
+ */
+ if (gpio_is_valid(imx6_pcie->reset_gpio)) {
+ gpio_set_value(imx6_pcie->reset_gpio, 0);
+ }
+
/*
* If the bootloader already enabled the link we need some special
* handling to get the core back into a state where it is safe to
@@ -241,6 +389,7 @@ static int imx6_pcie_assert_core_reset(struct pcie_port *pp)
regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
IMX6Q_GPR1_PCIE_TEST_PD, 1 << 18);
+ udelay(10);
regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
IMX6Q_GPR1_PCIE_REF_CLK_EN, 0 << 16);
I've also slightly changed the Gen2 negotiation with this relevant part where the Gen2 speed
change is only done if necessary
@@ -387,46 +541,57 @@ static int imx6_pcie_establish_link(struct pcie_port *pp)
/* Start LTSSM. */
regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12,
- IMX6Q_GPR12_PCIE_CTL_2, 1 << 10);
-
- ret = imx6_pcie_wait_for_link(pp);
- if (ret)
- return ret;
-
- /* Allow Gen2 mode after the link is up. */
- tmp = readl(pp->dbi_base + PCIE_RC_LCR);
- tmp &= ~PCIE_RC_LCR_MAX_LINK_SPEEDS_MASK;
- tmp |= PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN2;
- writel(tmp, pp->dbi_base + PCIE_RC_LCR);
-
- /*
- * Start Directed Speed Change so the best possible speed both link
- * partners support can be negotiated.
- */
- tmp = readl(pp->dbi_base + PCIE_LINK_WIDTH_SPEED_CONTROL);
- tmp |= PORT_LOGIC_SPEED_CHANGE;
- writel(tmp, pp->dbi_base + PCIE_LINK_WIDTH_SPEED_CONTROL);
-
- ret = imx6_pcie_wait_for_speed_change(pp);
- if (ret) {
- dev_err(pp->dev, "Failed to bring link up!\n");
- return ret;
- }
+ IMX6Q_GPR12_PCIE_CTL_2, 1 << 10);
- /* Make sure link training is finished as well! */
ret = imx6_pcie_wait_for_link(pp);
- if (ret) {
- dev_err(pp->dev, "Failed to bring link up!\n");
- return ret;
+ if(ret)
+ return ret;
+
+ if(pp->link_gen == 2) {
+ /* Allow Gen2 mode after the link is up. */
+ tmp = readl(pp->dbi_base + PCIE_RC_LCR);
+ tmp &= ~PCIE_RC_LCR_MAX_LINK_SPEEDS_MASK;
+ tmp |= PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN2;
+ writel(tmp, pp->dbi_base + PCIE_RC_LCR);
+
+ /*
+ * Start Directed Speed Change so the best possible speed both link
+ * partners support can be negotiated.
+ */
+ tmp = readl(pp->dbi_base + PCIE_LINK_WIDTH_SPEED_CONTROL);
+ tmp |= PORT_LOGIC_SPEED_CHANGE;
+ writel(tmp, pp->dbi_base + PCIE_LINK_WIDTH_SPEED_CONTROL);
+
+ ret = imx6_pcie_wait_for_speed_change(pp);
+ if (ret) {
+ dev_err(pp->dev, "Failed to bring link up!\n");
+ return ret;
+ }
+
+ /* Make sure link training is finished as well! */
+ ret = imx6_pcie_wait_for_link(pp);
+ if (ret) {
+ dev_err(pp->dev, "Failed to bring link up!\n");
+ return ret;
+ }
+
+ } else {
+ dev_info(pp->dev, "Link: Gen2 disabled\n");
}
tmp = readl(pp->dbi_base + PCIE_RC_LCSR);
- dev_dbg(pp->dev, "Link up, Gen=%i\n", (tmp >> 16) & 0xf);
+ dev_info(pp->dev, "Link up, Gen=%i\n", (tmp >> 16) & 0xf);
return 0;
}
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2016-03-15 14:30 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-01 18:47 iMX6q PCIe phy link never came up on kernel v4.4.x Roberto Fichera
2016-03-02 17:13 ` Roberto Fichera
2016-03-02 19:56 ` Bjorn Helgaas
2016-03-03 9:15 ` Richard Zhu
2016-03-03 9:30 ` Roberto Fichera
2016-03-03 9:39 ` Richard Zhu
2016-03-03 10:55 ` Roberto Fichera
2016-03-03 14:34 ` Roberto Fichera
2016-03-03 18:34 ` Roberto Fichera
2016-03-04 7:11 ` Richard Zhu
2016-03-04 8:09 ` Roberto Fichera
2016-03-08 14:39 ` Roberto Fichera
2016-03-08 14:53 ` Lucas Stach
2016-03-08 14:59 ` Roberto Fichera
2016-03-10 17:35 ` Roberto Fichera
2016-03-14 8:44 ` Roberto Fichera
2016-03-15 11:08 ` Roberto Fichera
2016-03-15 14:04 ` Bjorn Helgaas
2016-03-15 14:10 ` Fabio Estevam
2016-03-15 14:29 ` Roberto Fichera [this message]
2016-03-16 14:19 ` Fabio Estevam
2016-03-16 21:33 ` Tim Harvey
2016-03-16 22:12 ` Fabio Estevam
2016-03-17 8:32 ` Roberto Fichera
2016-03-17 13:28 ` Fabio Estevam
2016-03-17 14:14 ` Roberto Fichera
2016-03-17 21:09 ` Fabio Estevam
2016-03-17 8:20 ` Roberto Fichera
2016-03-16 2:07 ` Richard Zhu
2016-03-03 9:32 ` Lucas Stach
2016-03-03 9:38 ` Roberto Fichera
2016-03-08 15:02 ` Fabio Estevam
2016-03-08 15:06 ` Roberto Fichera
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56E81C56.8060404@tekno-soft.it \
--to=kernel@tekno-soft.it \
--cc=Richard.Zhu@freescale.com \
--cc=festevam@gmail.com \
--cc=helgaas@kernel.org \
--cc=hongxing.zhu@nxp.com \
--cc=l.stach@pengutronix.de \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).