Skip to contentSkip to conversation

Add PCIe support for i.MX6q

PATCH New Sean Cross 12 participants 30 messages Sep 16, 2013 – Nov 28, 2013

Subsystems (9)
lore
Share & tools
lore

Sean Cross

author
#0 lore raw

v6 cover Add PCIe support for i.MX6q

This patchset adds support for the PCI Express port present on the i.MX6 SoC. The port is based on Synopsis Designware IP with a custom PHY.

Changes since v5:
- Changed "compatible" to "fsl,imx6q-pcie"
- Moved clock_prepare_enable calls back into driver
- Removed clk lookups for lvds[12]_gate

Changes since v4:
- Add an abort exception handler
- Fix register ordering in imx6q-iomuxc-gpr.h
- Enable sata_ref_100m during clock initialization
- Minor changes to lvds[12]_gate definitions

Changes since v3:
- Moved clock initialization to board clock file
- Reworked memory range layout
- Reduced the duration of several sleep calls

Changes since v2:
- Reworked source file with Sascha Hauer's suggestions

Changes since v1:
- Use the Designware controller code for BAR initialization

Sean Cross (3):
ARM: imx: Add LVDS general-purpose clocks to i.MX6Q
ARM: imx6q: Add PCIe bits to GPR syscon definition
PCI: imx6: Add support for i.MX6 PCIe controller

 .../devicetree/bindings/clock/imx6q-clock.txt      |    4 +
 .../devicetree/bindings/pci/designware-pcie.txt    |    7 +-
 arch/arm/boot/dts/imx6qdl.dtsi                     |   16 +
 arch/arm/mach-imx/Kconfig                          |    2 +
 arch/arm/mach-imx/clk-imx6q.c                      |   24 +-
 drivers/pci/host/Kconfig                           |    6 +
 drivers/pci/host/Makefile                          |    1 +
 drivers/pci/host/pci-imx6.c                        |  576 ++++++++++++++++++++
 include/linux/mfd/syscon/imx6q-iomuxc-gpr.h        |    8 +
 9 files changed, 642 insertions(+), 2 deletions(-)
 create mode 100644 drivers/pci/host/pci-imx6.c
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v6 1/3 ARM: imx: Add LVDS general-purpose clocks to i.MX6Q

The i.MX6 has two general-purpose LVDS clocks that can be driven from a variety of sources. This patch adds a mux and a gate for both of these clocks.

---
 .../devicetree/bindings/clock/imx6q-clock.txt      |    4 ++++
 arch/arm/mach-imx/clk-imx6q.c                      |   20 +++++++++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/clock/imx6q-clock.txt +4 -0
index 5a90a72..35e82c7 100644
@@ -215,6 +215,10 @@ clocks and IDs.
 	cko2      		200
 	cko      		201
 	vdoa      		202
+	lvds1_sel		203
+	lvds2_sel		204
+	lvds1_gate		205
+	lvds2_gate		206
 
 Examples:
 
arch/arm/mach-imx/clk-imx6q.c +19 -1
index 9181a24..d94be84 100644
@@ -217,6 +217,11 @@ static const char *cko2_sels[] = {
 	"uart_serial", "spdif", "asrc", "hsi_tx",
 };
 static const char *cko_sels[] = { "cko1", "cko2", };
+static const char *lvds_sels[] = {
+	"dummy", "dummy", "dummy", "dummy", "dummy", "dummy",
+	"pll4_audio", "pll5_video", "pll8_mlb", "enet_ref",
+	"pcie_ref", "sata_ref",
+};
 
 enum mx6q_clks {
 	dummy, ckil, ckih, osc, pll2_pfd0_352m, pll2_pfd1_594m, pll2_pfd2_396m,
@@ -251,7 +256,8 @@ enum mx6q_clks {
 	ssi2_ipg, ssi3_ipg, rom, usbphy1, usbphy2, ldb_di0_div_3_5, ldb_di1_div_3_5,
 	sata_ref, sata_ref_100m, pcie_ref, pcie_ref_125m, enet_ref, usbphy1_gate,
 	usbphy2_gate, pll4_post_div, pll5_post_div, pll5_video_div, eim_slow,
-	spdif, cko2_sel, cko2_podf, cko2, cko, vdoa, clk_max
+	spdif, cko2_sel, cko2_podf, cko2, cko, vdoa,
+	lvds1_sel, lvds2_sel, lvds1_gate, lvds2_gate, clk_max
 };
 
 static struct clk *clk[clk_max];
@@ -342,6 +348,18 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
 			base + 0xe0, 0, 2, 0, clk_enet_ref_table,
 			&imx_ccm_lock);
 
+	clk[lvds1_sel] = imx_clk_mux("lvds1_sel", base + 0x160, 0, 5, lvds_sels, ARRAY_SIZE(lvds_sels));
+	clk[lvds2_sel] = imx_clk_mux("lvds2_sel", base + 0x160, 5, 5, lvds_sels, ARRAY_SIZE(lvds_sels));
+
+	/*
+	 * lvds1_gate and lvds2_gate are pseudo-gates.  Both can be
+	 * independently configured as clock inputs or outputs.  We treat
+	 * the "output_enable" bit as a gate, even though it's really just
+	 * enabling clock output.
+	 */
+	clk[lvds1_gate] = imx_clk_gate("lvds1_gate", "dummy", base + 0x160, 10);
+	clk[lvds2_gate] = imx_clk_gate("lvds2_gate", "dummy", base + 0x160, 11);
+
 	/*                                name              parent_name        reg       idx */
 	clk[pll2_pfd0_352m] = imx_clk_pfd("pll2_pfd0_352m", "pll2_bus",     base + 0x100, 0);
 	clk[pll2_pfd1_594m] = imx_clk_pfd("pll2_pfd1_594m", "pll2_bus",     base + 0x100, 1);
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH v6 2/3 ARM: imx6q: Add PCIe bits to GPR syscon definition

In reply to Sean Cross

PCIe requires additional bits be defined for GPR8 and GPR12.

---
 include/linux/mfd/syscon/imx6q-iomuxc-gpr.h |    8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/mfd/syscon/imx6q-iomuxc-gpr.h +8 -0
index b6bdcd6..e00e9f3 100644
@@ -241,6 +241,12 @@
 
 #define IMX6Q_GPR5_L2_CLK_STOP			BIT(8)
 
+#define IMX6Q_GPR8_TX_SWING_LOW			(0x7f << 25)
+#define IMX6Q_GPR8_TX_SWING_FULL		(0x7f << 18)
+#define IMX6Q_GPR8_TX_DEEMPH_GEN2_6DB		(0x3f << 12)
+#define IMX6Q_GPR8_TX_DEEMPH_GEN2_3P5DB		(0x3f << 6)
+#define IMX6Q_GPR8_TX_DEEMPH_GEN1		(0x3f << 0)
+
 #define IMX6Q_GPR9_TZASC2_BYP			BIT(1)
 #define IMX6Q_GPR9_TZASC1_BYP			BIT(0)
 
@@ -273,7 +279,9 @@
 #define IMX6Q_GPR12_ARMP_AHB_CLK_EN		BIT(26)
 #define IMX6Q_GPR12_ARMP_ATB_CLK_EN		BIT(25)
 #define IMX6Q_GPR12_ARMP_APB_CLK_EN		BIT(24)
+#define IMX6Q_GPR12_DEVICE_TYPE			(0xf << 12)
 #define IMX6Q_GPR12_PCIE_CTL_2			BIT(10)
+#define IMX6Q_GPR12_LOS_LEVEL			(0x1f << 4)
 
 #define IMX6Q_GPR13_SDMA_STOP_REQ		BIT(30)
 #define IMX6Q_GPR13_CAN2_STOP_REQ		BIT(29)
Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

In reply to Sean Cross

Add support for the PCIe port present on the i.MX6 family of controllers. These use the Synopsis Designware core tied to their own PHY.

---
 .../devicetree/bindings/pci/designware-pcie.txt    |    7 +-
 arch/arm/boot/dts/imx6qdl.dtsi                     |   16 +
 arch/arm/mach-imx/Kconfig                          |    2 +
 arch/arm/mach-imx/clk-imx6q.c                      |    4 +
 drivers/pci/host/Kconfig                           |    6 +
 drivers/pci/host/Makefile                          |    1 +
 drivers/pci/host/pci-imx6.c                        |  576 ++++++++++++++++++++
 7 files changed, 611 insertions(+), 1 deletion(-)
 create mode 100644 drivers/pci/host/pci-imx6.c
Documentation/devicetree/bindings/pci/designware-pcie.txt +6 -1
index eabcb4b..dd8d920 100644
@@ -3,7 +3,7 @@
 Required properties:
 - compatible: should contain "snps,dw-pcie" to identify the
 	core, plus an identifier for the specific instance, such
-	as "samsung,exynos5440-pcie".
+	as "samsung,exynos5440-pcie" or "fsl,imx6q-pcie".
 - reg: base addresses and lengths of the pcie controller,
 	the phy controller, additional register for the phy controller.
 - interrupts: interrupt values for level interrupt,
@@ -21,6 +21,11 @@ Required properties:
 - num-lanes: number of lanes to use
 - reset-gpio: gpio pin number of power good signal
 
+Optional properties for fsl,imx6q-pcie
+- power-on-gpio: gpio pin number of power-enable signal
+- wake-up-gpio: gpio pin number of incoming wakeup signal
+- disable-gpio: gpio pin number of outgoing rfkill/endpoint disable signal
+
 Example:
 
 SoC specific DT Entry:
arch/arm/boot/dts/imx6qdl.dtsi +16 -0
index ccd55c2..125202e 100644
@@ -116,6 +116,22 @@
 			arm,data-latency = <4 2 3>;
 		};
 
+		pcie: pcie at 0x01000000 {
+			compatible = "fsl,imx6q-pcie", "snps,dw-pcie";
+			reg = <0x01ffc000 0x4000>; /* DBI */
+			#address-cells = <3>;
+			#size-cells = <2>;
+			device_type = "pci";
+			ranges = <0x00000800 0 0x01f00000 0x01f00000 0 0x00080000 /* configuration space */
+				  0x81000000 0 0          0x01f80000 0 0x00010000 /* downstream I/O */
+				  0x82000000 0 0x01000000 0x01000000 0 0x00f00000>; /* non-prefetchable memory */
+			num-lanes = <1>;
+			interrupts = <0 123 0x04>;
+			clocks = <&clks 189>, <&clks 187>, <&clks 205>, <&clks 144>;
+			clock-names = "pcie_ref_125m", "sata_ref_100m", "lvds_gate", "pcie_axi";
+			status = "disabled";
+		};
+
 		pmu {
 			compatible = "arm,cortex-a9-pmu";
 			interrupts = <0 94 0x04>;
arch/arm/mach-imx/Kconfig +2 -0
index 29a8af6..e6ac281 100644
@@ -801,6 +801,8 @@ config SOC_IMX6Q
 	select HAVE_IMX_SRC
 	select HAVE_SMP
 	select MFD_SYSCON
+	select MIGHT_HAVE_PCI
+	select PCI_DOMAINS if PCI
 	select PINCTRL
 	select PINCTRL_IMX6Q
 	select PL310_ERRATA_588369 if CACHE_PL310
arch/arm/mach-imx/clk-imx6q.c +4 -0
index d94be84..6956995 100644
@@ -621,6 +621,10 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
 	if (ret)
 		pr_warn("failed to set up CLKO: %d\n", ret);
 
+	/* All existing boards with PCIe use LVDS1 */
+	if (IS_ENABLED(CONFIG_PCI_IMX6))
+		clk_set_parent(clk[lvds1_sel], clk[sata_ref]);
+
 	/* Set initial power mode */
 	imx6q_set_lpm(WAIT_CLOCKED);
 
drivers/pci/host/Kconfig +6 -0
index 3d95048..efa24d9 100644
@@ -15,6 +15,12 @@ config PCI_EXYNOS
 	select PCIEPORTBUS
 	select PCIE_DW
 
+config PCI_IMX6
+	bool "Freescale i.MX6 PCIe controller"
+	depends on SOC_IMX6Q
+	select PCIEPORTBUS
+	select PCIE_DW
+
 config PCI_TEGRA
 	bool "NVIDIA Tegra PCIe controller"
 	depends on ARCH_TEGRA
drivers/pci/host/Makefile +1 -0
index c9a997b..287d6a0 100644
@@ -1,4 +1,5 @@
 obj-$(CONFIG_PCIE_DW) += pcie-designware.o
 obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o
+obj-$(CONFIG_PCI_IMX6) += pci-imx6.o
 obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o
 obj-$(CONFIG_PCI_TEGRA) += pci-tegra.o
drivers/pci/host/pci-imx6.c new file +576 -0

576 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#4 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Quoted 9 lines · Sean Cross

Add support for the PCIe port present on the i.MX6 family of controllers. These use the Synopsis Designware core tied to their own PHY.

drivers/pci/host/pci-imx6.c new file +6 -0
+static int pcie_phy_poll_ack(void __iomem *dbi_base, int exp_val)
+{
+	u32 val;
+	u32 max_iterations = 10;
+	u32 wait_counter = 0;
+

drivers/pci/host/pci-imx6.c line 84

Quoted 10 lines
drivers/pci/host/pci-imx6.c new file +10 -0
+	do {
+		val = readl(dbi_base + PCIE_PHY_STAT);
+		val = (val >> PCIE_PHY_STAT_ACK_LOC) & 0x1;
+		wait_counter++;
+
+		if (val == exp_val)
+			return 0;
+
+		udelay(1);
+	} while ((wait_counter < max_iterations) && (val != exp_val));

The test for val != exp_val is unnecessary now of course.

With this and the devm_clk_get Shawn mentioned:

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#6 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

In reply to Sean Cross

drivers/pci/host/Kconfig config PCI_EXYNOS · line 21

Quoted 12 lines
drivers/pci/host/Kconfig +4 -0
index 3d95048..efa24d9 100644
@@ -15,6 +15,12 @@ config PCI_EXYNOS
        select PCIEPORTBUS
        select PCIE_DW
 
+config PCI_IMX6
+       bool "Freescale i.MX6 PCIe controller"
+       depends on SOC_IMX6Q
+       select PCIEPORTBUS

What is PCIEPORTBUS really for? When I enable this with a PCIe switch off the root complex I get invalid IRQ messages during enumeration of ports on the switch:

[    6.572410] PCI: Device 0000:00:00.0 not available because of
resource collisi
[    6.572433] pcieport: probe of 0000:00:00.0 failed with error -22
[    6.572489] pcieport 0000:01:00.0: device [10b5:8609] has invalid
IRQ; check vendor BIOS             [    6.572536] pcieport: probe of
0000:01:00.0 failed with error -22
[    6.572593] pcieport 0000:02:01.0: device [10b5:8609] has invalid
IRQ; check vendor BIOS
[    6.572621] PCI: enabling device 0000:02:01.0 (0140 -> 0143)
[    6.572672] pcieport 0000:02:01.0: enabling bus mastering
[    6.573045] pcieport 0000:02:04.0: device [10b5:8609] has invalid

IRQ; check vendor BIOS
if I remove PCIEPORTBUS these go away however cards behind the switch don't operate correctly (I believe the interrupts do not get mapped properly). Is there some logic perhaps missing in the driver required for PCIe switches?

Quoted 4 lines
drivers/pci/host/Kconfig +4 -0
+
+/*  Added for PCI abort handling */
+static int imx6q_pcie_abort_handler(unsigned long addr,
+               unsigned int fsr, struct pt_regs *regs)

drivers/pci/host/Kconfig config PCI_EXYNOS

Quoted 10 lines
drivers/pci/host/Kconfig +10 -0
+{
+       /*
+        * If it was an imprecise abort, then we need to correct the
+        * return address to be _after_ the instruction.
+        */
+       if (fsr & (1 << 10))
+               regs->ARM_pc += 4;
+       return 0;
+}
+

you added this per my request but after more testing I'm not sure now it should be needed. On the i.MX6, imprecise aborts will occur when an un-populated device behind a bridge is accessed. However somewhere a few kernels back (3.9 I believe) this behavior changed such that the aborts were not enabled/checked until the kernel completed init. Therefore with the current kernel any un-populated device will cause a single imprecise abort to be caught at the end of init and as such it should be ignored 'without touching the PC'. I'm not clear if this should happen - whatever enables the catching of the abort should perhaps clear any pending flags I would think. I'm also not clear if an abort handler should really be required as the current kernel has a default handler that results in:
...
Freeing unused kernel memory: 6600K (80817000 - 80e89000) Unhandled fault: imprecise external abort (0x1406) at 0xca8c0d71
...

Do we hook a handler that does nothing but 'return 0' just to eliminate the Unhandled fault message?

Quoted 8 lines
drivers/pci/host/Kconfig +8 -0
+static void imx6_pcie_host_init(struct pcie_port *pp)
+{
+       int count = 0;
+       struct imx6_pcie *imx6_pcie = to_imx6_pcie(pp);
+
+       imx6_pcie_assert_core_reset(pp);
+
+       imx6_pcie_init_phy(pp);

drivers/pci/host/Kconfig

Quoted 10 lines
drivers/pci/host/Kconfig +10 -0
+
+       imx6_pcie_deassert_core_reset(pp);
+
+       dw_pcie_setup_rc(pp);
+
+       regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12,
+                       IMX6Q_GPR12_PCIE_CTL_2, 1 << 10);
+
+       while (!dw_pcie_link_up(pp)) {
+               usleep_range(100, 1000);

I've found that I needed to increase this delay in order for a link detect with a PLX PEX8609 switch off the root complex. A usleep_range(2000, 3000) worked in my testing.

drivers/pci/host/Kconfig

Quoted 8 lines
drivers/pci/host/Kconfig +8 -0
+static int imx6_pcie_link_up(struct pcie_port *pp)
+{
+       u32 rc, ltssm, rx_valid, temp;
+
+       /* link is debug bit 36, debug register 1 starts at bit 32 */
+       rc = readl(pp->dbi_base + PCIE_PHY_DEBUG_R1) & (0x1 << (36 - 32));
+       if (rc)
+               return -EAGAIN;

I'm still having trouble accessing devices behind a PCIe switch in 3.12-rc2. Device enumeration goes fine however after kernel init it seems that any access to a switch port fails the check for link in dw_pcie_valid_config which calls imx6_pcie_link_up here. I'm wondering if this is some ASPM issue (I've tried both with that enabled and disabled). When I backport this driver to 3.11 I do not see this behavior and can access config space of all devices behind the bridge within userspace. Any ideas here?

Tim

Quoted 233 lines
drivers/pci/host/Kconfig +229 -1
+
+       /*
+        * From L0, initiate MAC entry to gen2 if EP/RC supports gen2.
+        * Wait 2ms (LTSSM timeout is 24ms, PHY lock is ~5us in gen2).
+        * If (MAC/LTSSM.state == Recovery.RcvrLock)
+        * && (PHY/rx_valid==0) then pulse PHY/rx_reset. Transition
+        * to gen2 is stuck
+        */
+       pcie_phy_read(pp->dbi_base, PCIE_PHY_RX_ASIC_OUT, &rx_valid);
+       ltssm = readl(pp->dbi_base + PCIE_PHY_DEBUG_R0) & 0x3F;
+
+       if (rx_valid & 0x01)
+               return 0;
+
+       if (ltssm != 0x0d)
+               return 0;
+
+       dev_err(pp->dev,
+               "transition to gen2 is stuck, reset PHY!\n");
+
+       pcie_phy_read(pp->dbi_base,
+               PHY_RX_OVRD_IN_LO, &temp);
+       temp |= (PHY_RX_OVRD_IN_LO_RX_DATA_EN
+               | PHY_RX_OVRD_IN_LO_RX_PLL_EN);
+       pcie_phy_write(pp->dbi_base,
+               PHY_RX_OVRD_IN_LO, temp);
+
+       usleep_range(2000, 3000);
+
+       pcie_phy_read(pp->dbi_base,
+               PHY_RX_OVRD_IN_LO, &temp);
+       temp &= ~(PHY_RX_OVRD_IN_LO_RX_DATA_EN
+               | PHY_RX_OVRD_IN_LO_RX_PLL_EN);
+       pcie_phy_write(pp->dbi_base,
+               PHY_RX_OVRD_IN_LO, temp);
+
+       return 0;
+}
+
+static struct pcie_host_ops imx6_pcie_host_ops = {
+       .link_up = imx6_pcie_link_up,
+       .host_init = imx6_pcie_host_init,
+};
+
+static int imx6_add_pcie_port(struct pcie_port *pp,
+                       struct platform_device *pdev)
+{
+       int ret;
+
+       pp->irq = platform_get_irq(pdev, 0);
+       if (!pp->irq) {
+               dev_err(&pdev->dev, "failed to get irq\n");
+               return -ENODEV;
+       }
+
+       pp->root_bus_nr = -1;
+       pp->ops = &imx6_pcie_host_ops;
+
+       spin_lock_init(&pp->conf_lock);
+       ret = dw_pcie_host_init(pp);
+       if (ret) {
+               dev_err(&pdev->dev, "failed to initialize host\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+static int __init imx6_pcie_probe(struct platform_device *pdev)
+{
+       struct imx6_pcie *imx6_pcie;
+       struct pcie_port *pp;
+       struct device_node *np = pdev->dev.of_node;
+       struct resource *dbi_base;
+       int ret;
+
+       imx6_pcie = devm_kzalloc(&pdev->dev, sizeof(*imx6_pcie), GFP_KERNEL);
+       if (!imx6_pcie)
+               return -ENOMEM;
+
+       pp = &imx6_pcie->pp;
+       pp->dev = &pdev->dev;
+
+       /* Added for PCI abort handling */
+       hook_fault_code(16 + 6, imx6q_pcie_abort_handler, SIGBUS, 0,
+               "imprecise external abort");
+
+       dbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!dbi_base) {
+               dev_err(&pdev->dev, "dbi_base memory resource not found\n");
+               return -ENODEV;
+       }
+
+       pp->dbi_base = devm_ioremap_resource(&pdev->dev, dbi_base);
+       if (IS_ERR(pp->dbi_base)) {
+               dev_err(&pdev->dev, "unable to remap dbi_base\n");
+               ret = PTR_ERR(pp->dbi_base);
+               goto err;
+       }
+
+       /* Fetch GPIOs */
+       imx6_pcie->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0);
+       if (!gpio_is_valid(imx6_pcie->reset_gpio)) {
+               dev_err(&pdev->dev, "no reset-gpio defined\n");
+               ret = -ENODEV;
+       }
+       ret = devm_gpio_request_one(&pdev->dev,
+                               imx6_pcie->reset_gpio,
+                               GPIOF_OUT_INIT_LOW,
+                               "PCIe reset");
+       if (ret) {
+               dev_err(&pdev->dev, "unable to get reset gpio\n");
+               goto err;
+       }
+
+       imx6_pcie->power_on_gpio = of_get_named_gpio(np, "power-on-gpio", 0);
+       if (gpio_is_valid(imx6_pcie->power_on_gpio)) {
+               ret = devm_gpio_request_one(&pdev->dev,
+                                       imx6_pcie->power_on_gpio,
+                                       GPIOF_OUT_INIT_LOW,
+                                       "PCIe power enable");
+               if (ret) {
+                       dev_err(&pdev->dev, "unable to get power-on gpio\n");
+                       goto err;
+               }
+       }
+
+       imx6_pcie->wake_up_gpio = of_get_named_gpio(np, "wake-up-gpio", 0);
+       if (gpio_is_valid(imx6_pcie->wake_up_gpio)) {
+               ret = devm_gpio_request_one(&pdev->dev,
+                                       imx6_pcie->wake_up_gpio,
+                                       GPIOF_IN,
+                                       "PCIe wake up");
+               if (ret) {
+                       dev_err(&pdev->dev, "unable to get wake-up gpio\n");
+                       goto err;
+               }
+       }
+
+       imx6_pcie->disable_gpio = of_get_named_gpio(np, "disable-gpio", 0);
+       if (gpio_is_valid(imx6_pcie->disable_gpio)) {
+               ret = devm_gpio_request_one(&pdev->dev,
+                                       imx6_pcie->disable_gpio,
+                                       GPIOF_OUT_INIT_HIGH,
+                                       "PCIe disable endpoint");
+               if (ret) {
+                       dev_err(&pdev->dev, "unable to get disable-ep gpio\n");
+                       goto err;
+               }
+       }
+
+       /* Fetch clocks */
+       imx6_pcie->lvds_gate = clk_get(&pdev->dev, "lvds_gate");
+       if (IS_ERR(imx6_pcie->lvds_gate)) {
+               dev_err(&pdev->dev,
+                       "lvds_gate clock select missing or invalid\n");
+               ret = PTR_ERR(imx6_pcie->lvds_gate);
+               goto err;
+       }
+
+       imx6_pcie->sata_ref_100m = clk_get(&pdev->dev, "sata_ref_100m");
+       if (IS_ERR(imx6_pcie->sata_ref_100m)) {
+               dev_err(&pdev->dev,
+                       "sata_ref_100m clock source missing or invalid\n");
+               ret = PTR_ERR(imx6_pcie->sata_ref_100m);
+               goto err;
+       }
+
+       imx6_pcie->pcie_ref_125m = clk_get(&pdev->dev, "pcie_ref_125m");
+       if (IS_ERR(imx6_pcie->pcie_ref_125m)) {
+               dev_err(&pdev->dev,
+                       "pcie_ref_125m clock source missing or invalid\n");
+               ret = PTR_ERR(imx6_pcie->pcie_ref_125m);
+               goto err;
+       }
+
+       imx6_pcie->pcie_axi = clk_get(&pdev->dev, "pcie_axi");
+       if (IS_ERR(imx6_pcie->pcie_axi)) {
+               dev_err(&pdev->dev,
+                       "pcie_axi clock source missing or invalid\n");
+               ret = PTR_ERR(imx6_pcie->pcie_axi);
+               goto err;
+       }
+
+       /* Grab GPR config register range */
+       imx6_pcie->iomuxc_gpr =
+                syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr");
+       if (IS_ERR(imx6_pcie->iomuxc_gpr)) {
+               dev_err(&pdev->dev, "unable to find iomuxc registers\n");
+               ret = PTR_ERR(imx6_pcie->iomuxc_gpr);
+               goto err;
+       }
+
+       ret = imx6_add_pcie_port(pp, pdev);
+       if (ret < 0)
+               goto err;
+
+       platform_set_drvdata(pdev, imx6_pcie);
+       return 0;
+
+err:
+       return ret;
+}
+
+static const struct of_device_id imx6_pcie_of_match[] = {
+       { .compatible = "fsl,imx6q-pcie", },
+       {},
+};
+MODULE_DEVICE_TABLE(of, imx6_pcie_of_match);
+
+static struct platform_driver imx6_pcie_driver = {
+       .driver = {
+               .name   = "imx6q-pcie",
+               .owner  = THIS_MODULE,
+               .of_match_table = of_match_ptr(imx6_pcie_of_match),
+       },
+};
+
+/* Freescale PCIe driver does not allow module unload */
+
+static int __init imx6_init(void)
+{
+       return platform_driver_probe(&imx6_pcie_driver, imx6_pcie_probe);
+}
+module_init(imx6_init);
+
+MODULE_AUTHOR("Sean Cross <[email protected]>");
+MODULE_DESCRIPTION("Freescale i.MX6 PCIe host controller driver");
+MODULE_LICENSE("GPL v2");
--

1.7.9.5

#7 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Hi Tim:
Thanks for your tests.
Yes, it is. There are some problems when the PCIe switch is used on the 3.1x kernel at my side too, although the PCIe switch is ok on FSL imx_3.0.35 kernels.
I'm debugging this issue now, and would summit the patches asap.

Best Regards
Richard Zhu

-----Original Message-----
From: Tim Harvey [mailto:tharvey at gateworks.com]
Sent: Thursday, September 26, 2013 1:54 PM
To: Sean Cross
Cc: devicetree at vger.kernel.org; linux-pci at vger.kernel.org; linux-arm-kernel at lists.infradead.org; Sascha Hauer; Zhu Richard-R65037; Shawn Guo; bhelgaas at google.com
Subject: Re: [PATCH v6 3/3] PCI: imx6: Add support for i.MX6 PCIe controller

drivers/pci/host/Kconfig config PCI_EXYNOS · line 21

Quoted 12 lines
drivers/pci/host/Kconfig index renamed from drivers/pci/host/Kconfig +0 -0

3d95048..efa24d9 100644

drivers/pci/host/Kconfig +4 -0
@@ -15,6 +15,12 @@ config PCI_EXYNOS
        select PCIEPORTBUS
        select PCIE_DW
 
+config PCI_IMX6
+       bool "Freescale i.MX6 PCIe controller"
+       depends on SOC_IMX6Q
+       select PCIEPORTBUS

What is PCIEPORTBUS really for? When I enable this with a PCIe switch off the root complex I get invalid IRQ messages during enumeration of ports on the switch:

[    6.572410] PCI: Device 0000:00:00.0 not available because of
resource collisi
[    6.572433] pcieport: probe of 0000:00:00.0 failed with error -22
[    6.572489] pcieport 0000:01:00.0: device [10b5:8609] has invalid
IRQ; check vendor BIOS             [    6.572536] pcieport: probe of
0000:01:00.0 failed with error -22
[    6.572593] pcieport 0000:02:01.0: device [10b5:8609] has invalid
IRQ; check vendor BIOS
[    6.572621] PCI: enabling device 0000:02:01.0 (0140 -> 0143)
[    6.572672] pcieport 0000:02:01.0: enabling bus mastering
[    6.573045] pcieport 0000:02:04.0: device [10b5:8609] has invalid

IRQ; check vendor BIOS
if I remove PCIEPORTBUS these go away however cards behind the switch don't operate correctly (I believe the interrupts do not get mapped properly). Is there some logic perhaps missing in the driver required for PCIe switches?

drivers/pci/host/Kconfig config PCI_EXYNOS

Quoted 13 lines
drivers/pci/host/Kconfig +13 -0
+
+/*  Added for PCI abort handling */
+static int imx6q_pcie_abort_handler(unsigned long addr,
+               unsigned int fsr, struct pt_regs *regs) {
+       /*
+        * If it was an imprecise abort, then we need to correct the
+        * return address to be _after_ the instruction.
+        */
+       if (fsr & (1 << 10))
+               regs->ARM_pc += 4;
+       return 0;
+}
+

you added this per my request but after more testing I'm not sure now it should be needed. On the i.MX6, imprecise aborts will occur when an un-populated device behind a bridge is accessed. However somewhere a few kernels back (3.9 I believe) this behavior changed such that the aborts were not enabled/checked until the kernel completed init.
Therefore with the current kernel any un-populated device will cause a single imprecise abort to be caught at the end of init and as such it should be ignored 'without touching the PC'. I'm not clear if this should happen - whatever enables the catching of the abort should perhaps clear any pending flags I would think. I'm also not clear if an abort handler should really be required as the current kernel has a default handler that results in:
...
Freeing unused kernel memory: 6600K (80817000 - 80e89000) Unhandled fault: imprecise external abort (0x1406) at 0xca8c0d71 ...

Do we hook a handler that does nothing but 'return 0' just to eliminate the Unhandled fault message?

Quoted 7 lines
drivers/pci/host/Kconfig +7 -0
+static void imx6_pcie_host_init(struct pcie_port *pp) {
+       int count = 0;
+       struct imx6_pcie *imx6_pcie = to_imx6_pcie(pp);
+
+       imx6_pcie_assert_core_reset(pp);
+
+       imx6_pcie_init_phy(pp);

drivers/pci/host/Kconfig

Quoted 10 lines
drivers/pci/host/Kconfig +10 -0
+
+       imx6_pcie_deassert_core_reset(pp);
+
+       dw_pcie_setup_rc(pp);
+
+       regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12,
+                       IMX6Q_GPR12_PCIE_CTL_2, 1 << 10);
+
+       while (!dw_pcie_link_up(pp)) {
+               usleep_range(100, 1000);

I've found that I needed to increase this delay in order for a link detect with a PLX PEX8609 switch off the root complex. A usleep_range(2000, 3000) worked in my testing.

drivers/pci/host/Kconfig

Quoted 7 lines
drivers/pci/host/Kconfig +7 -0
+static int imx6_pcie_link_up(struct pcie_port *pp) {
+       u32 rc, ltssm, rx_valid, temp;
+
+       /* link is debug bit 36, debug register 1 starts at bit 32 */
+       rc = readl(pp->dbi_base + PCIE_PHY_DEBUG_R1) & (0x1 << (36 - 32));
+       if (rc)
+               return -EAGAIN;

I'm still having trouble accessing devices behind a PCIe switch in 3.12-rc2. Device enumeration goes fine however after kernel init it seems that any access to a switch port fails the check for link in dw_pcie_valid_config which calls imx6_pcie_link_up here. I'm wondering if this is some ASPM issue (I've tried both with that enabled and disabled). When I backport this driver to 3.11 I do not see this behavior and can access config space of all devices behind the bridge within userspace. Any ideas here?

Tim

Quoted 229 lines
drivers/pci/host/Kconfig +225 -1
+
+       /*
+        * From L0, initiate MAC entry to gen2 if EP/RC supports gen2.
+        * Wait 2ms (LTSSM timeout is 24ms, PHY lock is ~5us in gen2).
+        * If (MAC/LTSSM.state == Recovery.RcvrLock)
+        * && (PHY/rx_valid==0) then pulse PHY/rx_reset. Transition
+        * to gen2 is stuck
+        */
+       pcie_phy_read(pp->dbi_base, PCIE_PHY_RX_ASIC_OUT, &rx_valid);
+       ltssm = readl(pp->dbi_base + PCIE_PHY_DEBUG_R0) & 0x3F;
+
+       if (rx_valid & 0x01)
+               return 0;
+
+       if (ltssm != 0x0d)
+               return 0;
+
+       dev_err(pp->dev,
+               "transition to gen2 is stuck, reset PHY!\n");
+
+       pcie_phy_read(pp->dbi_base,
+               PHY_RX_OVRD_IN_LO, &temp);
+       temp |= (PHY_RX_OVRD_IN_LO_RX_DATA_EN
+               | PHY_RX_OVRD_IN_LO_RX_PLL_EN);
+       pcie_phy_write(pp->dbi_base,
+               PHY_RX_OVRD_IN_LO, temp);
+
+       usleep_range(2000, 3000);
+
+       pcie_phy_read(pp->dbi_base,
+               PHY_RX_OVRD_IN_LO, &temp);
+       temp &= ~(PHY_RX_OVRD_IN_LO_RX_DATA_EN
+               | PHY_RX_OVRD_IN_LO_RX_PLL_EN);
+       pcie_phy_write(pp->dbi_base,
+               PHY_RX_OVRD_IN_LO, temp);
+
+       return 0;
+}
+
+static struct pcie_host_ops imx6_pcie_host_ops = {
+       .link_up = imx6_pcie_link_up,
+       .host_init = imx6_pcie_host_init, };
+
+static int imx6_add_pcie_port(struct pcie_port *pp,
+                       struct platform_device *pdev) {
+       int ret;
+
+       pp->irq = platform_get_irq(pdev, 0);
+       if (!pp->irq) {
+               dev_err(&pdev->dev, "failed to get irq\n");
+               return -ENODEV;
+       }
+
+       pp->root_bus_nr = -1;
+       pp->ops = &imx6_pcie_host_ops;
+
+       spin_lock_init(&pp->conf_lock);
+       ret = dw_pcie_host_init(pp);
+       if (ret) {
+               dev_err(&pdev->dev, "failed to initialize host\n");
+               return ret;
+       }
+
+       return 0;
+}
+
+static int __init imx6_pcie_probe(struct platform_device *pdev) {
+       struct imx6_pcie *imx6_pcie;
+       struct pcie_port *pp;
+       struct device_node *np = pdev->dev.of_node;
+       struct resource *dbi_base;
+       int ret;
+
+       imx6_pcie = devm_kzalloc(&pdev->dev, sizeof(*imx6_pcie), GFP_KERNEL);
+       if (!imx6_pcie)
+               return -ENOMEM;
+
+       pp = &imx6_pcie->pp;
+       pp->dev = &pdev->dev;
+
+       /* Added for PCI abort handling */
+       hook_fault_code(16 + 6, imx6q_pcie_abort_handler, SIGBUS, 0,
+               "imprecise external abort");
+
+       dbi_base = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!dbi_base) {
+               dev_err(&pdev->dev, "dbi_base memory resource not found\n");
+               return -ENODEV;
+       }
+
+       pp->dbi_base = devm_ioremap_resource(&pdev->dev, dbi_base);
+       if (IS_ERR(pp->dbi_base)) {
+               dev_err(&pdev->dev, "unable to remap dbi_base\n");
+               ret = PTR_ERR(pp->dbi_base);
+               goto err;
+       }
+
+       /* Fetch GPIOs */
+       imx6_pcie->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0);
+       if (!gpio_is_valid(imx6_pcie->reset_gpio)) {
+               dev_err(&pdev->dev, "no reset-gpio defined\n");
+               ret = -ENODEV;
+       }
+       ret = devm_gpio_request_one(&pdev->dev,
+                               imx6_pcie->reset_gpio,
+                               GPIOF_OUT_INIT_LOW,
+                               "PCIe reset");
+       if (ret) {
+               dev_err(&pdev->dev, "unable to get reset gpio\n");
+               goto err;
+       }
+
+       imx6_pcie->power_on_gpio = of_get_named_gpio(np, "power-on-gpio", 0);
+       if (gpio_is_valid(imx6_pcie->power_on_gpio)) {
+               ret = devm_gpio_request_one(&pdev->dev,
+                                       imx6_pcie->power_on_gpio,
+                                       GPIOF_OUT_INIT_LOW,
+                                       "PCIe power enable");
+               if (ret) {
+                       dev_err(&pdev->dev, "unable to get power-on gpio\n");
+                       goto err;
+               }
+       }
+
+       imx6_pcie->wake_up_gpio = of_get_named_gpio(np, "wake-up-gpio", 0);
+       if (gpio_is_valid(imx6_pcie->wake_up_gpio)) {
+               ret = devm_gpio_request_one(&pdev->dev,
+                                       imx6_pcie->wake_up_gpio,
+                                       GPIOF_IN,
+                                       "PCIe wake up");
+               if (ret) {
+                       dev_err(&pdev->dev, "unable to get wake-up gpio\n");
+                       goto err;
+               }
+       }
+
+       imx6_pcie->disable_gpio = of_get_named_gpio(np, "disable-gpio", 0);
+       if (gpio_is_valid(imx6_pcie->disable_gpio)) {
+               ret = devm_gpio_request_one(&pdev->dev,
+                                       imx6_pcie->disable_gpio,
+                                       GPIOF_OUT_INIT_HIGH,
+                                       "PCIe disable endpoint");
+               if (ret) {
+                       dev_err(&pdev->dev, "unable to get disable-ep gpio\n");
+                       goto err;
+               }
+       }
+
+       /* Fetch clocks */
+       imx6_pcie->lvds_gate = clk_get(&pdev->dev, "lvds_gate");
+       if (IS_ERR(imx6_pcie->lvds_gate)) {
+               dev_err(&pdev->dev,
+                       "lvds_gate clock select missing or invalid\n");
+               ret = PTR_ERR(imx6_pcie->lvds_gate);
+               goto err;
+       }
+
+       imx6_pcie->sata_ref_100m = clk_get(&pdev->dev, "sata_ref_100m");
+       if (IS_ERR(imx6_pcie->sata_ref_100m)) {
+               dev_err(&pdev->dev,
+                       "sata_ref_100m clock source missing or invalid\n");
+               ret = PTR_ERR(imx6_pcie->sata_ref_100m);
+               goto err;
+       }
+
+       imx6_pcie->pcie_ref_125m = clk_get(&pdev->dev, "pcie_ref_125m");
+       if (IS_ERR(imx6_pcie->pcie_ref_125m)) {
+               dev_err(&pdev->dev,
+                       "pcie_ref_125m clock source missing or invalid\n");
+               ret = PTR_ERR(imx6_pcie->pcie_ref_125m);
+               goto err;
+       }
+
+       imx6_pcie->pcie_axi = clk_get(&pdev->dev, "pcie_axi");
+       if (IS_ERR(imx6_pcie->pcie_axi)) {
+               dev_err(&pdev->dev,
+                       "pcie_axi clock source missing or invalid\n");
+               ret = PTR_ERR(imx6_pcie->pcie_axi);
+               goto err;
+       }
+
+       /* Grab GPR config register range */
+       imx6_pcie->iomuxc_gpr =
+                syscon_regmap_lookup_by_compatible("fsl,imx6q-iomuxc-gpr");
+       if (IS_ERR(imx6_pcie->iomuxc_gpr)) {
+               dev_err(&pdev->dev, "unable to find iomuxc registers\n");
+               ret = PTR_ERR(imx6_pcie->iomuxc_gpr);
+               goto err;
+       }
+
+       ret = imx6_add_pcie_port(pp, pdev);
+       if (ret < 0)
+               goto err;
+
+       platform_set_drvdata(pdev, imx6_pcie);
+       return 0;
+
+err:
+       return ret;
+}
+
+static const struct of_device_id imx6_pcie_of_match[] = {
+       { .compatible = "fsl,imx6q-pcie", },
+       {},
+};
+MODULE_DEVICE_TABLE(of, imx6_pcie_of_match);
+
+static struct platform_driver imx6_pcie_driver = {
+       .driver = {
+               .name   = "imx6q-pcie",
+               .owner  = THIS_MODULE,
+               .of_match_table = of_match_ptr(imx6_pcie_of_match),
+       },
+};
+
+/* Freescale PCIe driver does not allow module unload */
+
+static int __init imx6_init(void)
+{
+       return platform_driver_probe(&imx6_pcie_driver, 
+imx6_pcie_probe); } module_init(imx6_init);
+
+MODULE_AUTHOR("Sean Cross <[email protected]>"); 
+MODULE_DESCRIPTION("Freescale i.MX6 PCIe host controller driver"); 
+MODULE_LICENSE("GPL v2");
--

1.7.9.5

#8 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Quoted 8 lines · On Fri, Sep 27, 2013 at 01:38:39AM +0000, Zhu Richard-R65037 wrote:

Hi Tim:
Thanks for your tests.
Yes, it is. There are some problems when the PCIe switch is used on the 3.1x kernel at my side too, although the PCIe switch is ok on FSL imx_3.0.35 kernels.
I'm debugging this issue now, and would summit the patches asap.

From what I read, it seems Sean's series does not support PCIe switch.

At least, he hasn't got any device to test it. And there is some problem with PCIe switch running the latest kernel, which might not be related to the controller driver.

I suggest we ask Bjorn to merge the v7 I sent yesterday, so that people can have a same base to work on, and add PCIe switch support with
incremental patches. Does that sound good to you, Tim?

Shawn

#9 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Quoted 10 lines · Shawn Guo
Quoted 4 lines · On Fri, Sep 27, 2013 at 01:38:39AM +0000, Zhu Richard-R65037 wrote:

Hi Tim:
Thanks for your tests.
Yes, it is. There are some problems when the PCIe switch is used on the 3.1x kernel at my side too,

although the PCIe switch

Quoted 3 lines

is ok on FSL imx_3.0.35 kernels.
I'm debugging this issue now, and would summit the patches asap.

Quoted 9 lines

From what I read, it seems Sean's series does not support PCIe switch. At least, he hasn't got any device to test it. And there is some problem with PCIe switch running the latest kernel, which might not be related to the controller driver.

I suggest we ask Bjorn to merge the v7 I sent yesterday, so that people can have a same base to work on, and add PCIe switch support with
incremental patches. Does that sound good to you, Tim?

Hi Shawn Guo,

I agree with your suggestion. :-)
The PCIe switch support patches can be added later, after the v7 patch for i.MX6 PCIe controller driver is merged.

Also, if the PCIe switch support patches modify the synopsys designware PCIe driver (pcie-designware.c), it should be confirmed by other related people.

Best regards,
Jingoo Han

author
#10 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Quoted 19 lines · Jingoo Han
Quoted 9 lines · Shawn Guo
Quoted 4 lines · On Fri, Sep 27, 2013 at 01:38:39AM +0000, Zhu Richard-R65037 wrote:

Hi Tim:
Thanks for your tests.
Yes, it is. There are some problems when the PCIe switch is used on the 3.1x kernel at my side too,

although the PCIe switch

Quoted 3 lines

is ok on FSL imx_3.0.35 kernels.
I'm debugging this issue now, and would summit the patches asap.

Quoted 9 lines

From what I read, it seems Sean's series does not support PCIe switch.
At least, he hasn't got any device to test it. And there is some problem with PCIe switch running the latest kernel, which might not be related to the controller driver.

I suggest we ask Bjorn to merge the v7 I sent yesterday, so that people can have a same base to work on, and add PCIe switch support with
incremental patches. Does that sound good to you, Tim?

Quoted 9 lines

Hi Shawn Guo,

I agree with your suggestion. :-)
The PCIe switch support patches can be added later, after the v7 patch for i.MX6 PCIe controller driver is merged.

Also, if the PCIe switch support patches modify the synopsys designware PCIe driver (pcie-designware.c), it should be confirmed by other related people.

Correct. My series doesn't support PCIe switches mostly because I don't have one to test with. It would be interesting to see if PCIe switches work with other Designware drivers.

---
Sean

#11 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

In reply to Shawn Guo
Quoted 13 lines · Shawn Guo
Quoted 6 lines · On Fri, Sep 27, 2013 at 01:38:39AM +0000, Zhu Richard-R65037 wrote:

Hi Tim:
Thanks for your tests.
Yes, it is. There are some problems when the PCIe switch is used on the 3.1x kernel at my side too, although the PCIe switch is ok on FSL imx_3.0.35 kernels.
I'm debugging this issue now, and would summit the patches asap.

From what I read, it seems Sean's series does not support PCIe switch. At least, he hasn't got any device to test it. And there is some problem with PCIe switch running the latest kernel, which might not be related to the controller driver.

Quoted 6 lines

I suggest we ask Bjorn to merge the v7 I sent yesterday, so that people can have a same base to work on, and add PCIe switch support with
incremental patches. Does that sound good to you, Tim?

Shawn

Agreed - I would like to get this out there to a broader audience as well.

Thanks,

Tim

#12 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

In reply to Sean Cross
Quoted 21 lines · Sean Cross

Add support for the PCIe port present on the i.MX6 family of controllers. These use the Synopsis Designware core tied to their own PHY.

---
 .../devicetree/bindings/pci/designware-pcie.txt    |    7 +-
arch/arm/boot/dts/imx6qdl.dtsi +6 -0
index ccd55c2..125202e 100644
@@ -116,6 +116,22 @@
                        arm,data-latency = <4 2 3>;
                };
 
+               pcie: pcie at 0x01000000 {
+                       compatible = "fsl,imx6q-pcie", "snps,dw-pcie";
+                       reg = <0x01ffc000 0x4000>; /* DBI */
+                       #address-cells = <3>;
+                       #size-cells = <2>;
+                       device_type = "pci";

arch/arm/boot/dts/imx6qdl.dtsi line 134

Quoted 10 lines
arch/arm/boot/dts/imx6qdl.dtsi +10 -0
+                       ranges = <0x00000800 0 0x01f00000 0x01f00000 0 0x00080000 /* configuration space */
+                                 0x81000000 0 0          0x01f80000 0 0x00010000 /* downstream I/O */
+                                 0x82000000 0 0x01000000 0x01000000 0 0x00f00000>; /* non-prefetchable memory */
+                       num-lanes = <1>;
+                       interrupts = <0 123 0x04>;
+                       clocks = <&clks 189>, <&clks 187>, <&clks 205>, <&clks 144>;
+                       clock-names = "pcie_ref_125m", "sata_ref_100m", "lvds_gate", "pcie_axi";
+                       status = "disabled";
+               };
+

Sean,

The devicetree portion above is now here
https://gitorious.org/thierryreding/linux-next/commit/3a57291fa4ca7f7647d826f5b47082ef306d839f
(which I'm told gets pulled into linux-next) and I wanted to see if you or any of the other IMX/PCI gurus here can answer a question about region mapping.

The above ranges look to me to allocate 15MB for mem resources, 64K for io resources, and 256K for cfg space.

Table 2.1 of the IMX6DQRM.pdf
(http://cache.freescale.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf)
shows:
01FF_C000 01FF_FFFF 16 KB PCIe registers
0100_0000 01FF_BFFF 16368 KB PCIe

The driver in the fsl 3.0.35_4.1.0 BSP maps the following (see
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/tree/arch/arm/mach-mx6/pcie.c?h=imx_3.0.35_4.1.0#n331):

0x0100_0000 --- 0x01DF_FFFF 14MB IORESOURCE_MEM 0x01E0_0000 --- 0x01EF_FFFF 1MB IORESOURCE_IO 0x01F0_0000 --- 0x01FF_FFFF 1MB Cfg + MSI + Registers

and, in a discussion on the IMX Community forum
(https://community.freescale.com/message/334959#334959) points out that you have more flexibility if you map the MEM resource first because of its more limited alignment. So, if you were going to stick with the fsl mapping I would think we would want something like this in the dt node:

ranges = <0x00000800 0 0x01f00000 0x01f00000 0 0x00080000 /* 512K configuration space */

               0x81000000 0 0          0x01e00000 0 0x00100000 /* 1MB
downstream I/O */
               0x82000000 0 0x01000000 0x01000000 0 0x00e00000>; /*

14MB non-prefetchable memory */

Can these regions be moved around however you want depending on what kind of mem vs io resource configurations you desire? How about the cfg space - is 512K really needed?

Are we sure the committed values to linux-next 'wrong' in any way? I still am seeing bus-hangs with devices behind a bridge that use io-space resources and am trying to figure out where the issue is. I don't get these bus-hangs when using the fsl driver which is structured very different so its been difficult for me to determine the difference. The mappings and the way iATU mappings are done are very different.

Thanks,

Tim

#13 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Quoted 89 lines

-----Original Message-----
From: Tim Harvey [mailto:tharvey at gateworks.com]
Sent: Friday, October 18, 2013 1:33 PM
To: Sean Cross
Cc: devicetree at vger.kernel.org; linux-pci at vger.kernel.org; linux-arm- kernel at lists.infradead.org; Sascha Hauer; Zhu Richard-R65037; Shawn Guo; Bjorn Helgaas; Marek Va?ut; Jingoo Han; Pratyush Anand; Troy Kisky
Subject: Re: [PATCH v6 3/3] PCI: imx6: Add support for i.MX6 PCIe controller

Quoted 12 lines · Sean Cross

Add support for the PCIe port present on the i.MX6 family of controllers. These use the Synopsis Designware core tied to their own PHY.

---
 .../devicetree/bindings/pci/designware-pcie.txt    |    7 +-
(quoted diff) +0 -0

b/arch/arm/boot/dts/imx6qdl.dtsi index ccd55c2..125202e 100644

arch/arm/boot/dts/imx6qdl.dtsi line 125

Quoted 10 lines
arch/arm/boot/dts/imx6qdl.dtsi +7 -0
@@ -116,6 +116,22 @@
                        arm,data-latency = <4 2 3>;
                };
 
+               pcie: pcie at 0x01000000 {
+                       compatible = "fsl,imx6q-pcie", "snps,dw-pcie";
+                       reg = <0x01ffc000 0x4000>; /* DBI */
+                       #address-cells = <3>;
+                       #size-cells = <2>;
+                       device_type = "pci";
+                       ranges = <0x00000800 0 0x01f00000 0x01f00000 0

0x00080000 /* configuration space */

arch/arm/boot/dts/imx6qdl.dtsi line 126

Quoted 1 line
arch/arm/boot/dts/imx6qdl.dtsi +1 -0
+                                 0x81000000 0 0          0x01f80000 0

0x00010000 /* downstream I/O */

arch/arm/boot/dts/imx6qdl.dtsi line 127

Quoted 1 line
arch/arm/boot/dts/imx6qdl.dtsi +1 -0
+                                 0x82000000 0 0x01000000 0x01000000 0

0x00f00000>; /* non-prefetchable memory */

arch/arm/boot/dts/imx6qdl.dtsi

Quoted 3 lines
arch/arm/boot/dts/imx6qdl.dtsi +3 -0
+                       num-lanes = <1>;
+                       interrupts = <0 123 0x04>;
+                       clocks = <&clks 189>, <&clks 187>, <&clks 205>,

<&clks 144>;

arch/arm/boot/dts/imx6qdl.dtsi line 131

Quoted 1 line
arch/arm/boot/dts/imx6qdl.dtsi +1 -0
+                       clock-names = "pcie_ref_125m", "sata_ref_100m",

"lvds_gate", "pcie_axi";

arch/arm/boot/dts/imx6qdl.dtsi line 134

Quoted 3 lines
arch/arm/boot/dts/imx6qdl.dtsi +3 -0
+                       status = "disabled";
+               };
+

Sean,

The devicetree portion above is now here
https://gitorious.org/thierryreding/linux-
next/commit/3a57291fa4ca7f7647d826f5b47082ef306d839f
(which I'm told gets pulled into linux-next) and I wanted to see if you or any of the other IMX/PCI gurus here can answer a question about region mapping.

The above ranges look to me to allocate 15MB for mem resources, 64K for io resources, and 256K for cfg space.

Table 2.1 of the IMX6DQRM.pdf
(http://cache.freescale.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf)
shows:
01FF_C000 01FF_FFFF 16 KB PCIe registers
0100_0000 01FF_BFFF 16368 KB PCIe

The driver in the fsl 3.0.35_4.1.0 BSP maps the following (see
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-
imx.git/tree/arch/arm/mach-mx6/pcie.c?h=imx_3.0.35_4.1.0#n331):

0x0100_0000 --- 0x01DF_FFFF 14MB IORESOURCE_MEM 0x01E0_0000 --- 0x01EF_FFFF 1MB IORESOURCE_IO 0x01F0_0000 --- 0x01FF_FFFF 1MB Cfg + MSI + Registers

and, in a discussion on the IMX Community forum
(https://community.freescale.com/message/334959#334959) points out that you have more flexibility if you map the MEM resource first because of its more limited alignment. So, if you were going to stick with the fsl mapping I would think we would want something like this in the dt node:

ranges = <0x00000800 0 0x01f00000 0x01f00000 0 0x00080000 /* 512K configuration space */

               0x81000000 0 0          0x01e00000 0 0x00100000 /* 1MB
downstream I/O */
               0x82000000 0 0x01000000 0x01000000 0 0x00e00000>; /* 14MB non-

prefetchable memory */

Can these regions be moved around however you want depending on what kind of mem vs io resource configurations you desire? How about the cfg space - is 512K really needed?

Quoted 6 lines

Are we sure the committed values to linux-next 'wrong' in any way? I still am seeing bus-hangs with devices behind a bridge that use io-space resources and am trying to figure out where the issue is. I don't get these bus-hangs when using the fsl driver which is structured very different so its been difficult for me to determine the difference. The mappings and the way iATU mappings are done are very different.

Hi Tim:
Regarding to my experience, the difference shouldn't be related with the bus hang. Here are my DT region setup when I trying to bring up imx6 pcie on 3.1x kernel by my own driver.

                        clock-names = "pcie_axi", "pcie_ref", "pcie_bus_in", "pcie_bus_out";
                        #address-cells = <3>;
                        #size-cells = <2>;
                        ranges = <0x00000800 0 0x01f00000 0x01f00000 0 0x00080000   /* configuration space */
                                  0x81000000 0 0          0x01f80000 0 0x00010000   /* downstream I/O */
                                  0x82000000 0 0x01000000 0x01000000 0 0x00f00000>; /* non-prefetchable memory */
                        num-lanes = <1>;

It works sometimes, although that there is random kernel panic and system hang(log is pasted below):( LOGS, when pericom's PI7C9X2G303EL and Intel e1000e network card is used.
...
imx-pcie 1ffc000.pcie: legacy_irq 155
imx-pcie 1ffc000.pcie: map [mem 0x01ffc000-0x01ffffff]
IMX PCIe port: link up.
PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [io 0x1000-0x10000]
pci_bus 0000:00: root bus resource [mem 0x01000000-0x01efffff]
pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
PCI: bus0: Fast back to back transfers disabled
PCI: bus1: Fast back to back transfers disabled
pci 0000:01:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
PCI: bus2: Fast back to back transfers disabled
pci 0000:02:01.0: bridge configuration invalid ([bus 00-00]), reconfiguring
pci 0000:02:02.0: bridge configuration invalid ([bus 00-00]), reconfiguring
PCI: bus3: Fast back to back transfers disabled
PCI: bus4: Fast back to back transfers enabled
pci 0000:00:00.0: BAR 0: assigned [mem 0x01000000-0x010fffff 64bit]
pci 0000:00:00.0: BAR 8: assigned [mem 0x01100000-0x012fffff]
pci 0000:00:00.0: BAR 6: assigned [mem 0x01300000-0x0130ffff pref]
pci 0000:00:00.0: BAR 7: assigned [io 0x1000-0x1fff]
pci 0000:01:00.0: BAR 8: assigned [mem 0x01100000-0x012fffff]
pci 0000:01:00.0: BAR 7: assigned [io 0x1000-0x1fff]
pci 0000:02:01.0: BAR 8: assigned [mem 0x01100000-0x012fffff]
pci 0000:02:01.0: BAR 7: assigned [io 0x1000-0x1fff]
pci 0000:03:00.0: BAR 1: assigned [mem 0x01100000-0x011fffff]
pci 0000:03:00.0: BAR 0: assigned [mem 0x01200000-0x0121ffff]
pci 0000:03:00.0: BAR 3: assigned [mem 0x01220000-0x01223fff]
pci 0000:03:00.0: BAR 2: assigned [io 0x1000-0x101f]
pci 0000:02:01.0: PCI bridge to [bus 03]
pci 0000:02:01.0: bridge window [io 0x1000-0x1fff]
pci 0000:02:01.0: bridge window [mem 0x01100000-0x012fffff]
pci 0000:02:02.0: PCI bridge to [bus 04]
pci 0000:01:00.0: PCI bridge to [bus 02-04]
pci 0000:01:00.0: bridge window [io 0x1000-0x1fff]
pci 0000:01:00.0: bridge window [mem 0x01100000-0x012fffff]
pci 0000:00:00.0: PCI bridge to [bus 01-04]
pci 0000:00:00.0: bridge window [io 0x1000-0x1fff]
pci 0000:00:00.0: bridge window [mem 0x01100000-0x012fffff]
PCI: enabling device 0000:01:00.0 (0140 -> 0143)
PCI: enabling device 0000:02:01.0 (0140 -> 0143)
PCI: enabling device 0000:02:02.0 (0140 -> 0143)
...
e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k
e1000e: Copyright(c) 1999 - 2013 Intel Corporation.
e1000e 0000:03:00.0: Disabling ASPM L0s L1
PCI: enabling device 0000:03:00.0 (0140 -> 0142)
e1000e 0000:03:00.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode e1000e 0000:03:00.0 eth1: registered PHC clock
e1000e 0000:03:00.0 eth1: (PCI Express:2.5GT/s:Width x1) 00:1b:21:3a:18:8b
e1000e 0000:03:00.0 eth1: Intel(R) PRO/1000 Network Connection
e1000e 0000:03:00.0 eth1: MAC: 3, PHY: 8, PBA No: E42641-005
igb: Intel(R) Gigabit Ethernet Network Driver - version 5.0.3-k
igb: Copyright (c) 2007-2013 Intel Corporation.
...

ALSA device list:
#0: wm8962-audio
VFS: Mounted root (nfs filesystem) on device 0:11.
devtmpfs: mounted
Freeing unused kernel memory: 324K (8082d000 - 8087e000)

Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b  <-- Kernel panic here randomly. Same phenomena when the root-fs is located in SD.

CPU1: stopping

CPU: 1 PID: 0 Comm: swapper/1 Not tainted 3.11.0-rc3+ #13
Backtrace: 
[<80011b58>] (dump_backtrace+0x0/0x10c) from [<80011cf8>] (show_stack+0x18/0x1c)
 r6:bf896000 r5:8087dd84 r4:00000000 r3:00000000
[<80011ce0>] (show_stack+0x0/0x1c) from [<80642d8c>] (dump_stack+0x78/0x94)
[<80642d14>] (dump_stack+0x0/0x94) from [<80014a60>] (handle_IPI+0x138/0x174)
Quoted 4 lines

Thanks,

Tim

Thanks.

Best Regards
Richard Zhu

#14 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

On Thu, Oct 17, 2013 at 11:34 PM, Zhu Richard-R65037 <[email protected]> wrote:

[...]

Quoted 68 lines

Hi Tim:
Regarding to my experience, the difference shouldn't be related with the bus hang. Here are my DT region setup when I trying to bring up imx6 pcie on 3.1x kernel by my own driver.

                        clock-names = "pcie_axi", "pcie_ref", "pcie_bus_in", "pcie_bus_out";
                        #address-cells = <3>;
                        #size-cells = <2>;
                        ranges = <0x00000800 0 0x01f00000 0x01f00000 0 0x00080000   /* configuration space */
                                  0x81000000 0 0          0x01f80000 0 0x00010000   /* downstream I/O */
                                  0x82000000 0 0x01000000 0x01000000 0 0x00f00000>; /* non-prefetchable memory */
                        num-lanes = <1>;

It works sometimes, although that there is random kernel panic and system hang(log is pasted below):( LOGS, when pericom's PI7C9X2G303EL and Intel e1000e network card is used.
...
imx-pcie 1ffc000.pcie: legacy_irq 155
imx-pcie 1ffc000.pcie: map [mem 0x01ffc000-0x01ffffff]
IMX PCIe port: link up.
PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [io 0x1000-0x10000]
pci_bus 0000:00: root bus resource [mem 0x01000000-0x01efffff]
pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
PCI: bus0: Fast back to back transfers disabled
PCI: bus1: Fast back to back transfers disabled
pci 0000:01:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
PCI: bus2: Fast back to back transfers disabled
pci 0000:02:01.0: bridge configuration invalid ([bus 00-00]), reconfiguring
pci 0000:02:02.0: bridge configuration invalid ([bus 00-00]), reconfiguring
PCI: bus3: Fast back to back transfers disabled
PCI: bus4: Fast back to back transfers enabled
pci 0000:00:00.0: BAR 0: assigned [mem 0x01000000-0x010fffff 64bit]
pci 0000:00:00.0: BAR 8: assigned [mem 0x01100000-0x012fffff]
pci 0000:00:00.0: BAR 6: assigned [mem 0x01300000-0x0130ffff pref]
pci 0000:00:00.0: BAR 7: assigned [io 0x1000-0x1fff]
pci 0000:01:00.0: BAR 8: assigned [mem 0x01100000-0x012fffff]
pci 0000:01:00.0: BAR 7: assigned [io 0x1000-0x1fff]
pci 0000:02:01.0: BAR 8: assigned [mem 0x01100000-0x012fffff]
pci 0000:02:01.0: BAR 7: assigned [io 0x1000-0x1fff]
pci 0000:03:00.0: BAR 1: assigned [mem 0x01100000-0x011fffff]
pci 0000:03:00.0: BAR 0: assigned [mem 0x01200000-0x0121ffff]
pci 0000:03:00.0: BAR 3: assigned [mem 0x01220000-0x01223fff]
pci 0000:03:00.0: BAR 2: assigned [io 0x1000-0x101f]
pci 0000:02:01.0: PCI bridge to [bus 03]
pci 0000:02:01.0: bridge window [io 0x1000-0x1fff]
pci 0000:02:01.0: bridge window [mem 0x01100000-0x012fffff]
pci 0000:02:02.0: PCI bridge to [bus 04]
pci 0000:01:00.0: PCI bridge to [bus 02-04]
pci 0000:01:00.0: bridge window [io 0x1000-0x1fff]
pci 0000:01:00.0: bridge window [mem 0x01100000-0x012fffff]
pci 0000:00:00.0: PCI bridge to [bus 01-04]
pci 0000:00:00.0: bridge window [io 0x1000-0x1fff]
pci 0000:00:00.0: bridge window [mem 0x01100000-0x012fffff]
PCI: enabling device 0000:01:00.0 (0140 -> 0143)
PCI: enabling device 0000:02:01.0 (0140 -> 0143)
PCI: enabling device 0000:02:02.0 (0140 -> 0143)
...
e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k
e1000e: Copyright(c) 1999 - 2013 Intel Corporation.
e1000e 0000:03:00.0: Disabling ASPM L0s L1
PCI: enabling device 0000:03:00.0 (0140 -> 0142)
e1000e 0000:03:00.0: Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode e1000e 0000:03:00.0 eth1: registered PHC clock
e1000e 0000:03:00.0 eth1: (PCI Express:2.5GT/s:Width x1) 00:1b:21:3a:18:8b
e1000e 0000:03:00.0 eth1: Intel(R) PRO/1000 Network Connection
e1000e 0000:03:00.0 eth1: MAC: 3, PHY: 8, PBA No: E42641-005
igb: Intel(R) Gigabit Ethernet Network Driver - version 5.0.3-k
igb: Copyright (c) 2007-2013 Intel Corporation.
...

Quoted 6 lines

ALSA device list:
#0: wm8962-audio
VFS: Mounted root (nfs filesystem) on device 0:11.
devtmpfs: mounted
Freeing unused kernel memory: 324K (8082d000 - 8087e000)

Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b  <-- Kernel panic here randomly. Same phenomena when the root-fs is located in SD.

Richard,

I would suspect this is the imprecise abort issue. Please see my patch (http://thread.gmane.org/gmane.linux.kernel.pci/26159) resolves that for you and reply to that thread if so.

I believe that the imprecise abort's only occurs if you have a PCIe switch on the bus - is this your topology and if so are you experiencing any issues with devices behind the bus that use io regions? If you do have a switch, perhaps you can provide me with an 'lspci -v' for comparison.

Tim

#15 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Hi

Quoted 99 lines

-----Original Message-----
From: linux-pci-owner at vger.kernel.org [mailto:linux-pci-owner at vger.kernel.org] On Behalf Of Tim Harvey
Sent: Friday, October 18, 2013 3:28 PM
To: Zhu Richard-R65037
Cc: Sean Cross; devicetree at vger.kernel.org; linux-pci at vger.kernel.org; linux- arm-kernel at lists.infradead.org; Sascha Hauer; Shawn Guo; Bjorn Helgaas; Marek Va?ut; Jingoo Han; Pratyush Anand; Troy Kisky
Subject: Re: [PATCH v6 3/3] PCI: imx6: Add support for i.MX6 PCIe controller

On Thu, Oct 17, 2013 at 11:34 PM, Zhu Richard-R65037 <[email protected]> wrote:

[...]

Quoted 2 lines

Hi Tim:
Regarding to my experience, the difference shouldn't be related with the bus

hang.

Quoted 1 line

Here are my DT region setup when I trying to bring up imx6 pcie on 3.1x

kernel by my own driver.

Quoted 1 line
                        clock-names = "pcie_axi", "pcie_ref", "pcie_bus_in",

"pcie_bus_out";

Quoted 3 lines
                        #address-cells = <3>;
                        #size-cells = <2>;
                        ranges = <0x00000800 0 0x01f00000 0x01f00000 0

0x00080000 /* configuration space */

Quoted 1 line
                                  0x81000000 0 0          0x01f80000 0

0x00010000 /* downstream I/O */

Quoted 1 line
                                  0x82000000 0 0x01000000 0x01000000 0

0x00f00000>; /* non-prefetchable memory */

Quoted 4 lines
                        num-lanes = <1>;

It works sometimes, although that there is random kernel panic and system hang(log is pasted below):( LOGS, when pericom's PI7C9X2G303EL and

Intel e1000e network card is used.

Quoted 54 lines

...
imx-pcie 1ffc000.pcie: legacy_irq 155
imx-pcie 1ffc000.pcie: map [mem 0x01ffc000-0x01ffffff] IMX PCIe port:
link up.
PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [io 0x1000-0x10000] pci_bus 0000:00: root bus resource [mem 0x01000000-0x01efffff] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
PCI: bus0: Fast back to back transfers disabled
PCI: bus1: Fast back to back transfers disabled pci 0000:01:00.0:
bridge configuration invalid ([bus 00-00]), reconfiguring
PCI: bus2: Fast back to back transfers disabled pci 0000:02:01.0:
bridge configuration invalid ([bus 00-00]), reconfiguring pci 0000:02:02.0: bridge configuration invalid ([bus 00-00]), reconfiguring
PCI: bus3: Fast back to back transfers disabled
PCI: bus4: Fast back to back transfers enabled pci 0000:00:00.0: BAR 0: assigned [mem 0x01000000-0x010fffff 64bit] pci 0000:00:00.0: BAR 8:
assigned [mem 0x01100000-0x012fffff] pci 0000:00:00.0: BAR 6: assigned [mem 0x01300000-0x0130ffff pref] pci 0000:00:00.0: BAR 7: assigned [io 0x1000-0x1fff] pci 0000:01:00.0: BAR 8: assigned [mem 0x01100000-0x012fffff] pci 0000:01:00.0: BAR 7: assigned [io 0x1000-0x1fff] pci 0000:02:01.0: BAR 8: assigned [mem 0x01100000-0x012fffff] pci 0000:02:01.0: BAR 7: assigned [io 0x1000-0x1fff] pci 0000:03:00.0: BAR 1: assigned [mem 0x01100000-0x011fffff] pci 0000:03:00.0: BAR 0: assigned [mem 0x01200000-0x0121ffff] pci 0000:03:00.0: BAR 3: assigned [mem 0x01220000-0x01223fff] pci 0000:03:00.0: BAR 2: assigned [io 0x1000-0x101f] pci 0000:02:01.0: PCI bridge to [bus 03]
pci 0000:02:01.0: bridge window [io 0x1000-0x1fff]
pci 0000:02:01.0: bridge window [mem 0x01100000-0x012fffff]
pci 0000:02:02.0: PCI bridge to [bus 04] pci 0000:01:00.0: PCI bridge to [bus 02-04]
pci 0000:01:00.0: bridge window [io 0x1000-0x1fff]
pci 0000:01:00.0: bridge window [mem 0x01100000-0x012fffff]
pci 0000:00:00.0: PCI bridge to [bus 01-04]
pci 0000:00:00.0: bridge window [io 0x1000-0x1fff]
pci 0000:00:00.0: bridge window [mem 0x01100000-0x012fffff]
PCI: enabling device 0000:01:00.0 (0140 -> 0143)
PCI: enabling device 0000:02:01.0 (0140 -> 0143)
PCI: enabling device 0000:02:02.0 (0140 -> 0143) ...
e1000e: Intel(R) PRO/1000 Network Driver - 2.3.2-k
e1000e: Copyright(c) 1999 - 2013 Intel Corporation.
e1000e 0000:03:00.0: Disabling ASPM L0s L1
PCI: enabling device 0000:03:00.0 (0140 -> 0142) e1000e 0000:03:00.0:
Interrupt Throttling Rate (ints/sec) set to dynamic conservative mode e1000e 0000:03:00.0 eth1: registered PHC clock e1000e 0000:03:00.0
eth1: (PCI Express:2.5GT/s:Width x1) 00:1b:21:3a:18:8b e1000e 0000:03:00.0 eth1: Intel(R) PRO/1000 Network Connection e1000e 0000:03:00.0 eth1: MAC: 3, PHY: 8, PBA No: E42641-005
igb: Intel(R) Gigabit Ethernet Network Driver - version 5.0.3-k
igb: Copyright (c) 2007-2013 Intel Corporation.
...

Quoted 6 lines

ALSA device list:
#0: wm8962-audio
VFS: Mounted root (nfs filesystem) on device 0:11.
devtmpfs: mounted
Freeing unused kernel memory: 324K (8082d000 - 8087e000) Kernel panic
- not syncing: Attempted to kill init! exitcode=0x0000000b <-- Kernel panic

here randomly. Same phenomena when the root-fs is located in SD.

Richard,

Quoted 9 lines

I would suspect this is the imprecise abort issue. Please see my patch
(http://thread.gmane.org/gmane.linux.kernel.pci/26159) resolves that for you and reply to that thread if so.

I believe that the imprecise abort's only occurs if you have a PCIe switch on the bus - is this your topology and if so are you experiencing any issues with devices behind the bus that use io regions? If you do have a switch, perhaps you can provide me with an 'lspci -v' for comparison.

Hi Tim:
Oh, It's great. Your patch can fix my problem.
My own patch-set of pcie driver works well when my Pericom's switch is used. Thanks a lot.

Yes, it is.
E1000e network card request about 32 bytes IO regions during the bus enumeration procedure, and it works well behind the my Pericom's switch.

Based on my own pcie driver(not the one up-streamed by Sean), Here are the log and the lspci -v results I got just now:

imx-pcie 1ffc000.pcie: legacy_irq 155
imx-pcie 1ffc000.pcie: map [mem 0x01ffc000-0x01ffffff]
imx-pcie 1ffc000.pcie: starting to link pcie port.
imx-pcie 1ffc000.pcie: Link up
PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [io 0x1000-0x10000]
pci_bus 0000:00: root bus resource [mem 0x01000000-0x01efffff] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
PCI: bus0: Fast back to back transfers disabled
PCI: bus1: Fast back to back transfers disabled
pci 0000:01:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
PCI: bus2: Fast back to back transfers disabled
pci 0000:02:01.0: bridge configuration invalid ([bus 00-00]), reconfiguring pci 0000:02:02.0: bridge configuration invalid ([bus 00-00]), reconfiguring
PCI: bus3: Fast back to back transfers disabled
PCI: bus4: Fast back to back transfers enabled
pci 0000:00:00.0: BAR 0: assigned [mem 0x01000000-0x010fffff] pci 0000:00:00.0: BAR 8: assigned [mem 0x01100000-0x011fffff] pci 0000:00:00.0: BAR 9: assigned [mem 0x01200000-0x012fffff pref] pci 0000:00:00.0: BAR 6: assigned [mem 0x01300000-0x0130ffff pref] pci 0000:00:00.0: BAR 7: assigned [io 0x1000-0x1fff]
pci 0000:01:00.0: BAR 8: assigned [mem 0x01100000-0x011fffff] pci 0000:01:00.0: BAR 9: assigned [mem 0x01200000-0x012fffff pref] pci 0000:01:00.0: BAR 7: assigned [io 0x1000-0x1fff]
pci 0000:02:01.0: BAR 8: assigned [mem 0x01100000-0x011fffff] pci 0000:02:01.0: BAR 9: assigned [mem 0x01200000-0x012fffff pref] pci 0000:02:01.0: BAR 7: assigned [io 0x1000-0x1fff]
pci 0000:03:00.0: BAR 1: assigned [mem 0x01100000-0x0117ffff] pci 0000:03:00.0: BAR 6: assigned [mem 0x01200000-0x0123ffff pref] pci 0000:03:00.0: BAR 0: assigned [mem 0x01180000-0x0119ffff] pci 0000:03:00.0: BAR 3: assigned [mem 0x011a0000-0x011a3fff] pci 0000:03:00.0: BAR 2: assigned [io 0x1000-0x101f]
pci 0000:02:01.0: PCI bridge to [bus 03]

pci 0000:02:01.0:   bridge window [io  0x1000-0x1fff]
pci 0000:02:01.0:   bridge window [mem 0x01100000-0x011fffff]
pci 0000:02:01.0:   bridge window [mem 0x01200000-0x012fffff pref]
pci 0000:02:02.0: PCI bridge to [bus 04]
pci 0000:01:00.0: PCI bridge to [bus 02-04]
pci 0000:01:00.0:   bridge window [io  0x1000-0x1fff]
pci 0000:01:00.0:   bridge window [mem 0x01100000-0x011fffff]
pci 0000:01:00.0:   bridge window [mem 0x01200000-0x012fffff pref]
pci 0000:00:00.0: PCI bridge to [bus 01-04]
pci 0000:00:00.0:   bridge window [io  0x1000-0x1fff]
pci 0000:00:00.0:   bridge window [mem 0x01100000-0x011fffff]
pci 0000:00:00.0:   bridge window [mem 0x01200000-0x012fffff pref]

PCI: enabling device 0000:01:00.0 (0140 -> 0143)
PCI: enabling device 0000:02:01.0 (0140 -> 0143)
PCI: enabling device 0000:02:02.0 (0140 -> 0143)
...
root at freescale ~$ lspci -v
00:00.0 PCI bridge: Unknown device 16c3:abcd (rev 01) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0
Memory at 01000000 (32-bit, non-prefetchable) [size=1M]
Bus: primary=00, secondary=01, subordinate=04, sec-latency=0
I/O behind bridge: 00001000-00001fff
Memory behind bridge: 01100000-011fffff
Prefetchable memory behind bridge: 01200000-012fffff
[virtual] Expansion ROM at 01300000 [disabled] [size=64K]
Capabilities: [40] Power Management version 3
Capabilities: [50] Message Signalled Interrupts: Mask+ 64bit+ Queue=0/0 Enable-
Capabilities: [70] Express Root Port (Slot-) IRQ 0
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel

01:00.0 PCI bridge: Pericom Semiconductor Unknown device 2303 (rev 05) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0
Bus: primary=01, secondary=02, subordinate=04, sec-latency=0
I/O behind bridge: 00001000-00001fff
Memory behind bridge: 01100000-011fffff
Prefetchable memory behind bridge: 0000000001200000-00000000012fffff
Capabilities: [40] Power Management version 3
Capabilities: [5c] Vital Product Data
Capabilities: [64] Vendor Specific Information
Capabilities: [b0] Subsystem: Gammagraphx, Inc. Unknown device 0000
Capabilities: [c0] Express Upstream Port IRQ 0
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel
Capabilities: [20c] Power Budgeting
Capabilities: [230] Unknown (24)

02:01.0 PCI bridge: Pericom Semiconductor Unknown device 2303 (rev 05) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0
Bus: primary=02, secondary=03, subordinate=03, sec-latency=0
I/O behind bridge: 00001000-00001fff
Memory behind bridge: 01100000-011fffff
Prefetchable memory behind bridge: 0000000001200000-00000000012fffff
Capabilities: [40] Power Management version 3
Capabilities: [4c] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-
Capabilities: [64] Vendor Specific Information
Capabilities: [b0] Subsystem: Gammagraphx, Inc. Unknown device 0000
Capabilities: [c0] Express Downstream Port (Slot+) IRQ 0
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel
Capabilities: [20c] Power Budgeting
Capabilities: [220] Unknown (13)

02:02.0 PCI bridge: Pericom Semiconductor Unknown device 2303 (rev 05) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0
Bus: primary=02, secondary=04, subordinate=04, sec-latency=0
Capabilities: [40] Power Management version 3
Capabilities: [4c] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-
Capabilities: [64] Vendor Specific Information
Capabilities: [b0] Subsystem: Gammagraphx, Inc. Unknown device 0000
Capabilities: [c0] Express Downstream Port (Slot+) IRQ 0
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel
Capabilities: [20c] Power Budgeting
Capabilities: [220] Unknown (13)

03:00.0 Ethernet controller: Intel Corporation Unknown device 10d3
Subsystem: Intel Corporation Unknown device a01f
Flags: bus master, fast devsel, latency 0, IRQ 154
Memory at 01180000 (32-bit, non-prefetchable) [size=128K]
Memory at 01100000 (32-bit, non-prefetchable) [size=512K]
I/O ports at 1000 [disabled] [size=32]
Memory at 011a0000 (32-bit, non-prefetchable) [size=16K] [virtual] Expansion ROM at 01200000 [disabled] [size=256K]
Capabilities: [c8] Power Management version 2
Capabilities: [d0] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-
Capabilities: [e0] Express Endpoint IRQ 0
Capabilities: [a0] MSI-X: Enable- Mask- TabSize=5
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Device Serial Number 8b-18-3a-ff-ff-21-1b-00

Quoted 5 lines

Tim
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo at vger.kernel.org More majordomo info at
http://vger.kernel.org/majordomo-info.html

Best Regards
Richard

#16 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

On Fri, Oct 18, 2013 at 12:45 AM, Zhu Richard-R65037 <[email protected]> wrote:

[...]

Quoted 13 lines
Quoted 4 lines

Richard,

Quoted 9 lines

I would suspect this is the imprecise abort issue. Please see my patch
(http://thread.gmane.org/gmane.linux.kernel.pci/26159) resolves that for you and reply to that thread if so.

I believe that the imprecise abort's only occurs if you have a PCIe switch on the bus - is this your topology and if so are you experiencing any issues with devices behind the bus that use io regions? If you do have a switch, perhaps you can provide me with an 'lspci -v' for comparison.

Quoted 4 lines

Hi Tim:
Oh, It's great. Your patch can fix my problem.
My own patch-set of pcie driver works well when my Pericom's switch is used. Thanks a lot.

Good to hear! Please reply to that thread and provide an Acked-by and Tested-by so we can get that patch upstream.

Quoted 6 lines

Yes, it is.
E1000e network card request about 32 bytes IO regions during the bus enumeration procedure, and it works well behind the my Pericom's switch.

Based on my own pcie driver(not the one up-streamed by Sean),

How about with the upstream driver? I have 'my own driver' as well (based on Freescale's BSP) which works, but I'm very interested in getting this upstream driver to work so we don't have to keep maintaining our own drivers. Can you please test with this upstream driver?

Quoted 111 lines

Here are the log and the lspci -v results I got just now:

imx-pcie 1ffc000.pcie: legacy_irq 155
imx-pcie 1ffc000.pcie: map [mem 0x01ffc000-0x01ffffff]
imx-pcie 1ffc000.pcie: starting to link pcie port.
imx-pcie 1ffc000.pcie: Link up
PCI host bridge to bus 0000:00
pci_bus 0000:00: root bus resource [io 0x1000-0x10000]
pci_bus 0000:00: root bus resource [mem 0x01000000-0x01efffff] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
PCI: bus0: Fast back to back transfers disabled
PCI: bus1: Fast back to back transfers disabled
pci 0000:01:00.0: bridge configuration invalid ([bus 00-00]), reconfiguring
PCI: bus2: Fast back to back transfers disabled
pci 0000:02:01.0: bridge configuration invalid ([bus 00-00]), reconfiguring pci 0000:02:02.0: bridge configuration invalid ([bus 00-00]), reconfiguring
PCI: bus3: Fast back to back transfers disabled
PCI: bus4: Fast back to back transfers enabled
pci 0000:00:00.0: BAR 0: assigned [mem 0x01000000-0x010fffff] pci 0000:00:00.0: BAR 8: assigned [mem 0x01100000-0x011fffff] pci 0000:00:00.0: BAR 9: assigned [mem 0x01200000-0x012fffff pref] pci 0000:00:00.0: BAR 6: assigned [mem 0x01300000-0x0130ffff pref] pci 0000:00:00.0: BAR 7: assigned [io 0x1000-0x1fff]
pci 0000:01:00.0: BAR 8: assigned [mem 0x01100000-0x011fffff] pci 0000:01:00.0: BAR 9: assigned [mem 0x01200000-0x012fffff pref] pci 0000:01:00.0: BAR 7: assigned [io 0x1000-0x1fff]
pci 0000:02:01.0: BAR 8: assigned [mem 0x01100000-0x011fffff] pci 0000:02:01.0: BAR 9: assigned [mem 0x01200000-0x012fffff pref] pci 0000:02:01.0: BAR 7: assigned [io 0x1000-0x1fff]
pci 0000:03:00.0: BAR 1: assigned [mem 0x01100000-0x0117ffff] pci 0000:03:00.0: BAR 6: assigned [mem 0x01200000-0x0123ffff pref] pci 0000:03:00.0: BAR 0: assigned [mem 0x01180000-0x0119ffff] pci 0000:03:00.0: BAR 3: assigned [mem 0x011a0000-0x011a3fff] pci 0000:03:00.0: BAR 2: assigned [io 0x1000-0x101f]
pci 0000:02:01.0: PCI bridge to [bus 03]

pci 0000:02:01.0:   bridge window [io  0x1000-0x1fff]
pci 0000:02:01.0:   bridge window [mem 0x01100000-0x011fffff]
pci 0000:02:01.0:   bridge window [mem 0x01200000-0x012fffff pref]
pci 0000:02:02.0: PCI bridge to [bus 04]
pci 0000:01:00.0: PCI bridge to [bus 02-04]
pci 0000:01:00.0:   bridge window [io  0x1000-0x1fff]
pci 0000:01:00.0:   bridge window [mem 0x01100000-0x011fffff]
pci 0000:01:00.0:   bridge window [mem 0x01200000-0x012fffff pref]
pci 0000:00:00.0: PCI bridge to [bus 01-04]
pci 0000:00:00.0:   bridge window [io  0x1000-0x1fff]
pci 0000:00:00.0:   bridge window [mem 0x01100000-0x011fffff]
pci 0000:00:00.0:   bridge window [mem 0x01200000-0x012fffff pref]

PCI: enabling device 0000:01:00.0 (0140 -> 0143)
PCI: enabling device 0000:02:01.0 (0140 -> 0143)
PCI: enabling device 0000:02:02.0 (0140 -> 0143)
...
root at freescale ~$ lspci -v
00:00.0 PCI bridge: Unknown device 16c3:abcd (rev 01) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0
Memory at 01000000 (32-bit, non-prefetchable) [size=1M]
Bus: primary=00, secondary=01, subordinate=04, sec-latency=0
I/O behind bridge: 00001000-00001fff
Memory behind bridge: 01100000-011fffff
Prefetchable memory behind bridge: 01200000-012fffff
[virtual] Expansion ROM at 01300000 [disabled] [size=64K]
Capabilities: [40] Power Management version 3
Capabilities: [50] Message Signalled Interrupts: Mask+ 64bit+ Queue=0/0 Enable-
Capabilities: [70] Express Root Port (Slot-) IRQ 0
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel

01:00.0 PCI bridge: Pericom Semiconductor Unknown device 2303 (rev 05) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0
Bus: primary=01, secondary=02, subordinate=04, sec-latency=0
I/O behind bridge: 00001000-00001fff
Memory behind bridge: 01100000-011fffff
Prefetchable memory behind bridge: 0000000001200000-00000000012fffff
Capabilities: [40] Power Management version 3
Capabilities: [5c] Vital Product Data
Capabilities: [64] Vendor Specific Information
Capabilities: [b0] Subsystem: Gammagraphx, Inc. Unknown device 0000
Capabilities: [c0] Express Upstream Port IRQ 0
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel
Capabilities: [20c] Power Budgeting
Capabilities: [230] Unknown (24)

02:01.0 PCI bridge: Pericom Semiconductor Unknown device 2303 (rev 05) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0
Bus: primary=02, secondary=03, subordinate=03, sec-latency=0
I/O behind bridge: 00001000-00001fff
Memory behind bridge: 01100000-011fffff
Prefetchable memory behind bridge: 0000000001200000-00000000012fffff
Capabilities: [40] Power Management version 3
Capabilities: [4c] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-
Capabilities: [64] Vendor Specific Information
Capabilities: [b0] Subsystem: Gammagraphx, Inc. Unknown device 0000
Capabilities: [c0] Express Downstream Port (Slot+) IRQ 0
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel
Capabilities: [20c] Power Budgeting
Capabilities: [220] Unknown (13)

02:02.0 PCI bridge: Pericom Semiconductor Unknown device 2303 (rev 05) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0
Bus: primary=02, secondary=04, subordinate=04, sec-latency=0
Capabilities: [40] Power Management version 3
Capabilities: [4c] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-
Capabilities: [64] Vendor Specific Information
Capabilities: [b0] Subsystem: Gammagraphx, Inc. Unknown device 0000
Capabilities: [c0] Express Downstream Port (Slot+) IRQ 0
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel
Capabilities: [20c] Power Budgeting
Capabilities: [220] Unknown (13)

Quoted 15 lines

03:00.0 Ethernet controller: Intel Corporation Unknown device 10d3
Subsystem: Intel Corporation Unknown device a01f
Flags: bus master, fast devsel, latency 0, IRQ 154
Memory at 01180000 (32-bit, non-prefetchable) [size=128K]
Memory at 01100000 (32-bit, non-prefetchable) [size=512K]
I/O ports at 1000 [disabled] [size=32]
Memory at 011a0000 (32-bit, non-prefetchable) [size=16K] [virtual] Expansion ROM at 01200000 [disabled] [size=256K]
Capabilities: [c8] Power Management version 2
Capabilities: [d0] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-
Capabilities: [e0] Express Endpoint IRQ 0
Capabilities: [a0] MSI-X: Enable- Mask- TabSize=5
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Device Serial Number 8b-18-3a-ff-ff-21-1b-00

The above device does show an io resource but it says its disabled? I'm not sure what that means, but I'm not convinced you would see the same issue as I do if the io resource isn't being used.

Tim

#17 lore raw

Re: [PATCH v6 3/3] PCI: imx6: Add support for i.MX6 PCIe controller

Quoted 7 lines · Tim Harvey

On Fri, Oct 18, 2013 at 12:45 AM, Zhu Richard-R65037 [...]
How about with the upstream driver? I have 'my own driver' as well (based on Freescale's BSP) which works, but I'm very interested in getting this upstream driver to work so we don't have to keep maintaining our own drivers. Can you please test with this upstream driver?

Tim, Sean what is the status of this patch ? Is it part of any tree
already ? I'd like to test few things.

Thanks

Sinan Akman

maintainer
#18 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Quoted 2 lines · Sinan Akman

Tim, Sean what is the status of this patch ? Is it part of any tree
already ? I'd like to test few things.

This patch is in my "next" branch and will be merged into Linus' tree during the v3.13 merge window (probably next week). It's also in the linux-next tree.

http://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/commit/?h=next&id=bb38919ec56e0758c3ae56dfc091dcde1391353e

#19 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Quoted 9 lines · Bjorn Helgaas
Quoted 2 lines · Sinan Akman

Tim, Sean what is the status of this patch ? Is it part of any tree
already ? I'd like to test few things.

This patch is in my "next" branch and will be merged into Linus' tree during the v3.13 merge window (probably next week). It's also in the linux-next tree.

http://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/commit/?h=next&id=bb38919ec56e0758c3ae56dfc091dcde1391353e

Does anybody know how to test this on a SabreSD board?

I have added the following to imx6qdl-sabresd.dtsi:
---------------------
@@ -166,10 +166,21 @@

&iomuxc {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_hog>;

+ pcie {
+ pinctrl_pcie: pciegrp {
+ fsl,pins = <
+ MX6QDL_PAD_GPIO_17__GPIO7_IO12 0x80000000
+ MX6QDL_PAD_EIM_D19__GPIO3_IO19 0x80000000
+ MX6QDL_PAD_CSI0_DATA_EN__GPIO5_IO20 0x80000000
+ MX6QDL_PAD_KEY_COL4__GPIO4_IO14 0x80000000
+ >;
+ };
+ };
+
hog {
pinctrl_hog: hoggrp {
fsl,pins = <
MX6QDL_PAD_GPIO_4__GPIO1_IO04 0x80000000
MX6QDL_PAD_GPIO_5__GPIO1_IO05 0x80000000
@@ -185,10 +196,20 @@
>;
};
};
};

+&pcie {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_pcie>;
+ reset-gpio = <&gpio7 12 0>;
+ power-on-gpio = <&gpio3 19 0>;
+ wake-up-gpio = <&gpio5 20 0>;
+ disable-gpio = <&gpio4 14 0>;
+ status = "okay";
+};
+
&ldb {
status = "okay";

lvds-channel at 1 {
fsl,data-mapping = "spwg";
---------------------

But during booting it says:
imx6q-pcie 1ffc000.pcie: phy link never came up

Thanks in advance,

Harro

Note: the e1000e network card does work with the FSL imx_3.0.35 kernel

#20 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Hi Harro:

Quoted 69 lines

-----Original Message-----
From: Harro Haan [mailto:hrhaan at gmail.com]
Sent: Sunday, November 24, 2013 1:28 AM
To: linux-arm-kernel at lists.infradead.org
Cc: Sinan Akman; Zhu Richard-R65037; Marek Va?ut; Pratyush Anand; Tim Harvey; Jingoo Han; Troy Kisky; Sean Cross; Shawn Guo; Sascha Hauer; Bjorn Helgaas
Subject: Re: [PATCH v6 3/3] PCI: imx6: Add support for i.MX6 PCIe controller

Quoted 10 lines · Bjorn Helgaas
Quoted 2 lines · Sinan Akman

Tim, Sean what is the status of this patch ? Is it part of any tree
already ? I'd like to test few things.

This patch is in my "next" branch and will be merged into Linus' tree during the v3.13 merge window (probably next week). It's also in the linux-next tree.

http://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/commit/?h=
next&id=bb38919ec56e0758c3ae56dfc091dcde1391353e

Does anybody know how to test this on a SabreSD board?

I have added the following to imx6qdl-sabresd.dtsi:
---------------------

(quoted diff) +21 -1
@@ -166,10 +166,21 @@
 
 &iomuxc {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_hog>;
 
+	pcie {
+		pinctrl_pcie: pciegrp {
+			fsl,pins = <
+				MX6QDL_PAD_GPIO_17__GPIO7_IO12      0x80000000
+				MX6QDL_PAD_EIM_D19__GPIO3_IO19      0x80000000
+				MX6QDL_PAD_CSI0_DATA_EN__GPIO5_IO20 0x80000000
+				MX6QDL_PAD_KEY_COL4__GPIO4_IO14     0x80000000
+			>;
+		};
+	};
+
 	hog {
 		pinctrl_hog: hoggrp {
 			fsl,pins = <
 				MX6QDL_PAD_GPIO_4__GPIO1_IO04   0x80000000
 				MX6QDL_PAD_GPIO_5__GPIO1_IO05   0x80000000
@@ -185,10 +196,20 @@
 			>;
 		};
 	};
 };
 
+&pcie {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_pcie>;
+	reset-gpio = <&gpio7 12 0>;
+	power-on-gpio = <&gpio3 19 0>;
+	wake-up-gpio = <&gpio5 20 0>;
+	disable-gpio = <&gpio4 14 0>;
+	status = "okay";
+};
+
 &ldb {
 	status = "okay";
 
 	lvds-channel at 1 {
 		fsl,data-mapping = "spwg";
---------------------
Quoted 6 lines

But during booting it says:
imx6q-pcie 1ffc000.pcie: phy link never came up

Thanks in advance,

Harro

[Richard] Regarding to my experience, based on Shawn's(http://git.linaro.org/git-ro/people/shawnguo/linux-2.6.git)
for-next branch, cherry-pick the imx6-pcie patch set merged on host-imx6 branch on PCIe git-repos.
Re-setup the clock configurations refer to your kernel baseline.
Here is one example at my local git-repos site, hope it is helpful.
-------------------------------------------------
pcie: switch to upstreamed pcie driver

Based on community patch-set, re-setup pcie driver on imx6 platforms.
* re-fine the pcie clks.
* add the pcie support in dts files.

---
 .../devicetree/bindings/clock/imx6q-clock.txt      |    6 +++---
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi           |    4 ++++
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi             |    7 +++++++
 arch/arm/boot/dts/imx6qdl.dtsi                     |    4 ++--
 arch/arm/mach-imx/Kconfig                          |    2 ++
 arch/arm/mach-imx/clk-imx6q.c                      |   17 ++++++++++++++++-
 6 files changed, 34 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/clock/imx6q-clock.txt +3 -3
index 02ad157..b289100 100644
@@ -220,9 +220,9 @@ clocks and IDs.
 	ldb_di0_div_sel		207
 	ldb_di1_div_sel		208
 	pll4_audio_div		209
-	pcie_dummy1   		210
-	pcie_dummy2   		211
-	pcie_dummy3   		212
+	lvds1_sel      		210
+	lvds1_in      		211
+	lvds1_out		212
 	caam_mem		213
 	caam_aclk		214
 	caam_ipg		215
arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +4 -0
index bbd4bfb..e011ba7 100644
@@ -590,6 +590,10 @@
 	status = "okay";
 };
 
+&pcie {
+	status = "okay";
+};
+
 &pwm3 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_pwm3_1>;
arch/arm/boot/dts/imx6qdl-sabresd.dtsi +7 -0
index 4de08aa..5236ff6 100644
@@ -611,6 +611,13 @@
 	status = "okay";
 };
 
+&pcie {
+	power-on-gpio = <&gpio3 19 0>;
+	reset-gpio = <&gpio7 12 0>;
+	status = "okay";
+};
+
+
 &pwm1 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_pwm1_1>;
arch/arm/boot/dts/imx6qdl.dtsi +2 -2
index c2f7fd5..1e40164 100644
@@ -128,8 +128,8 @@
 				  0x82000000 0 0x01000000 0x01000000 0 0x00f00000>; /* non-prefetchable memory */
 			num-lanes = <1>;
 			interrupts = <0 123 0x04>;
-			clocks = <&clks 189>, <&clks 187>, <&clks 206>, <&clks 144>;
-			clock-names = "pcie_ref_125m", "sata_ref_100m", "lvds_gate", "pcie_axi";
+			clocks = <&clks 189>, <&clks 187>, <&clks 144>, <&clks 212>;
+			clock-names = "pcie_ref_125m", "sata_ref_100m", "pcie_axi", "lvds_gate";
 			status = "disabled";
 		};
 
arch/arm/mach-imx/Kconfig +2 -0
index 0633cf9..c26aac0 100644
@@ -809,6 +809,8 @@ config SOC_IMX6Q
 	select HAVE_IMX_SRC
 	select HAVE_SMP
 	select MFD_SYSCON
+	select MIGHT_HAVE_PCI
+	select PCI_DOMAINS if PCI
 	select PINCTRL
 	select PINCTRL_IMX6Q
 	select PL310_ERRATA_588369 if CACHE_PL310
arch/arm/mach-imx/clk-imx6q.c +16 -1
index 0923ff8..96e3198 100644
@@ -71,6 +71,8 @@ static const char *cko2_sels[] = {
 	"uart_serial", "spdif", "asrc", "hsi_tx",
 };
 static const char *cko_sels[] = { "cko1", "cko2", };
+static const char *lvds_sels[]	= { "arm", "pll1_sys", "dummy", "dummy", "dummy", "dummy", "dummy", "pll5_video_div",
+				    "dummy", "dummy", "pcie_ref", "sata_ref", "usbphy1", "usbphy2", };
 
 enum mx6q_clks {
 	dummy, ckil, ckih, osc, pll2_pfd0_352m, pll2_pfd1_594m, pll2_pfd2_396m,
@@ -107,7 +109,7 @@ enum mx6q_clks {
 	usbphy2_gate, pll4_post_div, pll5_post_div, pll5_video_div, eim_slow,
 	spdif, cko2_sel, cko2_podf, cko2, cko, vdoa, gpt_3m, video_27m,
 	ldb_di0_div_7, ldb_di1_div_7, ldb_di0_div_sel, ldb_di1_div_sel,
-	pll4_audio_div, pcie_dummy1, pcie_dummy2, pcie_dummy3, caam_mem, caam_aclk,
+	pll4_audio_div, lvds1_sel, lvds1_in, lvds1_out, caam_mem, caam_aclk,
 	caam_ipg, epit1, epit2, tzasc2, clk_max
 };
 
@@ -173,6 +175,9 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
 	clk[pll6_enet]     = imx_clk_pllv3(IMX_PLLV3_ENET,	"pll6_enet",	"osc", base + 0xe0, 0x3, false);
 	clk[pll7_usb_host] = imx_clk_pllv3(IMX_PLLV3_USB,	"pll7_usb_host",	"osc", base + 0x20, 0x3, false);
 
+	/*                              name            reg       shift width parent_names     num_parents */
+	clk[lvds1_sel]    = imx_clk_mux("lvds1_sel",    base + 0x160, 0,  5,  lvds_sels,       ARRAY_SIZE(lvds_sels));
+
 	/*
 	 * Bit 20 is the reserved and read-only bit, we do this only for:
 	 * - Do nothing for usbphy clk_enable/disable
@@ -191,6 +196,9 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
 
 	clk[sata_ref] = imx_clk_fixed_factor("sata_ref", "pll6_enet", 1, 5);
 	clk[pcie_ref] = imx_clk_fixed_factor("pcie_ref", "pll6_enet", 1, 4);
+	/* NOTICE: The gate of the lvds1 in/out is used to select the clk direction */
+	clk[lvds1_in] = imx_clk_gate("lvds1_in", NULL, base + 0x160, 12);
+	clk[lvds1_out] = imx_clk_gate("lvds1_out", "lvds1_sel", base + 0x160, 10);
 
 	clk[sata_ref_100m] = imx_clk_gate("sata_ref_100m", "sata_ref", base + 0xe0, 20);
 	clk[pcie_ref_125m] = imx_clk_gate("pcie_ref_125m", "pcie_ref", base + 0xe0, 19);
@@ -482,6 +490,13 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
 	 */
 	clk_set_parent(clk[enfc_sel], clk[pll2_pfd2_396m]);
 
+	/* Set the parent clks of PCIe lvds1 and pcie_axi to be sata ref, axi */
+	if (clk_set_parent(clk[lvds1_sel], clk[sata_ref]))
+		pr_err("Failed to set PCIe bus parent clk.\n");
+	if (clk_set_parent(clk[pcie_axi_sel], clk[axi]))
+		pr_err("Failed to set PCIe parent clk.\n");
+
+
 	/* gpu clock initilazation */
 	clk_set_parent(clk[gpu3d_shader_sel], clk[pll2_pfd1_594m]);
 	clk_set_rate(clk[gpu3d_shader], 594000000);
Quoted 2 lines

Note: the e1000e network card does work with the FSL imx_3.0.35 kernel

Best Regards
Richard Zhu

#21 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Richard,

Quoted 2 lines · Richard Zhu

[Richard] Regarding to my experience, based on Shawn's(http://git.linaro.org/git-ro/people/shawnguo/linux-2.6.git)
for-next branch, cherry-pick the imx6-pcie patch set merged on host-imx6 branch on PCIe git-repos.

Since v3.13-rc1 is out there with pci-imx6 driver merged, can you please give it a test to see what's missing there at platform level to get PCIe support on imx6q-sabresd? That will be easy for Harro to follow.

Shawn

Quoted 162 lines

Re-setup the clock configurations refer to your kernel baseline. Here is one example at my local git-repos site, hope it is helpful.
-------------------------------------------------
pcie: switch to upstreamed pcie driver

Based on community patch-set, re-setup pcie driver on imx6 platforms.
* re-fine the pcie clks.
* add the pcie support in dts files.

---
 .../devicetree/bindings/clock/imx6q-clock.txt      |    6 +++---
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi           |    4 ++++
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi             |    7 +++++++
 arch/arm/boot/dts/imx6qdl.dtsi                     |    4 ++--
 arch/arm/mach-imx/Kconfig                          |    2 ++
 arch/arm/mach-imx/clk-imx6q.c                      |   17 ++++++++++++++++-
 6 files changed, 34 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/clock/imx6q-clock.txt +3 -3
index 02ad157..b289100 100644
@@ -220,9 +220,9 @@ clocks and IDs.
 	ldb_di0_div_sel		207
 	ldb_di1_div_sel		208
 	pll4_audio_div		209
-	pcie_dummy1   		210
-	pcie_dummy2   		211
-	pcie_dummy3   		212
+	lvds1_sel      		210
+	lvds1_in      		211
+	lvds1_out		212
 	caam_mem		213
 	caam_aclk		214
 	caam_ipg		215
arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +4 -0
index bbd4bfb..e011ba7 100644
@@ -590,6 +590,10 @@
 	status = "okay";
 };
 
+&pcie {
+	status = "okay";
+};
+
 &pwm3 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_pwm3_1>;
arch/arm/boot/dts/imx6qdl-sabresd.dtsi +7 -0
index 4de08aa..5236ff6 100644
@@ -611,6 +611,13 @@
 	status = "okay";
 };
 
+&pcie {
+	power-on-gpio = <&gpio3 19 0>;
+	reset-gpio = <&gpio7 12 0>;
+	status = "okay";
+};
+
+
 &pwm1 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_pwm1_1>;
arch/arm/boot/dts/imx6qdl.dtsi +2 -2
index c2f7fd5..1e40164 100644
@@ -128,8 +128,8 @@
 				  0x82000000 0 0x01000000 0x01000000 0 0x00f00000>; /* non-prefetchable memory */
 			num-lanes = <1>;
 			interrupts = <0 123 0x04>;
-			clocks = <&clks 189>, <&clks 187>, <&clks 206>, <&clks 144>;
-			clock-names = "pcie_ref_125m", "sata_ref_100m", "lvds_gate", "pcie_axi";
+			clocks = <&clks 189>, <&clks 187>, <&clks 144>, <&clks 212>;
+			clock-names = "pcie_ref_125m", "sata_ref_100m", "pcie_axi", "lvds_gate";
 			status = "disabled";
 		};
 
arch/arm/mach-imx/Kconfig +2 -0
index 0633cf9..c26aac0 100644
@@ -809,6 +809,8 @@ config SOC_IMX6Q
 	select HAVE_IMX_SRC
 	select HAVE_SMP
 	select MFD_SYSCON
+	select MIGHT_HAVE_PCI
+	select PCI_DOMAINS if PCI
 	select PINCTRL
 	select PINCTRL_IMX6Q
 	select PL310_ERRATA_588369 if CACHE_PL310
arch/arm/mach-imx/clk-imx6q.c +16 -1
index 0923ff8..96e3198 100644
@@ -71,6 +71,8 @@ static const char *cko2_sels[] = {
 	"uart_serial", "spdif", "asrc", "hsi_tx",
 };
 static const char *cko_sels[] = { "cko1", "cko2", };
+static const char *lvds_sels[]	= { "arm", "pll1_sys", "dummy", "dummy", "dummy", "dummy", "dummy", "pll5_video_div",
+				    "dummy", "dummy", "pcie_ref", "sata_ref", "usbphy1", "usbphy2", };
 
 enum mx6q_clks {
 	dummy, ckil, ckih, osc, pll2_pfd0_352m, pll2_pfd1_594m, pll2_pfd2_396m,
@@ -107,7 +109,7 @@ enum mx6q_clks {
 	usbphy2_gate, pll4_post_div, pll5_post_div, pll5_video_div, eim_slow,
 	spdif, cko2_sel, cko2_podf, cko2, cko, vdoa, gpt_3m, video_27m,
 	ldb_di0_div_7, ldb_di1_div_7, ldb_di0_div_sel, ldb_di1_div_sel,
-	pll4_audio_div, pcie_dummy1, pcie_dummy2, pcie_dummy3, caam_mem, caam_aclk,
+	pll4_audio_div, lvds1_sel, lvds1_in, lvds1_out, caam_mem, caam_aclk,
 	caam_ipg, epit1, epit2, tzasc2, clk_max
 };
 
@@ -173,6 +175,9 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
 	clk[pll6_enet]     = imx_clk_pllv3(IMX_PLLV3_ENET,	"pll6_enet",	"osc", base + 0xe0, 0x3, false);
 	clk[pll7_usb_host] = imx_clk_pllv3(IMX_PLLV3_USB,	"pll7_usb_host",	"osc", base + 0x20, 0x3, false);
 
+	/*                              name            reg       shift width parent_names     num_parents */
+	clk[lvds1_sel]    = imx_clk_mux("lvds1_sel",    base + 0x160, 0,  5,  lvds_sels,       ARRAY_SIZE(lvds_sels));
+
 	/*
 	 * Bit 20 is the reserved and read-only bit, we do this only for:
 	 * - Do nothing for usbphy clk_enable/disable
@@ -191,6 +196,9 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
 
 	clk[sata_ref] = imx_clk_fixed_factor("sata_ref", "pll6_enet", 1, 5);
 	clk[pcie_ref] = imx_clk_fixed_factor("pcie_ref", "pll6_enet", 1, 4);
+	/* NOTICE: The gate of the lvds1 in/out is used to select the clk direction */
+	clk[lvds1_in] = imx_clk_gate("lvds1_in", NULL, base + 0x160, 12);
+	clk[lvds1_out] = imx_clk_gate("lvds1_out", "lvds1_sel", base + 0x160, 10);
 
 	clk[sata_ref_100m] = imx_clk_gate("sata_ref_100m", "sata_ref", base + 0xe0, 20);
 	clk[pcie_ref_125m] = imx_clk_gate("pcie_ref_125m", "pcie_ref", base + 0xe0, 19);
@@ -482,6 +490,13 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node)
 	 */
 	clk_set_parent(clk[enfc_sel], clk[pll2_pfd2_396m]);
 
+	/* Set the parent clks of PCIe lvds1 and pcie_axi to be sata ref, axi */
+	if (clk_set_parent(clk[lvds1_sel], clk[sata_ref]))
+		pr_err("Failed to set PCIe bus parent clk.\n");
+	if (clk_set_parent(clk[pcie_axi_sel], clk[axi]))
+		pr_err("Failed to set PCIe parent clk.\n");
+
+
 	/* gpu clock initilazation */
 	clk_set_parent(clk[gpu3d_shader_sel], clk[pll2_pfd1_594m]);
 	clk_set_rate(clk[gpu3d_shader], 594000000);
Quoted 4 lines

Note: the e1000e network card does work with the FSL imx_3.0.35 kernel

Best Regards
Richard Zhu

#22 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Hi Shawn:

Quoted 15 lines

-----Original Message-----
From: Shawn Guo [mailto:shawn.guo at linaro.org]
Sent: Tuesday, November 26, 2013 12:32 PM
To: Zhu Richard-R65037
Cc: Harro Haan; linux-arm-kernel at lists.infradead.org; Sinan Akman; Marek Va?ut; Pratyush Anand; Tim Harvey; Jingoo Han; Troy Kisky; Sean Cross; Sascha Hauer; Bjorn Helgaas
Subject: Re: [PATCH v6 3/3] PCI: imx6: Add support for i.MX6 PCIe controller

Richard,

Quoted 3 lines · Richard Zhu

[Richard] Regarding to my experience, based on Shawn's(http://git.linaro.org/git-ro/people/shawnguo/linux-2.6.git)
for-next branch, cherry-pick the imx6-pcie patch set merged on host-imx6

Quoted 7 lines

branch on PCIe git-repos.

Since v3.13-rc1 is out there with pci-imx6 driver merged, can you please give it a test to see what's missing there at platform level to get PCIe support on imx6q-sabresd? That will be easy for Harro to follow.

Shawn

[Richard] Ok, no problem, I'm preparing the test, would post the status later.

Quoted 153 lines
Quoted 79 lines

Re-setup the clock configurations refer to your kernel baseline. Here is one example at my local git-repos site, hope it is helpful.
-------------------------------------------------
pcie: switch to upstreamed pcie driver

Based on community patch-set, re-setup pcie driver on imx6 platforms.
* re-fine the pcie clks.
* add the pcie support in dts files.

---
 .../devicetree/bindings/clock/imx6q-clock.txt      |    6 +++---
 arch/arm/boot/dts/imx6qdl-sabreauto.dtsi           |    4 ++++
 arch/arm/boot/dts/imx6qdl-sabresd.dtsi             |    7 +++++++
 arch/arm/boot/dts/imx6qdl.dtsi                     |    4 ++--
 arch/arm/mach-imx/Kconfig                          |    2 ++
 arch/arm/mach-imx/clk-imx6q.c                      |   17 ++++++++++++++++-
 6 files changed, 34 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/clock/imx6q-clock.txt +3 -3
index 02ad157..b289100 100644
@@ -220,9 +220,9 @@ clocks and IDs.
 	ldb_di0_div_sel		207
 	ldb_di1_div_sel		208
 	pll4_audio_div		209
-	pcie_dummy1   		210
-	pcie_dummy2   		211
-	pcie_dummy3   		212
+	lvds1_sel      		210
+	lvds1_in      		211
+	lvds1_out		212
 	caam_mem		213
 	caam_aclk		214
 	caam_ipg		215
arch/arm/boot/dts/imx6qdl-sabreauto.dtsi +4 -0
index bbd4bfb..e011ba7 100644
@@ -590,6 +590,10 @@
 	status = "okay";
 };
 
+&pcie {
+	status = "okay";
+};
+
 &pwm3 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_pwm3_1>;
arch/arm/boot/dts/imx6qdl-sabresd.dtsi +7 -0
index 4de08aa..5236ff6 100644
@@ -611,6 +611,13 @@
 	status = "okay";
 };
 
+&pcie {
+	power-on-gpio = <&gpio3 19 0>;
+	reset-gpio = <&gpio7 12 0>;
+	status = "okay";
+};
+
+
 &pwm1 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_pwm1_1>;
(quoted diff) +0 -0

b/arch/arm/boot/dts/imx6qdl.dtsi index c2f7fd5..1e40164 100644

arch/arm/boot/dts/imx6qdl.dtsi line 128

Quoted 1 line
arch/arm/boot/dts/imx6qdl.dtsi +0 -0
@@ -128,8 +128,8 @@
 				  0x82000000 0 0x01000000 0x01000000 0 0x00f00000>; /*

non-prefetchable memory */

arch/arm/boot/dts/imx6qdl.dtsi

Quoted 4 lines
arch/arm/boot/dts/imx6qdl.dtsi +0 -2
 			num-lanes = <1>;
 			interrupts = <0 123 0x04>;
-			clocks = <&clks 189>, <&clks 187>, <&clks 206>, <&clks 144>;
-			clock-names = "pcie_ref_125m", "sata_ref_100m", "lvds_gate",

"pcie_axi";

Quoted 24 lines
arch/arm/boot/dts/imx6qdl.dtsi +3 -0
+			clocks = <&clks 189>, <&clks 187>, <&clks 144>, <&clks 212>;
+			clock-names = "pcie_ref_125m", "sata_ref_100m", "pcie_axi",
+"lvds_gate";
 			status = "disabled";
 		};
arch/arm/mach-imx/Kconfig +2 -0
index 0633cf9..c26aac0 100644
@@ -809,6 +809,8 @@ config SOC_IMX6Q
 	select HAVE_IMX_SRC
 	select HAVE_SMP
 	select MFD_SYSCON
+	select MIGHT_HAVE_PCI
+	select PCI_DOMAINS if PCI
 	select PINCTRL
 	select PINCTRL_IMX6Q
 	select PL310_ERRATA_588369 if CACHE_PL310 diff --git

a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c index 0923ff8..96e3198 100644

arch/arm/mach-imx/clk-imx6q.c static const char *cko2_sels[] = { · line 73

Quoted 3 lines
arch/arm/mach-imx/clk-imx6q.c +1 -0
@@ -71,6 +71,8 @@ static const char *cko2_sels[] = {
 	"uart_serial", "spdif", "asrc", "hsi_tx",  };  static const char
 *cko_sels[] = { "cko1", "cko2", };
+static const char *lvds_sels[]	= { "arm", "pll1_sys", "dummy", "dummy",

"dummy", "dummy", "dummy", "pll5_video_div",

arch/arm/mach-imx/clk-imx6q.c enum mx6q_clks {

Quoted 10 lines
arch/arm/mach-imx/clk-imx6q.c +2 -0
+				    "dummy", "dummy", "pcie_ref", "sata_ref", "usbphy1",
+"usbphy2", };
 
 enum mx6q_clks {
 	dummy, ckil, ckih, osc, pll2_pfd0_352m, pll2_pfd1_594m,

pll2_pfd2_396m, @@ -107,7 +109,7 @@ enum mx6q_clks {

arch/arm/mach-imx/clk-imx6q.c +0 -1
 	usbphy2_gate, pll4_post_div, pll5_post_div, pll5_video_div, eim_slow,
 	spdif, cko2_sel, cko2_podf, cko2, cko, vdoa, gpt_3m, video_27m,
 	ldb_di0_div_7, ldb_di1_div_7, ldb_di0_div_sel, ldb_di1_div_sel,
-	pll4_audio_div, pcie_dummy1, pcie_dummy2, pcie_dummy3, caam_mem,

caam_aclk,

arch/arm/mach-imx/clk-imx6q.c static void __init imx6q_clocks_init(struct device_node

Quoted 4 lines
arch/arm/mach-imx/clk-imx6q.c +1 -0
+	pll4_audio_div, lvds1_sel, lvds1_in, lvds1_out, caam_mem, caam_aclk,
 	caam_ipg, epit1, epit2, tzasc2, clk_max  };
@@ -173,6 +175,9 @@ static void __init imx6q_clocks_init(struct device_node

*ccm_node)

arch/arm/mach-imx/clk-imx6q.c static void __init imx6q_clocks_init(struct device_node · line 175

Quoted 1 line
arch/arm/mach-imx/clk-imx6q.c +0 -0
 	clk[pll6_enet]     = imx_clk_pllv3(IMX_PLLV3_ENET,	"pll6_enet",	"osc",

base + 0xe0, 0x3, false);

arch/arm/mach-imx/clk-imx6q.c static void __init imx6q_clocks_init(struct device_node · line 176

Quoted 1 line
arch/arm/mach-imx/clk-imx6q.c +0 -0
 	clk[pll7_usb_host] = imx_clk_pllv3(IMX_PLLV3_USB,	"pll7_usb_host",
	"osc", base + 0x20, 0x3, false);

arch/arm/mach-imx/clk-imx6q.c static void __init imx6q_clocks_init(struct device_node · line 177

Quoted 2 lines
arch/arm/mach-imx/clk-imx6q.c +1 -0
+	/*                              name            reg       shift width

parent_names num_parents */

arch/arm/mach-imx/clk-imx6q.c static void __init imx6q_clocks_init(struct device_node · line 178

Quoted 1 line
arch/arm/mach-imx/clk-imx6q.c +1 -0
+	clk[lvds1_sel]    = imx_clk_mux("lvds1_sel",    base + 0x160, 0,  5,

lvds_sels, ARRAY_SIZE(lvds_sels));

arch/arm/mach-imx/clk-imx6q.c static void __init imx6q_clocks_init(struct device_node *ccm_node)

Quoted 9 lines
arch/arm/mach-imx/clk-imx6q.c +1 -0
+
 	/*
 	 * Bit 20 is the reserved and read-only bit, we do this only for:
 	 * - Do nothing for usbphy clk_enable/disable @@ -191,6 +196,9 @@
 static void __init imx6q_clocks_init(struct device_node *ccm_node)
arch/arm/mach-imx/clk-imx6q.c +1 -0
 	clk[sata_ref] = imx_clk_fixed_factor("sata_ref", "pll6_enet", 1, 5);
 	clk[pcie_ref] = imx_clk_fixed_factor("pcie_ref", "pll6_enet", 1, 4);
+	/* NOTICE: The gate of the lvds1 in/out is used to select the clk

direction */

Quoted 4 lines
arch/arm/mach-imx/clk-imx6q.c +3 -0
+	clk[lvds1_in] = imx_clk_gate("lvds1_in", NULL, base + 0x160, 12);
+	clk[lvds1_out] = imx_clk_gate("lvds1_out", "lvds1_sel", base +
+0x160, 10);
Quoted 27 lines
Quoted 1 line

clk[sata_ref_100m] = imx_clk_gate("sata_ref_100m", "sata_ref", base +

0xe0, 20);

Quoted 2 lines

clk[pcie_ref_125m] = imx_clk_gate("pcie_ref_125m", "pcie_ref", base
+ 0xe0, 19); @@ -482,6 +490,13 @@ static void __init

imx6q_clocks_init(struct device_node *ccm_node)

Quoted 22 lines
arch/arm/mach-imx/clk-imx6q.c +7 -0
 	 */
 	clk_set_parent(clk[enfc_sel], clk[pll2_pfd2_396m]);
 
+	/* Set the parent clks of PCIe lvds1 and pcie_axi to be sata ref, axi */
+	if (clk_set_parent(clk[lvds1_sel], clk[sata_ref]))
+		pr_err("Failed to set PCIe bus parent clk.\n");
+	if (clk_set_parent(clk[pcie_axi_sel], clk[axi]))
+		pr_err("Failed to set PCIe parent clk.\n");
+
+
 	/* gpu clock initilazation */
 	clk_set_parent(clk[gpu3d_shader_sel], clk[pll2_pfd1_594m]);
 	clk_set_rate(clk[gpu3d_shader], 594000000);
Quoted 5 lines

Note: the e1000e network card does work with the FSL imx_3.0.35 kernel

Best Regards
Richard Zhu

Best Regards
Richard Zhu

#23 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

In reply to Shawn Guo

Hi Shawn & Harro:

Quoted 25 lines

-----Original Message-----
From: Zhu Richard-R65037
Sent: Tuesday, November 26, 2013 12:36 PM
To: 'Shawn Guo'
Cc: Harro Haan; linux-arm-kernel at lists.infradead.org; Sinan Akman; Marek Va?ut; Pratyush Anand; Tim Harvey; Jingoo Han; Troy Kisky; Sean Cross; Sascha Hauer; Bjorn Helgaas
Subject: RE: [PATCH v6 3/3] PCI: imx6: Add support for i.MX6 PCIe controller

Hi Shawn:

Quoted 13 lines

-----Original Message-----
From: Shawn Guo [mailto:shawn.guo at linaro.org]
Sent: Tuesday, November 26, 2013 12:32 PM
To: Zhu Richard-R65037
Cc: Harro Haan; linux-arm-kernel at lists.infradead.org; Sinan Akman; Marek Va?ut; Pratyush Anand; Tim Harvey; Jingoo Han; Troy Kisky; Sean Cross; Sascha Hauer; Bjorn Helgaas
Subject: Re: [PATCH v6 3/3] PCI: imx6: Add support for i.MX6 PCIe controller

Richard,

On Tue, Nov 26, 2013 at 02:20:15AM +0000, Richard Zhu wrote:

<...>

Quoted 8 lines
Quoted 6 lines

Since v3.13-rc1 is out there with pci-imx6 driver merged, can you please give it a test to see what's missing there at platform level to get PCIe support on imx6q-sabresd? That will be easy for Harro to follow.

Shawn

[Richard] Ok, no problem, I'm preparing the test, would post the status later.

[Richard] Based on the tag " pci-v3.13-fixes-1" on pci git-repos, imx6 pcie had been tested on imx6 sabresd board.

The pcie works after enable pcie support in imx6qdl-sabresd.dtsi file.

Patch:

Author: Richard Zhu <[email protected]>
Date:   Tue Nov 26 13:29:24 2013 +0800

pcie: imx6: enable pcie on imx6qdl sabresd board

Add pcie device tree node into imx6qdl dts file, enable pcie on imx6qdl sabresd board

arch/arm/boot/dts/imx6qdl-sabresd.dtsi +6 -0
index e75e11b..b821f87 100644
@@ -212,6 +212,12 @@
        };
 };
 
+&pcie {
+       power-on-gpio = <&gpio3 19 0>;
+       reset-gpio = <&gpio7 12 0>;
+       status = "okay";
+};
+
 &pwm1 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_pwm0_1>;

LOGs when e1000e nic is used:
uname -a
Linux freescale 3.12.0+ #49 SMP Tue Nov 26 13:26:03 CST 2013 armv7l GNU/Linux root at freescale ~$ lspci -v
00:00.0 PCI bridge: Unknown device 16c3:abcd (rev 01) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0
Memory at 01000000 (32-bit, non-prefetchable) [size=1M]
Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
I/O behind bridge: 00001000-00001fff
Memory behind bridge: 01100000-011fffff
Prefetchable memory behind bridge: 01200000-012fffff
[virtual] Expansion ROM at 01300000 [disabled] [size=64K]
Capabilities: [40] Power Management version 3
Capabilities: [50] Message Signalled Interrupts: Mask+ 64bit+ Queue=0/0 Enable-
Capabilities: [70] Express Root Port (Slot-) IRQ 0
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel

01:00.0 Ethernet controller: Intel Corporation Unknown device 10d3
Subsystem: Intel Corporation Unknown device a01f
Flags: bus master, fast devsel, latency 0, IRQ 155
Memory at 01180000 (32-bit, non-prefetchable) [size=128K]
Memory at 01100000 (32-bit, non-prefetchable) [size=512K]
I/O ports at 1000 [disabled] [size=32]
Memory at 011a0000 (32-bit, non-prefetchable) [size=16K] [virtual] Expansion ROM at 01200000 [disabled] [size=256K]
Capabilities: [c8] Power Management version 2
Capabilities: [d0] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-
Capabilities: [e0] Express Endpoint IRQ 0
Capabilities: [a0] MSI-X: Enable- Mask- TabSize=5
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Device Serial Number 8b-18-3a-ff-ff-21-1b-00

Quoted 1 line
Quoted 1 line

<...>

Quoted 3 lines

Best Regards
Richard Zhu

[Richard]
Best Regards
Richard Zhu

#24 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Quoted 3 lines · Richard Zhu

[Richard] Based on the tag " pci-v3.13-fixes-1" on pci git-repos, imx6 pcie had been tested on imx6 sabresd board.

The pcie works after enable pcie support in imx6qdl-sabresd.dtsi file.

Great, thanks, Richard.

Shawn

Quoted 73 lines

Patch:

Author: Richard Zhu <[email protected]>
Date:   Tue Nov 26 13:29:24 2013 +0800

pcie: imx6: enable pcie on imx6qdl sabresd board

Add pcie device tree node into imx6qdl dts file, enable pcie on imx6qdl sabresd board

arch/arm/boot/dts/imx6qdl-sabresd.dtsi +6 -0
index e75e11b..b821f87 100644
@@ -212,6 +212,12 @@
        };
 };
 
+&pcie {
+       power-on-gpio = <&gpio3 19 0>;
+       reset-gpio = <&gpio7 12 0>;
+       status = "okay";
+};
+
 &pwm1 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_pwm0_1>;

LOGs when e1000e nic is used:
uname -a
Linux freescale 3.12.0+ #49 SMP Tue Nov 26 13:26:03 CST 2013 armv7l GNU/Linux root at freescale ~$ lspci -v
00:00.0 PCI bridge: Unknown device 16c3:abcd (rev 01) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0
Memory at 01000000 (32-bit, non-prefetchable) [size=1M]
Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
I/O behind bridge: 00001000-00001fff
Memory behind bridge: 01100000-011fffff
Prefetchable memory behind bridge: 01200000-012fffff
[virtual] Expansion ROM at 01300000 [disabled] [size=64K]
Capabilities: [40] Power Management version 3
Capabilities: [50] Message Signalled Interrupts: Mask+ 64bit+ Queue=0/0 Enable-
Capabilities: [70] Express Root Port (Slot-) IRQ 0
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel

01:00.0 Ethernet controller: Intel Corporation Unknown device 10d3
Subsystem: Intel Corporation Unknown device a01f
Flags: bus master, fast devsel, latency 0, IRQ 155
Memory at 01180000 (32-bit, non-prefetchable) [size=128K]
Memory at 01100000 (32-bit, non-prefetchable) [size=512K]
I/O ports at 1000 [disabled] [size=32]
Memory at 011a0000 (32-bit, non-prefetchable) [size=16K] [virtual] Expansion ROM at 01200000 [disabled] [size=256K]
Capabilities: [c8] Power Management version 2
Capabilities: [d0] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-
Capabilities: [e0] Express Endpoint IRQ 0
Capabilities: [a0] MSI-X: Enable- Mask- TabSize=5
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Device Serial Number 8b-18-3a-ff-ff-21-1b-00

Quoted 1 line
Quoted 1 line

<...>

Quoted 3 lines

Best Regards
Richard Zhu

[Richard]
Best Regards
Richard Zhu

#25 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Quoted 9 lines · Shawn Guo
Quoted 3 lines · Richard Zhu

[Richard] Based on the tag " pci-v3.13-fixes-1" on pci git-repos, imx6 pcie had been tested on imx6 sabresd board.

The pcie works after enable pcie support in imx6qdl-sabresd.dtsi file.

Great, thanks, Richard.

Shawn

Thanks Richard,

TC1: The following does NOT work with the mainline Linux tree on my SabreSD with PCIe e1000e network card:

$ git reset --hard v3.13-rc1
$ git apply enable_pcie_on_imx6qdl_sabresd_board.patch # patch
supplied by Richard Zhu
result: "phy link never came up"

TC2: But the following does work with the mainline Linux tree:

$ git reset --hard d95d3d53c7ef85ec0dc87db63aece18212c337b0 # HEAD is
now at d95d3d5 Merge branch 'pci/host-imx6' into next (just a few
commits after v3.12-rc2)
$ git cherry-pick 1c4bfb9bd842f09318bc2fa37c1ee0d68bb4e8cb # [master
f283273] PCI: imx6: Remove redundant dev_err() in imx6_pcie_probe()
$ git cherry-pick 01ee0c70b5b935135dbe7fbf48115d9f16348474 # [master
5c93c84] PCI: imx6: Fix imprecise abort handler
$ git cherry-pick 5dcb7c402409f4b1ecb279d5e846bdb1dff9bbe0 # [master
c3cc5c5] PCI: imx6: Increase link startup timeout
$ git cherry-pick 832f3ca20743911508e0cc1909415080a3128532 # [master
b4a81be] PCI: imx6: Remove redundant of_match_ptr
$ git cherry-pick ca6457dc1fbcc1f5ed1f8311e7fcf7ff129cda55 # [master
45aa4ab] PCI: imx6: Probe the PCIe in fs_initcall()
$ git cherry-pick 212555bde33eeae0bec16d41bd4045fbebc0cfab # [master
4db342b] ARM: dts: imx6qdl: add pcie device node
$ git cherry-pick 64990a431469a58b2949aca5be9d69e220d53892 # [master
7c29353] ARM: imx6q: Add pll4_audio_div to clock tree
$ git cherry-pick bf22172158cd6dcc5be6dc286ff5c33794dd0ae8 # [master
5e5852f] ARM: imx: Add LVDS general-purpose clocks to i.MX6Q
$ git cherry-pick 74b8031307c5d33d36742c26dd0921991bd5a255 # [master
05ae48c] ARM: imx6q: clock and Kconfig update for PCIe support
$ git apply enable_pcie_on_imx6qdl_sabresd_board.patch # patch
supplied by Richard Zhu
result: lspci detects network card

I have also tested both test cases (TC1 + TC2) with the patches supplied by Marek Vasut on 26-11-2013:

$ git apply 17_pci_imx6_make_reset-gpio_optional.patch
$ git apply 37_pci_imx6_fix_waiting_for_link_up.patch
$ git apply 47_pci_imx6_split_away_the_phy_reset.patch
$ git apply 57_pci_imx6_split_away_the_link_up_wait_loop.patch
$ git apply 67_pci_imx6_fix_link_start_operation.patch
same results:
TC1: "phy link never came up"
TC2: lspci detects network card

Best regards,

Harro

Quoted 74 lines
Quoted 73 lines

Patch:

Author: Richard Zhu <[email protected]>
Date:   Tue Nov 26 13:29:24 2013 +0800

pcie: imx6: enable pcie on imx6qdl sabresd board

Add pcie device tree node into imx6qdl dts file, enable pcie on imx6qdl sabresd board

arch/arm/boot/dts/imx6qdl-sabresd.dtsi +6 -0
index e75e11b..b821f87 100644
@@ -212,6 +212,12 @@
        };
 };
 
+&pcie {
+       power-on-gpio = <&gpio3 19 0>;
+       reset-gpio = <&gpio7 12 0>;
+       status = "okay";
+};
+
 &pwm1 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_pwm0_1>;

LOGs when e1000e nic is used:
uname -a
Linux freescale 3.12.0+ #49 SMP Tue Nov 26 13:26:03 CST 2013 armv7l GNU/Linux root at freescale ~$ lspci -v
00:00.0 PCI bridge: Unknown device 16c3:abcd (rev 01) (prog-if 00 [Normal decode])
Flags: bus master, fast devsel, latency 0
Memory at 01000000 (32-bit, non-prefetchable) [size=1M]
Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
I/O behind bridge: 00001000-00001fff
Memory behind bridge: 01100000-011fffff
Prefetchable memory behind bridge: 01200000-012fffff
[virtual] Expansion ROM at 01300000 [disabled] [size=64K]
Capabilities: [40] Power Management version 3
Capabilities: [50] Message Signalled Interrupts: Mask+ 64bit+ Queue=0/0 Enable-
Capabilities: [70] Express Root Port (Slot-) IRQ 0
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Virtual Channel

01:00.0 Ethernet controller: Intel Corporation Unknown device 10d3
Subsystem: Intel Corporation Unknown device a01f
Flags: bus master, fast devsel, latency 0, IRQ 155
Memory at 01180000 (32-bit, non-prefetchable) [size=128K]
Memory at 01100000 (32-bit, non-prefetchable) [size=512K]
I/O ports at 1000 [disabled] [size=32]
Memory at 011a0000 (32-bit, non-prefetchable) [size=16K] [virtual] Expansion ROM at 01200000 [disabled] [size=256K]
Capabilities: [c8] Power Management version 2
Capabilities: [d0] Message Signalled Interrupts: Mask- 64bit+ Queue=0/0 Enable-
Capabilities: [e0] Express Endpoint IRQ 0
Capabilities: [a0] MSI-X: Enable- Mask- TabSize=5
Capabilities: [100] Advanced Error Reporting
Capabilities: [140] Device Serial Number 8b-18-3a-ff-ff-21-1b-00

Quoted 1 line
Quoted 1 line

<...>

Quoted 3 lines

Best Regards
Richard Zhu

[Richard]
Best Regards
Richard Zhu

#26 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Hey Harro,

Quoted 48 lines · Shawn Guo
Quoted 9 lines · Richard Zhu
Quoted 4 lines

[Richard] Based on the tag " pci-v3.13-fixes-1" on pci git-repos, imx6 pcie had been tested on imx6 sabresd board.

The pcie works after enable pcie support in imx6qdl-sabresd.dtsi file.

Great, thanks, Richard.

Shawn

Thanks Richard,

TC1: The following does NOT work with the mainline Linux tree on my SabreSD with PCIe e1000e network card:

$ git reset --hard v3.13-rc1
$ git apply enable_pcie_on_imx6qdl_sabresd_board.patch # patch
supplied by Richard Zhu
result: "phy link never came up"

TC2: But the following does work with the mainline Linux tree:

$ git reset --hard d95d3d53c7ef85ec0dc87db63aece18212c337b0 # HEAD is
now at d95d3d5 Merge branch 'pci/host-imx6' into next (just a few
commits after v3.12-rc2)
$ git cherry-pick 1c4bfb9bd842f09318bc2fa37c1ee0d68bb4e8cb # [master
f283273] PCI: imx6: Remove redundant dev_err() in imx6_pcie_probe()
$ git cherry-pick 01ee0c70b5b935135dbe7fbf48115d9f16348474 # [master
5c93c84] PCI: imx6: Fix imprecise abort handler
$ git cherry-pick 5dcb7c402409f4b1ecb279d5e846bdb1dff9bbe0 # [master
c3cc5c5] PCI: imx6: Increase link startup timeout
$ git cherry-pick 832f3ca20743911508e0cc1909415080a3128532 # [master
b4a81be] PCI: imx6: Remove redundant of_match_ptr
$ git cherry-pick ca6457dc1fbcc1f5ed1f8311e7fcf7ff129cda55 # [master
45aa4ab] PCI: imx6: Probe the PCIe in fs_initcall()
$ git cherry-pick 212555bde33eeae0bec16d41bd4045fbebc0cfab # [master
4db342b] ARM: dts: imx6qdl: add pcie device node
$ git cherry-pick 64990a431469a58b2949aca5be9d69e220d53892 # [master
7c29353] ARM: imx6q: Add pll4_audio_div to clock tree
$ git cherry-pick bf22172158cd6dcc5be6dc286ff5c33794dd0ae8 # [master
5e5852f] ARM: imx: Add LVDS general-purpose clocks to i.MX6Q
$ git cherry-pick 74b8031307c5d33d36742c26dd0921991bd5a255 # [master
05ae48c] ARM: imx6q: clock and Kconfig update for PCIe support
$ git apply enable_pcie_on_imx6qdl_sabresd_board.patch # patch
supplied by Richard Zhu
result: lspci detects network card

I have also tested both test cases (TC1 + TC2) with the patches supplied by Marek Vasut on 26-11-2013:

Quoted 8 lines
$ git apply 17_pci_imx6_make_reset-gpio_optional.patch
$ git apply 37_pci_imx6_fix_waiting_for_link_up.patch
$ git apply 47_pci_imx6_split_away_the_phy_reset.patch
$ git apply 57_pci_imx6_split_away_the_link_up_wait_loop.patch
$ git apply 67_pci_imx6_fix_link_start_operation.patch
same results:
TC1: "phy link never came up"
TC2: lspci detects network card

A quick remark: try not to top-post replies in the ML, it's frowned upon.

btw. with my latest patches, do you see the link in Gen=1 or Gen=2 mode ? You will see a line in dmesg, eventually you can try 'dmesg | grep Gen' to find it.

#27 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Quoted 59 lines · Marek Vasut

Hey Harro,

Quoted 48 lines · Shawn Guo
Quoted 9 lines · Richard Zhu
Quoted 4 lines

[Richard] Based on the tag " pci-v3.13-fixes-1" on pci git-repos, imx6 pcie had been tested on imx6 sabresd board.

The pcie works after enable pcie support in imx6qdl-sabresd.dtsi file.

Great, thanks, Richard.

Shawn

Thanks Richard,

TC1: The following does NOT work with the mainline Linux tree on my SabreSD with PCIe e1000e network card:

$ git reset --hard v3.13-rc1
$ git apply enable_pcie_on_imx6qdl_sabresd_board.patch # patch
supplied by Richard Zhu
result: "phy link never came up"

TC2: But the following does work with the mainline Linux tree:

$ git reset --hard d95d3d53c7ef85ec0dc87db63aece18212c337b0 # HEAD is
now at d95d3d5 Merge branch 'pci/host-imx6' into next (just a few
commits after v3.12-rc2)
$ git cherry-pick 1c4bfb9bd842f09318bc2fa37c1ee0d68bb4e8cb # [master
f283273] PCI: imx6: Remove redundant dev_err() in imx6_pcie_probe()
$ git cherry-pick 01ee0c70b5b935135dbe7fbf48115d9f16348474 # [master
5c93c84] PCI: imx6: Fix imprecise abort handler
$ git cherry-pick 5dcb7c402409f4b1ecb279d5e846bdb1dff9bbe0 # [master
c3cc5c5] PCI: imx6: Increase link startup timeout
$ git cherry-pick 832f3ca20743911508e0cc1909415080a3128532 # [master
b4a81be] PCI: imx6: Remove redundant of_match_ptr
$ git cherry-pick ca6457dc1fbcc1f5ed1f8311e7fcf7ff129cda55 # [master
45aa4ab] PCI: imx6: Probe the PCIe in fs_initcall()
$ git cherry-pick 212555bde33eeae0bec16d41bd4045fbebc0cfab # [master
4db342b] ARM: dts: imx6qdl: add pcie device node
$ git cherry-pick 64990a431469a58b2949aca5be9d69e220d53892 # [master
7c29353] ARM: imx6q: Add pll4_audio_div to clock tree
$ git cherry-pick bf22172158cd6dcc5be6dc286ff5c33794dd0ae8 # [master
5e5852f] ARM: imx: Add LVDS general-purpose clocks to i.MX6Q
$ git cherry-pick 74b8031307c5d33d36742c26dd0921991bd5a255 # [master
05ae48c] ARM: imx6q: clock and Kconfig update for PCIe support
$ git apply enable_pcie_on_imx6qdl_sabresd_board.patch # patch
supplied by Richard Zhu
result: lspci detects network card

I have also tested both test cases (TC1 + TC2) with the patches supplied by Marek Vasut on 26-11-2013:

Quoted 8 lines
$ git apply 17_pci_imx6_make_reset-gpio_optional.patch
$ git apply 37_pci_imx6_fix_waiting_for_link_up.patch
$ git apply 47_pci_imx6_split_away_the_phy_reset.patch
$ git apply 57_pci_imx6_split_away_the_link_up_wait_loop.patch
$ git apply 67_pci_imx6_fix_link_start_operation.patch
same results:
TC1: "phy link never came up"
TC2: lspci detects network card
Quoted 4 lines

A quick remark: try not to top-post replies in the ML, it's frowned upon.

btw. with my latest patches, do you see the link in Gen=1 or Gen=2 mode ? You will see a line in dmesg, eventually you can try 'dmesg | grep Gen' to find it.

For the network card:

$ dmesg | grep Gen
imx6q-pcie 1ffc000.pcie: Link up, Gen=1
$ lspci -vvv | grep "LnkSta:"
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive+
BWMgmt- ABWMgmt-

For the Xilinx AC701 board configured with a Gen1 design:

$ dmesg | grep Gen
imx6q-pcie 1ffc000.pcie: Link up, Gen=1
$ lspci -vvv | grep "LnkSta:"
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive+
BWMgmt- ABWMgmt-

For the Xilinx AC701 board configured with a Gen2 design:

$ dmesg | grep Gen
imx6q-pcie 1ffc000.pcie: Link up, Gen=2
$ lspci -vvv | grep "LnkSta:"
LnkSta: Speed 5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive+ BWMgmt- ABWMgmt-

Regards,

Harro

#28 lore raw

PATCH v6 3/3 PCI: imx6: Add support for i.MX6 PCIe controller

Hi,

Quoted 81 lines · Marek Vasut
Quoted 60 lines

Hey Harro,

Quoted 49 lines · Shawn Guo
Quoted 10 lines · Richard Zhu
Quoted 5 lines

[Richard] Based on the tag " pci-v3.13-fixes-1" on pci git-repos, imx6 pcie had been tested on imx6 sabresd board.

The pcie works after enable pcie support in imx6qdl-sabresd.dtsi file.

Great, thanks, Richard.

Shawn

Thanks Richard,

TC1: The following does NOT work with the mainline Linux tree on my SabreSD with PCIe e1000e network card:

$ git reset --hard v3.13-rc1
$ git apply enable_pcie_on_imx6qdl_sabresd_board.patch # patch
supplied by Richard Zhu
result: "phy link never came up"

TC2: But the following does work with the mainline Linux tree:

$ git reset --hard d95d3d53c7ef85ec0dc87db63aece18212c337b0 # HEAD is
now at d95d3d5 Merge branch 'pci/host-imx6' into next (just a few
commits after v3.12-rc2)
$ git cherry-pick 1c4bfb9bd842f09318bc2fa37c1ee0d68bb4e8cb # [master
f283273] PCI: imx6: Remove redundant dev_err() in imx6_pcie_probe()
$ git cherry-pick 01ee0c70b5b935135dbe7fbf48115d9f16348474 # [master
5c93c84] PCI: imx6: Fix imprecise abort handler
$ git cherry-pick 5dcb7c402409f4b1ecb279d5e846bdb1dff9bbe0 # [master
c3cc5c5] PCI: imx6: Increase link startup timeout
$ git cherry-pick 832f3ca20743911508e0cc1909415080a3128532 # [master
b4a81be] PCI: imx6: Remove redundant of_match_ptr
$ git cherry-pick ca6457dc1fbcc1f5ed1f8311e7fcf7ff129cda55 # [master
45aa4ab] PCI: imx6: Probe the PCIe in fs_initcall()
$ git cherry-pick 212555bde33eeae0bec16d41bd4045fbebc0cfab # [master
4db342b] ARM: dts: imx6qdl: add pcie device node
$ git cherry-pick 64990a431469a58b2949aca5be9d69e220d53892 # [master
7c29353] ARM: imx6q: Add pll4_audio_div to clock tree
$ git cherry-pick bf22172158cd6dcc5be6dc286ff5c33794dd0ae8 # [master
5e5852f] ARM: imx: Add LVDS general-purpose clocks to i.MX6Q
$ git cherry-pick 74b8031307c5d33d36742c26dd0921991bd5a255 # [master
05ae48c] ARM: imx6q: clock and Kconfig update for PCIe support
$ git apply enable_pcie_on_imx6qdl_sabresd_board.patch # patch
supplied by Richard Zhu
result: lspci detects network card

I have also tested both test cases (TC1 + TC2) with the patches supplied by Marek Vasut on 26-11-2013:

Quoted 8 lines
$ git apply 17_pci_imx6_make_reset-gpio_optional.patch
$ git apply 37_pci_imx6_fix_waiting_for_link_up.patch
$ git apply 47_pci_imx6_split_away_the_phy_reset.patch
$ git apply 57_pci_imx6_split_away_the_link_up_wait_loop.patch
$ git apply 67_pci_imx6_fix_link_start_operation.patch
same results:
TC1: "phy link never came up"
TC2: lspci detects network card
Quoted 5 lines

A quick remark: try not to top-post replies in the ML, it's frowned upon.

btw. with my latest patches, do you see the link in Gen=1 or Gen=2 mode ? You will see a line in dmesg, eventually you can try 'dmesg | grep Gen' to find it.

For the network card:

$ dmesg | grep Gen
imx6q-pcie 1ffc000.pcie: Link up, Gen=1
$ lspci -vvv | grep "LnkSta:"
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive+
BWMgmt- ABWMgmt-

For the Xilinx AC701 board configured with a Gen1 design:

$ dmesg | grep Gen
imx6q-pcie 1ffc000.pcie: Link up, Gen=1
$ lspci -vvv | grep "LnkSta:"
LnkSta: Speed 2.5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive+
BWMgmt- ABWMgmt-
Quoted 6 lines

For the Xilinx AC701 board configured with a Gen2 design:

$ dmesg | grep Gen
imx6q-pcie 1ffc000.pcie: Link up, Gen=2
$ lspci -vvv | grep "LnkSta:"
LnkSta: Speed 5GT/s, Width x1, TrErr- Train- SlotClk+ DLActive+ BWMgmt-
ABWMgmt-

This makes sense, looks like the Gen2 mode works for you now, thanks! Now I need Richard to verify if my patches make sense too ;-)

#29 lore raw

v6 cover Add PCIe support for i.MX6q

In reply to Sean Cross
Quoted 4 lines · Sean Cross

Sean Cross (3):
ARM: imx: Add LVDS general-purpose clocks to i.MX6Q
ARM: imx6q: Add PCIe bits to GPR syscon definition
PCI: imx6: Add support for i.MX6 PCIe controller

The series looks good to me except that the devm_clk_get() should be used in driver .probe function rather than clk_get(). I will wait for another couple of days. If there is no comments coming up, I can fix it up and apply the series.

Shawn

Quoted 16 lines
 .../devicetree/bindings/clock/imx6q-clock.txt      |    4 +
 .../devicetree/bindings/pci/designware-pcie.txt    |    7 +-
 arch/arm/boot/dts/imx6qdl.dtsi                     |   16 +
 arch/arm/mach-imx/Kconfig                          |    2 +
 arch/arm/mach-imx/clk-imx6q.c                      |   24 +-
 drivers/pci/host/Kconfig                           |    6 +
 drivers/pci/host/Makefile                          |    1 +
 drivers/pci/host/pci-imx6.c                        |  576 ++++++++++++++++++++
 include/linux/mfd/syscon/imx6q-iomuxc-gpr.h        |    8 +
 9 files changed, 642 insertions(+), 2 deletions(-)
 create mode 100644 drivers/pci/host/pci-imx6.c
Signature · 1 line
1.7.9.5