Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 0/3] Workaround for IMX7d PCI-e PLL lock failure
@ 2019-02-05  0:17 Trent Piepho
  2019-02-05  0:17 ` [PATCH v2 1/3] dt-bindings: imx6q-pcie: Add description of imx7d pcie phy Trent Piepho
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Trent Piepho @ 2019-02-05  0:17 UTC (permalink / raw)
  To: linux-pci
  Cc: Lorenzo Pieralisi, Richard Zhu, Lucas Stach, Shawn Guo,
	linux-arm-kernel, Trent Piepho

This is the workaround for the IMX7d Erratum e10728, failure of
initialize PCIe PLL VCO oscillation resulting in PLL lock failure and
failure of the PCI-e link to come up.

The registers used in the workaround are based on the latest patch in
the NXP kernel.

This uses a new node of type fsl,imx7d-pcie-phy to get the PHY's
registers.  The node is found via a phandle, named fsl,imx7d-pcie-phy,
added to the PCI-e controller's node.

If the phandle is not present, or otherwise incorrect, there is a
warning message on IMX7d.

While the PHY's register could be added as another bank in the PCI-e
controller's register space, this isn't an accurate description of the
hardware.  The PHY is a different device and attached to a different
AIPS bus.

Changes since v1:
  Renamed imx-pcie-phy to imx7d-pci-phy since it appears this phy is
  specific to the imx7d.
  Split out dts binding change into its own patch.
  Changed error message to warning and improved it.

Trent Piepho (3):
  dt-bindings: imx6q-pcie: Add description of imx7d pcie phy
  ARM: dts: imx7d: Add node for PCIe PHY
  PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure

 .../devicetree/bindings/pci/fsl,imx6q-pcie.txt     | 11 +++++
 arch/arm/boot/dts/imx7d.dtsi                       |  9 ++++
 drivers/pci/controller/dwc/pci-imx6.c              | 57 ++++++++++++++++++++++
 3 files changed, 77 insertions(+)

-- 
2.14.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 1/3] dt-bindings: imx6q-pcie: Add description of imx7d pcie phy
  2019-02-05  0:17 [PATCH v2 0/3] Workaround for IMX7d PCI-e PLL lock failure Trent Piepho
@ 2019-02-05  0:17 ` Trent Piepho
  2019-02-05  9:43   ` Lucas Stach
  2019-02-05  0:17 ` [PATCH v2 2/3] ARM: dts: imx7d: Add node for PCIe PHY Trent Piepho
  2019-02-05  0:17 ` [PATCH v2 3/3] PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure Trent Piepho
  2 siblings, 1 reply; 12+ messages in thread
From: Trent Piepho @ 2019-02-05  0:17 UTC (permalink / raw)
  To: linux-pci
  Cc: Lorenzo Pieralisi, Richard Zhu, Lucas Stach, Shawn Guo,
	linux-arm-kernel, Trent Piepho

There is a separate PHY device with its own registers on imx7d.  It's
currently unused, but a PCIe erratum on imx7d will require it for the
workaround.

Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---
 Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
index d514c1f2365f..f4933c8951bc 100644
--- a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
+++ b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
@@ -53,6 +53,7 @@ Additional required properties for imx7d-pcie:
 	       - "pciephy"
 	       - "apps"
 	       - "turnoff"
+- fsl,imx7d-pcie-phy: A phandle to an fsl,imx7d-pcie-phy node.
 
 Example:
 
@@ -79,3 +80,13 @@ Example:
 		clocks = <&clks 144>, <&clks 206>, <&clks 189>;
 		clock-names = "pcie", "pcie_bus", "pcie_phy";
 	};
+
+* Freescale i.MX7d PCIe PHY
+
+This is the PHY associated with the IMX7d PCIe controller.  It's used by the
+PCI-e controller via the fsl,imx7d-pcie-phy phandle.
+
+Required properties:
+- compatible:
+	- "fsl,imx7d-pcie-phy"
+- reg: base address and length of the PCIe PHY controller
-- 
2.14.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 2/3] ARM: dts: imx7d: Add node for PCIe PHY
  2019-02-05  0:17 [PATCH v2 0/3] Workaround for IMX7d PCI-e PLL lock failure Trent Piepho
  2019-02-05  0:17 ` [PATCH v2 1/3] dt-bindings: imx6q-pcie: Add description of imx7d pcie phy Trent Piepho
@ 2019-02-05  0:17 ` Trent Piepho
  2019-02-05  9:47   ` Lucas Stach
  2019-02-05  0:17 ` [PATCH v2 3/3] PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure Trent Piepho
  2 siblings, 1 reply; 12+ messages in thread
From: Trent Piepho @ 2019-02-05  0:17 UTC (permalink / raw)
  To: linux-pci
  Cc: Lorenzo Pieralisi, Richard Zhu, Lucas Stach, Shawn Guo,
	linux-arm-kernel, Trent Piepho

This adds the PHY as a new node.  The PCI-e controller node gains a
phandle property that points to it.

There isn't yet any code in the kernel that uses this device's
registers, but it will be added for a PCIe PLL erratum workaround.

Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---
 arch/arm/boot/dts/imx7d.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/imx7d.dtsi b/arch/arm/boot/dts/imx7d.dtsi
index 6b298e388f4b..6eb98e7c568d 100644
--- a/arch/arm/boot/dts/imx7d.dtsi
+++ b/arch/arm/boot/dts/imx7d.dtsi
@@ -96,6 +96,14 @@
 	};
 };
 
+&aips2 {
+	pcie_phy: pcie-phy@306d0000 {
+		  compatible = "fsl,imx7d-pcie-phy";
+		  reg = <0x306d0000 0x10000>;
+		  status = "disabled";
+	};
+};
+
 &aips3 {
 	usbotg2: usb@30b20000 {
 		compatible = "fsl,imx7d-usb", "fsl,imx27-usb";
@@ -173,6 +181,7 @@
 			 <&src IMX7_RESET_PCIE_CTRL_APPS_EN>,
 			 <&src IMX7_RESET_PCIE_CTRL_APPS_TURNOFF>;
 		reset-names = "pciephy", "apps", "turnoff";
+		fsl,imx7d-pcie-phy = <&pcie_phy>;
 		status = "disabled";
 	};
 };
-- 
2.14.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 3/3] PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure
  2019-02-05  0:17 [PATCH v2 0/3] Workaround for IMX7d PCI-e PLL lock failure Trent Piepho
  2019-02-05  0:17 ` [PATCH v2 1/3] dt-bindings: imx6q-pcie: Add description of imx7d pcie phy Trent Piepho
  2019-02-05  0:17 ` [PATCH v2 2/3] ARM: dts: imx7d: Add node for PCIe PHY Trent Piepho
@ 2019-02-05  0:17 ` Trent Piepho
  2019-02-05  9:48   ` Lucas Stach
  2019-02-07 12:31   ` Lorenzo Pieralisi
  2 siblings, 2 replies; 12+ messages in thread
From: Trent Piepho @ 2019-02-05  0:17 UTC (permalink / raw)
  To: linux-pci
  Cc: Lorenzo Pieralisi, Richard Zhu, Lucas Stach, Shawn Guo,
	linux-arm-kernel, Trent Piepho

This implements the workound described in the NXP IMX7d erratum e10728.

Initial VCO oscillation may fail under corner conditions such as cold
temperature.  It causes PCIe PLL to fail to lock in the initialization
phase, which results in the PCIe link failing to come up.

The workaround is to disable Duty-cycle Corrector (DCC) calibration
after G_RST.

To do this it is necessary to gain access to the undocumented and
currently unused PCIe PHY register bank.  A new device tree node of type
"fsl,imx7d-pcie-phy" is created for the PHY block and the existing PCIe
device uses a phandle named "fsl,imx7d-pcie-phy" to point to it.

Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---
 drivers/pci/controller/dwc/pci-imx6.c | 57 +++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index 80f843030e36..06dd6aa927d4 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/of_gpio.h>
 #include <linux/of_device.h>
+#include <linux/of_address.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
@@ -61,6 +62,7 @@ struct imx6_pcie {
 	u32			tx_swing_low;
 	int			link_gen;
 	struct regulator	*vpcie;
+	void __iomem		*phy_base;
 
 	/* power domain for pcie */
 	struct device		*pd_pcie;
@@ -117,6 +119,23 @@ struct imx6_pcie {
 #define PCIE_PHY_RX_ASIC_OUT 0x100D
 #define PCIE_PHY_RX_ASIC_OUT_VALID	(1 << 0)
 
+/* iMX7 PCIe PHY registers */
+#define PCIE_PHY_CMN_REG4		0x14
+/* These are probably the bits that *aren't* DCC_FB_EN */
+#define PCIE_PHY_CMN_REG4_DCC_FB_EN	0x29
+
+#define PCIE_PHY_CMN_REG15	        0x54
+#define PCIE_PHY_CMN_REG15_DLY_4	BIT(2)
+#define PCIE_PHY_CMN_REG15_PLL_PD	BIT(5)
+#define PCIE_PHY_CMN_REG15_OVRD_PLL_PD	BIT(7)
+
+#define PCIE_PHY_CMN_REG24		0x90
+#define PCIE_PHY_CMN_REG24_RX_EQ	BIT(6)
+#define PCIE_PHY_CMN_REG24_RX_EQ_SEL	BIT(3)
+
+#define PCIE_PHY_CMN_REG26		0x98
+#define PCIE_PHY_CMN_REG26_ATT_MODE	0xBC
+
 #define PHY_RX_OVRD_IN_LO 0x1005
 #define PHY_RX_OVRD_IN_LO_RX_DATA_EN (1 << 5)
 #define PHY_RX_OVRD_IN_LO_RX_PLL_EN (1 << 3)
@@ -490,6 +509,26 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
 	switch (imx6_pcie->variant) {
 	case IMX7D:
 		reset_control_deassert(imx6_pcie->pciephy_reset);
+
+		/* Workaround for ERR010728, failure of PCI-e PLL VCO to
+		 * oscillate, especially when cold.  This turns off "Duty-cycle
+		 * Corrector" and other mysterious undocumented things.
+		 */
+		if (likely(imx6_pcie->phy_base)) {
+			/* De-assert DCC_FB_EN */
+			writel(PCIE_PHY_CMN_REG4_DCC_FB_EN,
+			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG4);
+			/* Assert RX_EQS and RX_EQS_SEL */
+			writel(PCIE_PHY_CMN_REG24_RX_EQ_SEL
+				| PCIE_PHY_CMN_REG24_RX_EQ,
+			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG24);
+			/* Assert ATT_MODE */
+			writel(PCIE_PHY_CMN_REG26_ATT_MODE,
+			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG26);
+		} else {
+			dev_warn(dev, "DT lacks imx7d-pcie-phy, unable to apply ERR010728 workaround\n");
+		}
+
 		imx7d_pcie_wait_for_phy_pll_lock(imx6_pcie);
 		break;
 	case IMX6SX:
@@ -919,6 +958,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct dw_pcie *pci;
 	struct imx6_pcie *imx6_pcie;
+	struct device_node *np;
 	struct resource *dbi_base;
 	struct device_node *node = dev->of_node;
 	int ret;
@@ -939,6 +979,23 @@ static int imx6_pcie_probe(struct platform_device *pdev)
 	imx6_pcie->variant =
 		(enum imx6_pcie_variants)of_device_get_match_data(dev);
 
+	/* Find the PHY if one is defined, only imx7d uses it */
+	np = of_parse_phandle(node, "fsl,imx7d-pcie-phy", 0);
+	if (np) {
+		struct resource res;
+
+		ret = of_address_to_resource(np, 0, &res);
+		if (ret) {
+			dev_err(dev, "Unable to map PCIe PHY\n");
+			return ret;
+		}
+		imx6_pcie->phy_base = devm_ioremap_resource(dev, &res);
+		if (IS_ERR(imx6_pcie->phy_base)) {
+			dev_err(dev, "Unable to map PCIe PHY\n");
+			return PTR_ERR(imx6_pcie->phy_base);
+		}
+	}
+
 	dbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	pci->dbi_base = devm_ioremap_resource(dev, dbi_base);
 	if (IS_ERR(pci->dbi_base))
-- 
2.14.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/3] dt-bindings: imx6q-pcie: Add description of imx7d pcie phy
  2019-02-05  0:17 ` [PATCH v2 1/3] dt-bindings: imx6q-pcie: Add description of imx7d pcie phy Trent Piepho
@ 2019-02-05  9:43   ` Lucas Stach
  0 siblings, 0 replies; 12+ messages in thread
From: Lucas Stach @ 2019-02-05  9:43 UTC (permalink / raw)
  To: Trent Piepho, linux-pci, Rob Herring
  Cc: Richard Zhu, Lorenzo Pieralisi, Shawn Guo, linux-arm-kernel, devicetree

Am Dienstag, den 05.02.2019, 00:17 +0000 schrieb Trent Piepho:
> There is a separate PHY device with its own registers on imx7d.  It's
> currently unused, but a PCIe erratum on imx7d will require it for the
> workaround.
> 
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

I'm generally fine with this, but really want to see an Ack from the DT
folks (CC'ed) on this.

Acked-by: Lucas Stach <l.stach@pengutronix.de>

Regards,
Lucas

> ---
>  Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
> index d514c1f2365f..f4933c8951bc 100644
> --- a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
> +++ b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
> @@ -53,6 +53,7 @@ Additional required properties for imx7d-pcie:
> >  	       - "pciephy"
> >  	       - "apps"
> >  	       - "turnoff"
> +- fsl,imx7d-pcie-phy: A phandle to an fsl,imx7d-pcie-phy node.
>  
>  Example:
>  
> @@ -79,3 +80,13 @@ Example:
> >  		clocks = <&clks 144>, <&clks 206>, <&clks 189>;
> >  		clock-names = "pcie", "pcie_bus", "pcie_phy";
> >  	};
> +
> +* Freescale i.MX7d PCIe PHY
> +
> +This is the PHY associated with the IMX7d PCIe controller.  It's used by the
> +PCI-e controller via the fsl,imx7d-pcie-phy phandle.
> +
> +Required properties:
> +- compatible:
> > +	- "fsl,imx7d-pcie-phy"
> +- reg: base address and length of the PCIe PHY controller

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/3] ARM: dts: imx7d: Add node for PCIe PHY
  2019-02-05  0:17 ` [PATCH v2 2/3] ARM: dts: imx7d: Add node for PCIe PHY Trent Piepho
@ 2019-02-05  9:47   ` Lucas Stach
  0 siblings, 0 replies; 12+ messages in thread
From: Lucas Stach @ 2019-02-05  9:47 UTC (permalink / raw)
  To: Trent Piepho, linux-pci
  Cc: Richard Zhu, Lorenzo Pieralisi, Shawn Guo, linux-arm-kernel

Am Dienstag, den 05.02.2019, 00:17 +0000 schrieb Trent Piepho:
> This adds the PHY as a new node.  The PCI-e controller node gains a
> phandle property that points to it.
> 
> There isn't yet any code in the kernel that uses this device's
> registers, but it will be added for a PCIe PLL erratum workaround.
> 
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Looks good, but needs an Ack on the binding change. Also this should go
through Shawns tree, so needs to be split out from the series.

Regards,
Lucas

> ---
>  arch/arm/boot/dts/imx7d.dtsi | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/imx7d.dtsi b/arch/arm/boot/dts/imx7d.dtsi
> index 6b298e388f4b..6eb98e7c568d 100644
> --- a/arch/arm/boot/dts/imx7d.dtsi
> +++ b/arch/arm/boot/dts/imx7d.dtsi
> @@ -96,6 +96,14 @@
> >  	};
>  };
>  
> +&aips2 {
> +	pcie_phy: pcie-phy@306d0000 {
> +		  compatible = "fsl,imx7d-pcie-phy";
> +		  reg = <0x306d0000 0x10000>;
> +		  status = "disabled";
> +	};
> +};
> +
>  &aips3 {
>  	usbotg2: usb@30b20000 {
>  		compatible = "fsl,imx7d-usb", "fsl,imx27-usb";
> @@ -173,6 +181,7 @@
>  			 <&src IMX7_RESET_PCIE_CTRL_APPS_EN>,
>  			 <&src IMX7_RESET_PCIE_CTRL_APPS_TURNOFF>;
>  		reset-names = "pciephy", "apps", "turnoff";
> +		fsl,imx7d-pcie-phy = <&pcie_phy>;
>  		status = "disabled";
>  	};
>  };

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/3] PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure
  2019-02-05  0:17 ` [PATCH v2 3/3] PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure Trent Piepho
@ 2019-02-05  9:48   ` Lucas Stach
  2019-02-07 12:31   ` Lorenzo Pieralisi
  1 sibling, 0 replies; 12+ messages in thread
From: Lucas Stach @ 2019-02-05  9:48 UTC (permalink / raw)
  To: Trent Piepho, linux-pci
  Cc: Richard Zhu, Lorenzo Pieralisi, Shawn Guo, linux-arm-kernel

Am Dienstag, den 05.02.2019, 00:17 +0000 schrieb Trent Piepho:
> This implements the workound described in the NXP IMX7d erratum e10728.
> 
> Initial VCO oscillation may fail under corner conditions such as cold
> temperature.  It causes PCIe PLL to fail to lock in the initialization
> phase, which results in the PCIe link failing to come up.
> 
> The workaround is to disable Duty-cycle Corrector (DCC) calibration
> after G_RST.
> 
> To do this it is necessary to gain access to the undocumented and
> currently unused PCIe PHY register bank.  A new device tree node of type
> "fsl,imx7d-pcie-phy" is created for the PHY block and the existing PCIe
> device uses a phandle named "fsl,imx7d-pcie-phy" to point to it.
> 
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Reviewed-by: Lucas Stach <l.stach@pengutronix.de>

> ---
>  drivers/pci/controller/dwc/pci-imx6.c | 57 +++++++++++++++++++++++++++++++++++
>  1 file changed, 57 insertions(+)
> 
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index 80f843030e36..06dd6aa927d4 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -18,6 +18,7 @@
>  #include <linux/module.h>
>  #include <linux/of_gpio.h>
>  #include <linux/of_device.h>
> +#include <linux/of_address.h>
>  #include <linux/pci.h>
>  #include <linux/platform_device.h>
>  #include <linux/regmap.h>
> @@ -61,6 +62,7 @@ struct imx6_pcie {
> > >  	u32			tx_swing_low;
> > >  	int			link_gen;
> > >  	struct regulator	*vpcie;
> > > +	void __iomem		*phy_base;
>  
> >  	/* power domain for pcie */
> > >  	struct device		*pd_pcie;
> @@ -117,6 +119,23 @@ struct imx6_pcie {
>  #define PCIE_PHY_RX_ASIC_OUT 0x100D
> >  #define PCIE_PHY_RX_ASIC_OUT_VALID	(1 << 0)
>  
> +/* iMX7 PCIe PHY registers */
> > +#define PCIE_PHY_CMN_REG4		0x14
> +/* These are probably the bits that *aren't* DCC_FB_EN */
> > +#define PCIE_PHY_CMN_REG4_DCC_FB_EN	0x29
> +
> > +#define PCIE_PHY_CMN_REG15	        0x54
> > +#define PCIE_PHY_CMN_REG15_DLY_4	BIT(2)
> > +#define PCIE_PHY_CMN_REG15_PLL_PD	BIT(5)
> > +#define PCIE_PHY_CMN_REG15_OVRD_PLL_PD	BIT(7)
> +
> > +#define PCIE_PHY_CMN_REG24		0x90
> > +#define PCIE_PHY_CMN_REG24_RX_EQ	BIT(6)
> > +#define PCIE_PHY_CMN_REG24_RX_EQ_SEL	BIT(3)
> +
> > +#define PCIE_PHY_CMN_REG26		0x98
> > +#define PCIE_PHY_CMN_REG26_ATT_MODE	0xBC
> +
>  #define PHY_RX_OVRD_IN_LO 0x1005
>  #define PHY_RX_OVRD_IN_LO_RX_DATA_EN (1 << 5)
>  #define PHY_RX_OVRD_IN_LO_RX_PLL_EN (1 << 3)
> @@ -490,6 +509,26 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
> >  	switch (imx6_pcie->variant) {
> >  	case IMX7D:
> >  		reset_control_deassert(imx6_pcie->pciephy_reset);
> +
> > +		/* Workaround for ERR010728, failure of PCI-e PLL VCO to
> > +		 * oscillate, especially when cold.  This turns off "Duty-cycle
> > +		 * Corrector" and other mysterious undocumented things.
> > +		 */
> > +		if (likely(imx6_pcie->phy_base)) {
> > +			/* De-assert DCC_FB_EN */
> > +			writel(PCIE_PHY_CMN_REG4_DCC_FB_EN,
> > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG4);
> > +			/* Assert RX_EQS and RX_EQS_SEL */
> > +			writel(PCIE_PHY_CMN_REG24_RX_EQ_SEL
> > +				| PCIE_PHY_CMN_REG24_RX_EQ,
> > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG24);
> > +			/* Assert ATT_MODE */
> > +			writel(PCIE_PHY_CMN_REG26_ATT_MODE,
> > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG26);
> > +		} else {
> > +			dev_warn(dev, "DT lacks imx7d-pcie-phy, unable to apply ERR010728 workaround\n");
> > +		}
> +
> >  		imx7d_pcie_wait_for_phy_pll_lock(imx6_pcie);
> >  		break;
> >  	case IMX6SX:
> @@ -919,6 +958,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)
> >  	struct device *dev = &pdev->dev;
> >  	struct dw_pcie *pci;
> >  	struct imx6_pcie *imx6_pcie;
> > +	struct device_node *np;
> >  	struct resource *dbi_base;
> >  	struct device_node *node = dev->of_node;
> >  	int ret;
> @@ -939,6 +979,23 @@ static int imx6_pcie_probe(struct platform_device *pdev)
> >  	imx6_pcie->variant =
> >  		(enum imx6_pcie_variants)of_device_get_match_data(dev);
>  
> > +	/* Find the PHY if one is defined, only imx7d uses it */
> > +	np = of_parse_phandle(node, "fsl,imx7d-pcie-phy", 0);
> > +	if (np) {
> > +		struct resource res;
> +
> > +		ret = of_address_to_resource(np, 0, &res);
> > +		if (ret) {
> > +			dev_err(dev, "Unable to map PCIe PHY\n");
> > +			return ret;
> > +		}
> > +		imx6_pcie->phy_base = devm_ioremap_resource(dev, &res);
> > +		if (IS_ERR(imx6_pcie->phy_base)) {
> > +			dev_err(dev, "Unable to map PCIe PHY\n");
> > +			return PTR_ERR(imx6_pcie->phy_base);
> > +		}
> > +	}
> +
> >  	dbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >  	pci->dbi_base = devm_ioremap_resource(dev, dbi_base);
> >  	if (IS_ERR(pci->dbi_base))

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/3] PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure
  2019-02-05  0:17 ` [PATCH v2 3/3] PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure Trent Piepho
  2019-02-05  9:48   ` Lucas Stach
@ 2019-02-07 12:31   ` Lorenzo Pieralisi
  2019-02-07 18:15     ` Trent Piepho
  1 sibling, 1 reply; 12+ messages in thread
From: Lorenzo Pieralisi @ 2019-02-07 12:31 UTC (permalink / raw)
  To: Trent Piepho
  Cc: linux-pci, Richard Zhu, Shawn Guo, linux-arm-kernel, Lucas Stach

On Tue, Feb 05, 2019 at 12:17:41AM +0000, Trent Piepho wrote:
> This implements the workound described in the NXP IMX7d erratum e10728.
> 
> Initial VCO oscillation may fail under corner conditions such as cold
> temperature.  It causes PCIe PLL to fail to lock in the initialization
> phase, which results in the PCIe link failing to come up.
> 
> The workaround is to disable Duty-cycle Corrector (DCC) calibration
> after G_RST.
> 
> To do this it is necessary to gain access to the undocumented and
> currently unused PCIe PHY register bank.  A new device tree node of type
> "fsl,imx7d-pcie-phy" is created for the PHY block and the existing PCIe
> device uses a phandle named "fsl,imx7d-pcie-phy" to point to it.
> 
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>
> ---
>  drivers/pci/controller/dwc/pci-imx6.c | 57 +++++++++++++++++++++++++++++++++++
>  1 file changed, 57 insertions(+)
> 
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index 80f843030e36..06dd6aa927d4 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -18,6 +18,7 @@
>  #include <linux/module.h>
>  #include <linux/of_gpio.h>
>  #include <linux/of_device.h>
> +#include <linux/of_address.h>
>  #include <linux/pci.h>
>  #include <linux/platform_device.h>
>  #include <linux/regmap.h>
> @@ -61,6 +62,7 @@ struct imx6_pcie {
>  	u32			tx_swing_low;
>  	int			link_gen;
>  	struct regulator	*vpcie;
> +	void __iomem		*phy_base;
>  
>  	/* power domain for pcie */
>  	struct device		*pd_pcie;
> @@ -117,6 +119,23 @@ struct imx6_pcie {
>  #define PCIE_PHY_RX_ASIC_OUT 0x100D
>  #define PCIE_PHY_RX_ASIC_OUT_VALID	(1 << 0)
>  
> +/* iMX7 PCIe PHY registers */
> +#define PCIE_PHY_CMN_REG4		0x14
> +/* These are probably the bits that *aren't* DCC_FB_EN */
> +#define PCIE_PHY_CMN_REG4_DCC_FB_EN	0x29
> +
> +#define PCIE_PHY_CMN_REG15	        0x54
> +#define PCIE_PHY_CMN_REG15_DLY_4	BIT(2)
> +#define PCIE_PHY_CMN_REG15_PLL_PD	BIT(5)
> +#define PCIE_PHY_CMN_REG15_OVRD_PLL_PD	BIT(7)
> +
> +#define PCIE_PHY_CMN_REG24		0x90
> +#define PCIE_PHY_CMN_REG24_RX_EQ	BIT(6)
> +#define PCIE_PHY_CMN_REG24_RX_EQ_SEL	BIT(3)
> +
> +#define PCIE_PHY_CMN_REG26		0x98
> +#define PCIE_PHY_CMN_REG26_ATT_MODE	0xBC
> +
>  #define PHY_RX_OVRD_IN_LO 0x1005
>  #define PHY_RX_OVRD_IN_LO_RX_DATA_EN (1 << 5)
>  #define PHY_RX_OVRD_IN_LO_RX_PLL_EN (1 << 3)
> @@ -490,6 +509,26 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
>  	switch (imx6_pcie->variant) {
>  	case IMX7D:
>  		reset_control_deassert(imx6_pcie->pciephy_reset);
> +
> +		/* Workaround for ERR010728, failure of PCI-e PLL VCO to
> +		 * oscillate, especially when cold.  This turns off "Duty-cycle
> +		 * Corrector" and other mysterious undocumented things.
> +		 */
> +		if (likely(imx6_pcie->phy_base)) {

Nit: this is not a fast-path, so this branch performance is hardly
relevant.

> +			/* De-assert DCC_FB_EN */
> +			writel(PCIE_PHY_CMN_REG4_DCC_FB_EN,
> +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG4);
> +			/* Assert RX_EQS and RX_EQS_SEL */
> +			writel(PCIE_PHY_CMN_REG24_RX_EQ_SEL
> +				| PCIE_PHY_CMN_REG24_RX_EQ,
> +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG24);
> +			/* Assert ATT_MODE */
> +			writel(PCIE_PHY_CMN_REG26_ATT_MODE,
> +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG26);
> +		} else {
> +			dev_warn(dev, "DT lacks imx7d-pcie-phy, unable to apply ERR010728 workaround\n");

It is a nit but the warning log is not necessarily true ie you may not
have a mapped address for other reasons as well. It is up to you but I
would change the log message.

Thanks,
Lorenzo

> +		}
> +
>  		imx7d_pcie_wait_for_phy_pll_lock(imx6_pcie);
>  		break;
>  	case IMX6SX:
> @@ -919,6 +958,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)
>  	struct device *dev = &pdev->dev;
>  	struct dw_pcie *pci;
>  	struct imx6_pcie *imx6_pcie;
> +	struct device_node *np;
>  	struct resource *dbi_base;
>  	struct device_node *node = dev->of_node;
>  	int ret;
> @@ -939,6 +979,23 @@ static int imx6_pcie_probe(struct platform_device *pdev)
>  	imx6_pcie->variant =
>  		(enum imx6_pcie_variants)of_device_get_match_data(dev);
>  
> +	/* Find the PHY if one is defined, only imx7d uses it */
> +	np = of_parse_phandle(node, "fsl,imx7d-pcie-phy", 0);
> +	if (np) {
> +		struct resource res;
> +
> +		ret = of_address_to_resource(np, 0, &res);
> +		if (ret) {
> +			dev_err(dev, "Unable to map PCIe PHY\n");
> +			return ret;
> +		}
> +		imx6_pcie->phy_base = devm_ioremap_resource(dev, &res);
> +		if (IS_ERR(imx6_pcie->phy_base)) {
> +			dev_err(dev, "Unable to map PCIe PHY\n");
> +			return PTR_ERR(imx6_pcie->phy_base);
> +		}
> +	}
> +
>  	dbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	pci->dbi_base = devm_ioremap_resource(dev, dbi_base);
>  	if (IS_ERR(pci->dbi_base))
> -- 
> 2.14.4
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/3] PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure
  2019-02-07 12:31   ` Lorenzo Pieralisi
@ 2019-02-07 18:15     ` Trent Piepho
  2019-02-08 10:18       ` Lorenzo Pieralisi
  0 siblings, 1 reply; 12+ messages in thread
From: Trent Piepho @ 2019-02-07 18:15 UTC (permalink / raw)
  To: lorenzo.pieralisi
  Cc: linux-pci, hongxing.zhu, shawnguo, linux-arm-kernel, l.stach

On Thu, 2019-02-07 at 12:31 +0000, Lorenzo Pieralisi wrote:
> +			/* De-assert DCC_FB_EN */
> > +			writel(PCIE_PHY_CMN_REG4_DCC_FB_EN,
> > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG4);
> > +			/* Assert RX_EQS and RX_EQS_SEL */
> > +			writel(PCIE_PHY_CMN_REG24_RX_EQ_SEL
> > +				| PCIE_PHY_CMN_REG24_RX_EQ,
> > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG24);
> > +			/* Assert ATT_MODE */
> > +			writel(PCIE_PHY_CMN_REG26_ATT_MODE,
> > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG26);
> > +		} else {
> > +			dev_warn(dev, "DT lacks imx7d-pcie-phy, unable to apply ERR010728 workaround\n");
> 
> It is a nit but the warning log is not necessarily true ie you may not
> have a mapped address for other reasons as well. It is up to you but I
> would change the log message.

True, but I hardly want to enumerate every possible failure point in a
log message.  How about:

Unable to apply ERR010728 workaround.  DT lacks imx7d-pcie-phy?
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/3] PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure
  2019-02-07 18:15     ` Trent Piepho
@ 2019-02-08 10:18       ` Lorenzo Pieralisi
  2019-02-08 18:19         ` Trent Piepho
  0 siblings, 1 reply; 12+ messages in thread
From: Lorenzo Pieralisi @ 2019-02-08 10:18 UTC (permalink / raw)
  To: Trent Piepho; +Cc: linux-pci, hongxing.zhu, shawnguo, linux-arm-kernel, l.stach

On Thu, Feb 07, 2019 at 06:15:52PM +0000, Trent Piepho wrote:
> On Thu, 2019-02-07 at 12:31 +0000, Lorenzo Pieralisi wrote:
> > +			/* De-assert DCC_FB_EN */
> > > +			writel(PCIE_PHY_CMN_REG4_DCC_FB_EN,
> > > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG4);
> > > +			/* Assert RX_EQS and RX_EQS_SEL */
> > > +			writel(PCIE_PHY_CMN_REG24_RX_EQ_SEL
> > > +				| PCIE_PHY_CMN_REG24_RX_EQ,
> > > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG24);
> > > +			/* Assert ATT_MODE */
> > > +			writel(PCIE_PHY_CMN_REG26_ATT_MODE,
> > > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG26);
> > > +		} else {
> > > +			dev_warn(dev, "DT lacks imx7d-pcie-phy, unable to apply ERR010728 workaround\n");
> > 
> > It is a nit but the warning log is not necessarily true ie you may not
> > have a mapped address for other reasons as well. It is up to you but I
> > would change the log message.
> 
> True, but I hardly want to enumerate every possible failure point in a
> log message.  How about:
> 
> Unable to apply ERR010728 workaround.  DT lacks imx7d-pcie-phy?

I would just log "Unable to apply ERR010728 workaround" but it is up
to you. I can make the change myself with no need for reposting.

Lorenzo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/3] PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure
  2019-02-08 10:18       ` Lorenzo Pieralisi
@ 2019-02-08 18:19         ` Trent Piepho
  2019-02-11 12:18           ` Lorenzo Pieralisi
  0 siblings, 1 reply; 12+ messages in thread
From: Trent Piepho @ 2019-02-08 18:19 UTC (permalink / raw)
  To: lorenzo.pieralisi
  Cc: linux-pci, hongxing.zhu, shawnguo, linux-arm-kernel, l.stach

On Fri, 2019-02-08 at 10:18 +0000, Lorenzo Pieralisi wrote:
> On Thu, Feb 07, 2019 at 06:15:52PM +0000, Trent Piepho wrote:
> > On Thu, 2019-02-07 at 12:31 +0000, Lorenzo Pieralisi wrote:
> > > +			/* De-assert DCC_FB_EN */
> > > > +			writel(PCIE_PHY_CMN_REG4_DCC_FB_EN,
> > > > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG4);
> > > > +			/* Assert RX_EQS and RX_EQS_SEL */
> > > > +			writel(PCIE_PHY_CMN_REG24_RX_EQ_SEL
> > > > +				| PCIE_PHY_CMN_REG24_RX_EQ,
> > > > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG24);
> > > > +			/* Assert ATT_MODE */
> > > > +			writel(PCIE_PHY_CMN_REG26_ATT_MODE,
> > > > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG26);
> > > > +		} else {
> > > > +			dev_warn(dev, "DT lacks imx7d-pcie-phy, unable to apply ERR010728 workaround\n");
> > > 
> > > It is a nit but the warning log is not necessarily true ie you may not
> > > have a mapped address for other reasons as well. It is up to you but I
> > > would change the log message.
> > 
> > True, but I hardly want to enumerate every possible failure point in a
> > log message.  How about:
> > 
> > Unable to apply ERR010728 workaround.  DT lacks imx7d-pcie-phy?
> 
> I would just log "Unable to apply ERR010728 workaround" but it is up
> to you. I can make the change myself with no need for reposting.

I was following Lucas's comment on the v1 version:

   the user. It would be better to have something like "No access to
   PHY registers, can't apply workaround for ERR010728." Maybe even
   with a hint to update the DT.

I think the pretty much the only way any of the errors conditions will
get hit, is when someone with an old DT runs a new kernel.  So the hint
about the DT change might be actually useful to some users.

But it's not a big deal so just change it to whatever when applying the
patch.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/3] PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure
  2019-02-08 18:19         ` Trent Piepho
@ 2019-02-11 12:18           ` Lorenzo Pieralisi
  0 siblings, 0 replies; 12+ messages in thread
From: Lorenzo Pieralisi @ 2019-02-11 12:18 UTC (permalink / raw)
  To: Trent Piepho; +Cc: linux-pci, hongxing.zhu, shawnguo, linux-arm-kernel, l.stach

On Fri, Feb 08, 2019 at 06:19:10PM +0000, Trent Piepho wrote:
> On Fri, 2019-02-08 at 10:18 +0000, Lorenzo Pieralisi wrote:
> > On Thu, Feb 07, 2019 at 06:15:52PM +0000, Trent Piepho wrote:
> > > On Thu, 2019-02-07 at 12:31 +0000, Lorenzo Pieralisi wrote:
> > > > +			/* De-assert DCC_FB_EN */
> > > > > +			writel(PCIE_PHY_CMN_REG4_DCC_FB_EN,
> > > > > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG4);
> > > > > +			/* Assert RX_EQS and RX_EQS_SEL */
> > > > > +			writel(PCIE_PHY_CMN_REG24_RX_EQ_SEL
> > > > > +				| PCIE_PHY_CMN_REG24_RX_EQ,
> > > > > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG24);
> > > > > +			/* Assert ATT_MODE */
> > > > > +			writel(PCIE_PHY_CMN_REG26_ATT_MODE,
> > > > > +			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG26);
> > > > > +		} else {
> > > > > +			dev_warn(dev, "DT lacks imx7d-pcie-phy, unable to apply ERR010728 workaround\n");
> > > > 
> > > > It is a nit but the warning log is not necessarily true ie you may not
> > > > have a mapped address for other reasons as well. It is up to you but I
> > > > would change the log message.
> > > 
> > > True, but I hardly want to enumerate every possible failure point in a
> > > log message.  How about:
> > > 
> > > Unable to apply ERR010728 workaround.  DT lacks imx7d-pcie-phy?
> > 
> > I would just log "Unable to apply ERR010728 workaround" but it is up
> > to you. I can make the change myself with no need for reposting.
> 
> I was following Lucas's comment on the v1 version:
> 
>    the user. It would be better to have something like "No access to
>    PHY registers, can't apply workaround for ERR010728." Maybe even
>    with a hint to update the DT.
> 
> I think the pretty much the only way any of the errors conditions will
> get hit, is when someone with an old DT runs a new kernel.  So the hint
> about the DT change might be actually useful to some users.
> 
> But it's not a big deal so just change it to whatever when applying the
> patch.

Applied the series to pci/dwc for v5.1, please have a look to check
if we are in agreement (slightly tweaked the log string), thanks.

Lorenzo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, back to index

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-05  0:17 [PATCH v2 0/3] Workaround for IMX7d PCI-e PLL lock failure Trent Piepho
2019-02-05  0:17 ` [PATCH v2 1/3] dt-bindings: imx6q-pcie: Add description of imx7d pcie phy Trent Piepho
2019-02-05  9:43   ` Lucas Stach
2019-02-05  0:17 ` [PATCH v2 2/3] ARM: dts: imx7d: Add node for PCIe PHY Trent Piepho
2019-02-05  9:47   ` Lucas Stach
2019-02-05  0:17 ` [PATCH v2 3/3] PCI: imx: Add workaround for e10728, IMX7d PCIe PLL failure Trent Piepho
2019-02-05  9:48   ` Lucas Stach
2019-02-07 12:31   ` Lorenzo Pieralisi
2019-02-07 18:15     ` Trent Piepho
2019-02-08 10:18       ` Lorenzo Pieralisi
2019-02-08 18:19         ` Trent Piepho
2019-02-11 12:18           ` Lorenzo Pieralisi

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org infradead-linux-arm-kernel@archiver.kernel.org
	public-inbox-index linux-arm-kernel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox