Skip to contentSkip to conversation

pci: Add PCIe Gen4 controller driver for NXP Layerscape SoCs

PATCH Superseded Z.q. Hou 3 participants 19 messages Mar 11, 2019 – Mar 29, 2019

Subsystems (2)

v4 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Z.q. Hou

author
#0 lore raw

v4 cover pci: Add PCIe Gen4 controller driver for NXP Layerscape SoCs

From: Hou Zhiqiang <[email protected]>

Add PCIe Gen4 driver for the NXP Layerscape series SoCs.

Hou Zhiqiang (12):
armv8: fsl-layerscpae: correct the PCIe controllers' region size
armv8: lx2160a: add MMU table entries for PCIe
pci: Add PCIe Gen4 controller driver for NXP Layerscape SoCs
kconfig: add dependency PCIE_LAYERSCAPE_GEN4 for FSL_PCIE_COMPAT
pci: ls_pcie_g4: add device tree fixups for PCI Stream IDs
armv8: lx2160a: add PCIe controller DT nodes
armv8: lx2160a: enable PCIe support
pci: ls_pcie_g4: add Workaround for A-011577
dm: pci: add APIs for capability accessors
dm: pci: add APIs for MPS and MRRS accessors
pci: ls_pcie_g4: Add Workaround for A-011451
pci: ls_pcie_g4: add Workaround for A-011452

 arch/arm/cpu/armv8/fsl-layerscape/Kconfig     |   2 +-
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c       |  12 +
 arch/arm/dts/fsl-lx2160a.dtsi                 |  85 +++
 .../arm/include/asm/arch-fsl-layerscape/cpu.h |   9 +
 .../asm/arch-fsl-layerscape/immap_lsch3.h     |  14 +-
 configs/lx2160aqds_tfa_SECURE_BOOT_defconfig  |   5 +
 configs/lx2160aqds_tfa_defconfig              |   6 +
 configs/lx2160ardb_tfa_SECURE_BOOT_defconfig  |   5 +
 configs/lx2160ardb_tfa_defconfig              |   6 +
 drivers/pci/Kconfig                           |   8 +
 drivers/pci/Makefile                          |   2 +
 drivers/pci/pci-uclass.c                      | 245 ++++++++
 drivers/pci/pci_auto.c                        |  35 ++
 drivers/pci/pcie_layerscape_gen4.c            | 593 ++++++++++++++++++
 drivers/pci/pcie_layerscape_gen4.h            | 273 ++++++++
 drivers/pci/pcie_layerscape_gen4_fixup.c      | 249 ++++++++
 include/pci.h                                 |  33 +
 include/pci_ids.h                             |   1 +
 18 files changed, 1581 insertions(+), 2 deletions(-)
 create mode 100644 drivers/pci/pcie_layerscape_gen4.c
 create mode 100644 drivers/pci/pcie_layerscape_gen4.h
 create mode 100644 drivers/pci/pcie_layerscape_gen4_fixup.c
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v4 1/12 armv8: fsl-layerscpae: correct the PCIe controllers' region size

From: Hou Zhiqiang <[email protected]>

The LS2080A has 8GB region for each PCIe controller, while the other platforms have 32GB.

---
V4:
- No change

 arch/arm/include/asm/arch-fsl-layerscape/cpu.h | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/include/asm/arch-fsl-layerscape/cpu.h +7 -0
index d62754e045..89124cdb0e 100644
@@ -34,10 +34,17 @@
 #define CONFIG_SYS_FSL_QBMAN_BASE	0x818000000
 #define CONFIG_SYS_FSL_QBMAN_SIZE	0x8000000
 #define CONFIG_SYS_FSL_QBMAN_SIZE_1	0x4000000
+#ifdef CONFIG_ARCH_LS2080A
 #define CONFIG_SYS_PCIE1_PHYS_SIZE	0x200000000
 #define CONFIG_SYS_PCIE2_PHYS_SIZE	0x200000000
 #define CONFIG_SYS_PCIE3_PHYS_SIZE	0x200000000
 #define CONFIG_SYS_PCIE4_PHYS_SIZE	0x200000000
+#else
+#define CONFIG_SYS_PCIE1_PHYS_SIZE	0x800000000
+#define CONFIG_SYS_PCIE2_PHYS_SIZE	0x800000000
+#define CONFIG_SYS_PCIE3_PHYS_SIZE	0x800000000
+#define CONFIG_SYS_PCIE4_PHYS_SIZE	0x800000000
+#endif
 #define CONFIG_SYS_FSL_WRIOP1_BASE	0x4300000000
 #define CONFIG_SYS_FSL_WRIOP1_SIZE	0x100000000
 #define CONFIG_SYS_FSL_AIOP1_BASE	0x4b00000000
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v4 2/12 armv8: lx2160a: add MMU table entries for PCIe

In reply to Z.q. Hou

From: Hou Zhiqiang <[email protected]>

The lx2160a have up to 6 PCIe controllers and have different address and size of PCIe region.

---
V4:
- No change

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c            | 12 ++++++++++++
 arch/arm/include/asm/arch-fsl-layerscape/cpu.h     |  2 ++
 .../include/asm/arch-fsl-layerscape/immap_lsch3.h  | 14 +++++++++++++-
 3 files changed, 27 insertions(+), 1 deletion(-)
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +12 -0
index 978d46b32f..2805e5f6f2 100644
@@ -257,6 +257,18 @@ static struct mm_region final_map[] = {
 	  PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
 	  PTE_BLOCK_NON_SHARE | PTE_BLOCK_PXN | PTE_BLOCK_UXN
 	},
+#endif
+#ifdef CONFIG_ARCH_LX2160A
+	{ SYS_PCIE5_PHYS_ADDR, SYS_PCIE5_PHYS_ADDR,
+	  SYS_PCIE5_PHYS_SIZE,
+	  PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+	  PTE_BLOCK_NON_SHARE | PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	},
+	{ SYS_PCIE6_PHYS_ADDR, SYS_PCIE6_PHYS_ADDR,
+	  SYS_PCIE6_PHYS_SIZE,
+	  PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+	  PTE_BLOCK_NON_SHARE | PTE_BLOCK_PXN | PTE_BLOCK_UXN
+	},
 #endif
 	{ CONFIG_SYS_FSL_WRIOP1_BASE, CONFIG_SYS_FSL_WRIOP1_BASE,
 	  CONFIG_SYS_FSL_WRIOP1_SIZE,
arch/arm/include/asm/arch-fsl-layerscape/cpu.h +2 -0
index 89124cdb0e..bdeb62576c 100644
@@ -44,6 +44,8 @@
 #define CONFIG_SYS_PCIE2_PHYS_SIZE	0x800000000
 #define CONFIG_SYS_PCIE3_PHYS_SIZE	0x800000000
 #define CONFIG_SYS_PCIE4_PHYS_SIZE	0x800000000
+#define SYS_PCIE5_PHYS_SIZE		0x800000000
+#define SYS_PCIE6_PHYS_SIZE		0x800000000
 #endif
 #define CONFIG_SYS_FSL_WRIOP1_BASE	0x4300000000
 #define CONFIG_SYS_FSL_WRIOP1_SIZE	0x100000000
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +13 -1
index 9fab88ab2f..c9aa0cad71 100644
@@ -167,7 +167,19 @@
 #define CONFIG_SYS_PCIE2_ADDR			(CONFIG_SYS_IMMR + 0x2500000)
 #define CONFIG_SYS_PCIE3_ADDR			(CONFIG_SYS_IMMR + 0x2600000)
 #define CONFIG_SYS_PCIE4_ADDR			(CONFIG_SYS_IMMR + 0x2700000)
-#ifdef CONFIG_ARCH_LS1088A
+#ifdef CONFIG_ARCH_LX2160A
+#define SYS_PCIE5_ADDR				(CONFIG_SYS_IMMR + 0x2800000)
+#define SYS_PCIE6_ADDR				(CONFIG_SYS_IMMR + 0x2900000)
+#endif
+
+#ifdef CONFIG_ARCH_LX2160A
+#define CONFIG_SYS_PCIE1_PHYS_ADDR		0x8000000000ULL
+#define CONFIG_SYS_PCIE2_PHYS_ADDR		0x8800000000ULL
+#define CONFIG_SYS_PCIE3_PHYS_ADDR		0x9000000000ULL
+#define CONFIG_SYS_PCIE4_PHYS_ADDR		0x9800000000ULL
+#define SYS_PCIE5_PHYS_ADDR			0xa000000000ULL
+#define SYS_PCIE6_PHYS_ADDR			0xa800000000ULL
+#elif CONFIG_ARCH_LS1088A
 #define CONFIG_SYS_PCIE1_PHYS_ADDR		0x2000000000ULL
 #define CONFIG_SYS_PCIE2_PHYS_ADDR		0x2800000000ULL
 #define CONFIG_SYS_PCIE3_PHYS_ADDR		0x3000000000ULL
Signature · 1 line
2.17.1
author
#3 lore raw

PATCH v4 3/12 pci: Add PCIe Gen4 controller driver for NXP Layerscape SoCs

In reply to Z.q. Hou

From: Hou Zhiqiang <[email protected]>

Add PCIe Gen4 driver for the NXP Layerscape SoCs. This PCIe controller is based on the Mobiveil IP, which is compatible with the PCI Expressâ„¢ Base Specification, Revision 4.0.

---
V4:
- No change

 drivers/pci/Kconfig                |   8 +
 drivers/pci/Makefile               |   1 +
 drivers/pci/pcie_layerscape_gen4.c | 577 +++++++++++++++++++++++++++++
 drivers/pci/pcie_layerscape_gen4.h | 264 +++++++++++++
 4 files changed, 850 insertions(+)
 create mode 100644 drivers/pci/pcie_layerscape_gen4.c
 create mode 100644 drivers/pci/pcie_layerscape_gen4.h
drivers/pci/Kconfig +8 -0
index 1521885bde..2638a5a72d 100644
@@ -69,6 +69,14 @@ config PCI_RCAR_GEN2
 	  Renesas RCar Gen2 SoCs. The PCIe controller on RCar Gen2 is
 	  also used to access EHCI USB controller on the SoC.
 
+config PCIE_LAYERSCAPE_GEN4
+	bool "Layerscape Gen4 PCIe support"
+	depends on DM_PCI
+	help
+	  Support PCIe Gen4 on NXP Layerscape SoCs, which may have one or
+	  several PCIe controllers. The PCIe controller can work in RC or
+	  EP mode according to RCW[HOST_AGT_PEX] setting.
+
 config PCI_SANDBOX
 	bool "Sandbox PCI support"
 	depends on SANDBOX && DM_PCI
drivers/pci/Makefile +1 -0
index 4923641895..7f585aad55 100644
@@ -32,5 +32,6 @@ obj-$(CONFIG_PCI_AARDVARK) += pci-aardvark.o
 obj-$(CONFIG_PCIE_DW_MVEBU) += pcie_dw_mvebu.o
 obj-$(CONFIG_PCIE_LAYERSCAPE) += pcie_layerscape.o
 obj-$(CONFIG_PCIE_LAYERSCAPE) += pcie_layerscape_fixup.o
+obj-$(CONFIG_PCIE_LAYERSCAPE_GEN4) += pcie_layerscape_gen4.o
 obj-$(CONFIG_PCI_XILINX) += pcie_xilinx.o
 obj-$(CONFIG_PCIE_INTEL_FPGA) += pcie_intel_fpga.o
drivers/pci/pcie_layerscape_gen4.c new file +577 -0

577 lines not on this page · raw message

drivers/pci/pcie_layerscape_gen4.h new file +264 -0

264 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#4 lore raw

PATCH v4 4/12 kconfig: add dependency PCIE_LAYERSCAPE_GEN4 for FSL_PCIE_COMPAT

In reply to Z.q. Hou

From: Hou Zhiqiang <[email protected]>

The LX2160A PCIe is using driver PCIE_LAYERSCAPE_GEN4 instead of PCIE_LAYERSCAPE.

---
V4:
- No change

 arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/armv8/fsl-layerscape/Kconfig +1 -1
index f48481f465..d37e3678e7 100644
@@ -242,7 +242,7 @@ config FSL_LAYERSCAPE
 
 config FSL_PCIE_COMPAT
 	string "PCIe compatible of Kernel DT"
-	depends on PCIE_LAYERSCAPE
+	depends on PCIE_LAYERSCAPE || PCIE_LAYERSCAPE_GEN4
 	default "fsl,ls1012a-pcie" if ARCH_LS1012A
 	default "fsl,ls1043a-pcie" if ARCH_LS1043A
 	default "fsl,ls1046a-pcie" if ARCH_LS1046A
Signature · 1 line
2.17.1
author
#5 lore raw

PATCH v4 5/12 pci: ls_pcie_g4: add device tree fixups for PCI Stream IDs

In reply to Z.q. Hou

From: Hou Zhiqiang <[email protected]>

Add the infrastructure for Layerscape SoCs PCIe Gen4 controller to update device tree nodes to convey SMMU stream IDs in the device tree.

---
V4:
- No change

 drivers/pci/Makefile                     |   3 +-
 drivers/pci/pcie_layerscape_gen4.c       |   5 -
 drivers/pci/pcie_layerscape_gen4_fixup.c | 249 +++++++++++++++++++++++
 3 files changed, 251 insertions(+), 6 deletions(-)
 create mode 100644 drivers/pci/pcie_layerscape_gen4_fixup.c
drivers/pci/Makefile +2 -1
index 7f585aad55..8ee828af6d 100644
@@ -32,6 +32,7 @@ obj-$(CONFIG_PCI_AARDVARK) += pci-aardvark.o
 obj-$(CONFIG_PCIE_DW_MVEBU) += pcie_dw_mvebu.o
 obj-$(CONFIG_PCIE_LAYERSCAPE) += pcie_layerscape.o
 obj-$(CONFIG_PCIE_LAYERSCAPE) += pcie_layerscape_fixup.o
-obj-$(CONFIG_PCIE_LAYERSCAPE_GEN4) += pcie_layerscape_gen4.o
+obj-$(CONFIG_PCIE_LAYERSCAPE_GEN4) += pcie_layerscape_gen4.o \
+				pcie_layerscape_gen4_fixup.o
 obj-$(CONFIG_PCI_XILINX) += pcie_xilinx.o
 obj-$(CONFIG_PCIE_INTEL_FPGA) += pcie_intel_fpga.o
drivers/pci/pcie_layerscape_gen4.c +0 -5
index fbe7d35911..4e0d5b168e 100644
@@ -570,8 +570,3 @@ U_BOOT_DRIVER(pcie_layerscape_gen4) = {
 	.probe	= ls_pcie_g4_probe,
 	.priv_auto_alloc_size = sizeof(struct ls_pcie_g4),
 };
-
-/* No any fixup so far */
-void ft_pci_setup(void *blob, bd_t *bd)
-{
-}
drivers/pci/pcie_layerscape_gen4_fixup.c new file +249 -0

249 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#6 lore raw

PATCH v4 6/12 armv8: lx2160a: add PCIe controller DT nodes

In reply to Z.q. Hou

From: Hou Zhiqiang <[email protected]>

The LX2160A integrated 6 PCIe Gen4 controllers.

---
V4:
- No change

 arch/arm/dts/fsl-lx2160a.dtsi | 85 +++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)
arch/arm/dts/fsl-lx2160a.dtsi +85 -0
index 510b070582..cac3207985 100644
@@ -176,4 +176,89 @@
 			status = "disabled";
 
 	};
+
+	pcie at 3400000 {
+		compatible = "fsl,lx2160a-pcie";
+		reg = <0x00 0x03400000 0x0 0x80000   /* PAB registers */
+		       0x00 0x03480000 0x0 0x40000   /* LUT registers */
+		       0x00 0x034c0000 0x0 0x40000   /* PF control registers */
+		       0x80 0x00000000 0x0 0x1000>; /* configuration space */
+		reg-names = "ccsr", "lut", "pf_ctrl", "config";
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		bus-range = <0x0 0xff>;
+		ranges = <0x82000000 0x0 0x40000000 0x80 0x40000000 0x0 0x40000000>; /* non-prefetchable memory */
+	};
+
+	pcie at 3500000 {
+		compatible = "fsl,lx2160a-pcie";
+		reg = <0x00 0x03500000 0x0 0x80000   /* PAB registers */
+		       0x00 0x03580000 0x0 0x40000   /* LUT registers */
+		       0x00 0x035c0000 0x0 0x40000   /* PF control registers */
+		       0x88 0x00000000 0x0 0x1000>; /* configuration space */
+		reg-names = "ccsr", "lut", "pf_ctrl", "config";
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		num-lanes = <2>;
+		bus-range = <0x0 0xff>;
+		ranges = <0x82000000 0x0 0x40000000 0x88 0x40000000 0x0 0x40000000>; /* non-prefetchable memory */
+	};
+
+	pcie at 3600000 {
+		compatible = "fsl,lx2160a-pcie";
+		reg = <0x00 0x03600000 0x0 0x80000   /* PAB registers */
+		       0x00 0x03680000 0x0 0x40000   /* LUT registers */
+		       0x00 0x036c0000 0x0 0x40000   /* PF control registers */
+		       0x90 0x00000000 0x0 0x1000>; /* configuration space */
+		reg-names = "ccsr", "lut", "pf_ctrl", "config";
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		bus-range = <0x0 0xff>;
+		ranges = <0x82000000 0x0 0x40000000 0x90 0x40000000 0x0 0x40000000>; /* non-prefetchable memory */
+	};
+
+	pcie at 3700000 {
+		compatible = "fsl,lx2160a-pcie";
+		reg = <0x00 0x03700000 0x0 0x80000   /* PAB registers */
+		       0x00 0x03780000 0x0 0x40000   /* LUT registers */
+		       0x00 0x037c0000 0x0 0x40000   /* PF control registers */
+		       0x98 0x00000000 0x0 0x1000>; /* configuration space */
+		reg-names = "ccsr", "lut", "pf_ctrl", "config";
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		bus-range = <0x0 0xff>;
+		ranges = <0x82000000 0x0 0x40000000 0x98 0x40000000 0x0 0x40000000>; /* non-prefetchable memory */
+	};
+
+	pcie at 3800000 {
+		compatible = "fsl,lx2160a-pcie";
+		reg = <0x00 0x03800000 0x0 0x80000   /* PAB registers */
+		       0x00 0x03880000 0x0 0x40000   /* LUT registers */
+		       0x00 0x038c0000 0x0 0x40000   /* PF control registers */
+		       0xa0 0x00000000 0x0 0x1000>; /* configuration space */
+		reg-names = "ccsr", "lut", "pf_ctrl", "config";
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		bus-range = <0x0 0xff>;
+		ranges = <0x82000000 0x0 0x40000000 0xa0 0x40000000 0x0 0x40000000>; /* non-prefetchable memory */
+	};
+
+	pcie at 3900000 {
+		compatible = "fsl,lx2160a-pcie";
+		reg = <0x00 0x03900000 0x0 0x80000   /* PAB registers */
+		       0x00 0x03980000 0x0 0x40000   /* LUT registers */
+		       0x00 0x039c0000 0x0 0x40000   /* PF control registers */
+		       0xa8 0x00000000 0x0 0x1000>; /* configuration space */
+		reg-names = "ccsr", "lut", "pf_ctrl", "config";
+		#address-cells = <3>;
+		#size-cells = <2>;
+		device_type = "pci";
+		bus-range = <0x0 0xff>;
+		ranges = <0x82000000 0x0 0x40000000 0xa8 0x40000000 0x0 0x40000000>; /* non-prefetchable memory */
+	};
 };
Signature · 1 line
2.17.1
author
#7 lore raw

PATCH v4 7/12 armv8: lx2160a: enable PCIe support

In reply to Z.q. Hou

From: Hou Zhiqiang <[email protected]>

Enable the PCIe Gen4 controller driver and e1000 for LX2160ARDB and LX2160AQDS boards.

---
V4:
- Add PCI command support
- Enable PCIe in more LX2160A defconfigs

 configs/lx2160aqds_tfa_SECURE_BOOT_defconfig | 5 +++++
 configs/lx2160aqds_tfa_defconfig             | 6 ++++++
 configs/lx2160ardb_tfa_SECURE_BOOT_defconfig | 5 +++++
 configs/lx2160ardb_tfa_defconfig             | 6 ++++++
 4 files changed, 22 insertions(+)
configs/lx2160aqds_tfa_SECURE_BOOT_defconfig +5 -0
index 58841053ec..367502da37 100644
@@ -56,3 +56,8 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_CMD_PCI=y
+CONFIG_PCI=y
+CONFIG_DM_PCI=y
+CONFIG_DM_PCI_COMPAT=y
+CONFIG_PCIE_LAYERSCAPE_GEN4=y
configs/lx2160aqds_tfa_defconfig +6 -0
index a0b86ae142..06ef830acd 100644
@@ -51,3 +51,9 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_CMD_PCI=y
+CONFIG_PCI=y
+CONFIG_DM_PCI=y
+CONFIG_DM_PCI_COMPAT=y
+CONFIG_PCIE_LAYERSCAPE_GEN4=y
+CONFIG_E1000=y
configs/lx2160ardb_tfa_SECURE_BOOT_defconfig +5 -0
index f66882d6fa..4e972cc721 100644
@@ -53,3 +53,8 @@ CONFIG_RSA=y
 CONFIG_SPL_RSA=y
 CONFIG_RSA_SOFTWARE_EXP=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_CMD_PCI=y
+CONFIG_PCI=y
+CONFIG_DM_PCI=y
+CONFIG_DM_PCI_COMPAT=y
+CONFIG_PCIE_LAYERSCAPE_GEN4=y
configs/lx2160ardb_tfa_defconfig +6 -0
index 2dc49c7f5d..73b3b91034 100644
@@ -51,3 +51,9 @@ CONFIG_DM_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
+CONFIG_CMD_PCI=y
+CONFIG_PCI=y
+CONFIG_DM_PCI=y
+CONFIG_DM_PCI_COMPAT=y
+CONFIG_PCIE_LAYERSCAPE_GEN4=y
+CONFIG_E1000=y
Signature · 1 line
2.17.1
author
#8 lore raw

PATCH v4 8/12 pci: ls_pcie_g4: add Workaround for A-011577

In reply to Z.q. Hou

From: Hou Zhiqiang <[email protected]>

PCIe configuration access to non-existent function triggered SERROR interrupt exception.

Workaround:
Disable error reporting on AXI bus during the Vendor ID read transactions in enumeration.

This ERRATA is only for LX2160A Rev1.0 and will be fixed in Rev2.0.

---
V4:
- No change

 drivers/pci/pcie_layerscape_gen4.c | 8 ++++++++
 drivers/pci/pcie_layerscape_gen4.h | 5 +++++
 2 files changed, 13 insertions(+)
drivers/pci/pcie_layerscape_gen4.c +8 -0
index 4e0d5b168e..799da2f7df 100644
@@ -242,6 +242,9 @@ static int ls_pcie_g4_read_config(struct udevice *bus, pci_dev_t bdf,
 
 	address = ls_pcie_g4_conf_address(pcie, bdf, offset);
 
+	if (pcie->rev == REV_1_0 && offset == PCI_VENDOR_ID)
+		lut_writel(pcie, 0x0 << PCIE_LUT_GCR_RRE, PCIE_LUT_GCR);
+
 	switch (size) {
 	case PCI_SIZE_8:
 		*valuep = readb(address);
@@ -257,6 +260,9 @@ static int ls_pcie_g4_read_config(struct udevice *bus, pci_dev_t bdf,
 		break;
 	}
 
+	if (pcie->rev == REV_1_0 && offset == PCI_VENDOR_ID)
+		lut_writel(pcie, 0x1 << PCIE_LUT_GCR_RRE, PCIE_LUT_GCR);
+
 	return ret;
 }
 
@@ -518,6 +524,8 @@ static int ls_pcie_g4_probe(struct udevice *dev)
 	      dev->name, (unsigned long)pcie->ccsr, (unsigned long)pcie->cfg,
 	      pcie->big_endian);
 
+	pcie->rev = readb(pcie->ccsr + PCI_REVISION_ID);
+
 	pcie->mode = readb(pcie->ccsr + PCI_HEADER_TYPE) & 0x7f;
 
 	if (pcie->mode == PCI_HEADER_TYPE_NORMAL) {
drivers/pci/pcie_layerscape_gen4.h +5 -0
index 356b49f9ce..137768cae7 100644
@@ -11,6 +11,8 @@
 #include <pci.h>
 #include <dm.h>
 
+#define REV_1_0					(0x10)
+
 #ifndef CONFIG_SYS_PCI_MEMORY_SIZE
 #define CONFIG_SYS_PCI_MEMORY_SIZE		(4 * 1024 * 1024 * 1024ULL)
 #endif
@@ -161,6 +163,8 @@
 #define PCIE_LUT_LDR(n)				(0x804 + (n) * 8)
 #define PCIE_LUT_ENABLE				BIT(31)
 #define PCIE_LUT_ENTRY_COUNT			32
+#define PCIE_LUT_GCR				(0x28)
+#define PCIE_LUT_GCR_RRE			(0)
 
 /* PF control registers */
 #define PCIE_LTSSM_STA				0x7fc
@@ -190,6 +194,7 @@ struct ls_pcie_g4 {
 	int stream_id_cur;
 	int mode;
 	int sriov_support;
+	u8 rev;
 };
 
 extern struct list_head ls_pcie_g4_list;
Signature · 1 line
2.17.1
author
#9 lore raw

PATCH v4 8/12 pci: ls_pcie_g4: add Workaround for A-011577

Hi All,

Please ignore this patch, rev1.0 will not be production.

Thanks,
Zhiqiang

Quoted 99 lines

-----Original Message-----
From: Z.q. Hou
Sent: 2019年3月11日 10:58
To: u-boot at lists.denx.de; bmeng.cn at gmail.com; albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; York Sun <[email protected]>; sriram.dash at nxp.com; yamada.masahiro at socionext.com; Prabhakar Kushwaha <[email protected]>; Mingkai Hu <[email protected]>; M.h. Lian <[email protected]>
Cc: Z.q. Hou <[email protected]>
Subject: [PATCHv4 08/12] pci: ls_pcie_g4: add Workaround for A-011577

From: Hou Zhiqiang <[email protected]>

PCIe configuration access to non-existent function triggered SERROR interrupt exception.

Workaround:
Disable error reporting on AXI bus during the Vendor ID read transactions in enumeration.

This ERRATA is only for LX2160A Rev1.0 and will be fixed in Rev2.0.

---
V4:
- No change

 drivers/pci/pcie_layerscape_gen4.c | 8 ++++++++
drivers/pci/pcie_layerscape_gen4.h | 5 +++++
 2 files changed, 13 insertions(+)
drivers/pci/pcie_layerscape_gen4.c +3 -0
index 4e0d5b168e..799da2f7df 100644
@@ -242,6 +242,9 @@ static int ls_pcie_g4_read_config(struct udevice *bus,
 pci_dev_t bdf,
 
 	address = ls_pcie_g4_conf_address(pcie, bdf, offset);
 
+	if (pcie->rev == REV_1_0 && offset == PCI_VENDOR_ID)
+		lut_writel(pcie, 0x0 << PCIE_LUT_GCR_RRE, PCIE_LUT_GCR);
+
 	switch (size) {
 	case PCI_SIZE_8:
drivers/pci/pcie_layerscape_gen4.c +5 -0
 		*valuep = readb(address);
@@ -257,6 +260,9 @@ static int ls_pcie_g4_read_config(struct udevice *bus,
 pci_dev_t bdf,
 		break;
 	}
 
+	if (pcie->rev == REV_1_0 && offset == PCI_VENDOR_ID)
+		lut_writel(pcie, 0x1 << PCIE_LUT_GCR_RRE, PCIE_LUT_GCR);
+
 	return ret;
 }
@@ -518,6 +524,8 @@ static int ls_pcie_g4_probe(struct udevice *dev)
 	      dev->name, (unsigned long)pcie->ccsr, (unsigned long)pcie->cfg,
 	      pcie->big_endian);
 
+	pcie->rev = readb(pcie->ccsr + PCI_REVISION_ID);
+
 	pcie->mode = readb(pcie->ccsr + PCI_HEADER_TYPE) & 0x7f;
 
 	if (pcie->mode == PCI_HEADER_TYPE_NORMAL) { diff --git

a/drivers/pci/pcie_layerscape_gen4.h b/drivers/pci/pcie_layerscape_gen4.h index 356b49f9ce..137768cae7 100644

drivers/pci/pcie_layerscape_gen4.h +5 -1
@@ -11,6 +11,8 @@
 #include <pci.h>
 #include <dm.h>
 
+#define REV_1_0					(0x10)
+
 #ifndef CONFIG_SYS_PCI_MEMORY_SIZE
 #define CONFIG_SYS_PCI_MEMORY_SIZE		(4 * 1024 * 1024 * 1024ULL)
 #endif
@@ -161,6 +163,8 @@
 #define PCIE_LUT_LDR(n)				(0x804 + (n) * 8)
 #define PCIE_LUT_ENABLE				BIT(31)
 #define PCIE_LUT_ENTRY_COUNT			32
+#define PCIE_LUT_GCR				(0x28)
+#define PCIE_LUT_GCR_RRE			(0)
 
 /* PF control registers */
 #define PCIE_LTSSM_STA				0x7fc
@@ -190,6 +194,7 @@ struct ls_pcie_g4 {
 	int stream_id_cur;
 	int mode;
 	int sriov_support;
+	u8 rev;
 };
 
 extern struct list_head ls_pcie_g4_list;
--

2.17.1

author
#10 lore raw

PATCH v4 9/12 dm: pci: add APIs for capability accessors

In reply to Z.q. Hou

From: Hou Zhiqiang <[email protected]>

This patch introduce a set of PCI/PCIe capability accessors, including 16-bit and 32-bit read, write and clear_and_set operations.

---
V4:
- New patch

 drivers/pci/pci-uclass.c | 153 +++++++++++++++++++++++++++++++++++++++
 include/pci.h            |  20 +++++
 2 files changed, 173 insertions(+)
drivers/pci/pci-uclass.c +153 -0
index 824fa11907..4bb30f5d2b 100644
@@ -1443,6 +1443,159 @@ int dm_pci_find_ext_capability(struct udevice *dev, int cap)
 	return dm_pci_find_next_ext_capability(dev, 0, cap);
 }
 
+/**
+ * dm_pci_capability_read() - PCI capability register read
+ *
+ * @dev:	PCI device to read
+ * @cap:	capability code
+ * @pos:	register offset
+ * @val:	pointer to keep the read value
+ * @size:	register width
+ *
+ * Returns 0 if OK or appropriate error value.
+ */
+int dm_pci_capability_read(struct udevice *dev, int cap, int pos,
+			   ulong *val, enum pci_size_t size)
+{
+	u32 off;
+
+	switch (size) {
+	case PCI_SIZE_16:
+		if (pos & 1)
+			return -EINVAL;
+		break;
+	case PCI_SIZE_32:
+		if (pos & 3)
+			return -EINVAL;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	off = dm_pci_find_capability(dev, cap);
+	if (off)
+		return dm_pci_read_config(dev, off + pos, val, size);
+
+	return -EINVAL;
+}
+
+/**
+ * dm_pci_capability_write() - PCI capability register write
+ *
+ * @dev:	PCI device to write
+ * @cap:	capability code
+ * @pos:	register offset
+ * @val:	value to write
+ * @size:	register width
+ *
+ * Returns 0 if OK or appropriate error value.
+ */
+int dm_pci_capability_write(struct udevice *dev, int cap, int pos,
+			    ulong val, enum pci_size_t size)
+{
+	u32 off;
+
+	switch (size) {
+	case PCI_SIZE_16:
+		if (pos & 1)
+			return -EINVAL;
+		break;
+	case PCI_SIZE_32:
+		if (pos & 3)
+			return -EINVAL;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	off = dm_pci_find_capability(dev, cap);
+	if (off)
+		return dm_pci_write_config(dev, off + pos, val, size);
+
+	return -EINVAL;
+}
+
+int dm_pci_capability_read_word(struct udevice *dev, int cap, int pos, u16 *val)
+{
+	ulong value;
+	int ret;
+
+	ret = dm_pci_capability_read(dev, cap, pos, &value, PCI_SIZE_16);
+	if (ret)
+		return ret;
+	*val = value;
+
+	return 0;
+}
+
+int dm_pci_capability_write_word(struct udevice *dev, int cap, int pos, u16 val)
+{
+	return dm_pci_capability_write(dev, cap, pos, val, PCI_SIZE_16);
+}
+
+int dm_pci_capability_read_dword(struct udevice *dev, int cap,
+				 int pos, u32 *val)
+{
+	ulong value;
+	int ret;
+
+	return dm_pci_capability_read(dev, cap, pos, &value, PCI_SIZE_32);
+	if (ret)
+		return ret;
+	*val = value;
+
+	return 0;
+}
+
+int dm_pci_capability_write_dword(struct udevice *dev, int cap,
+				  int pos, u32 val)
+{
+	return dm_pci_capability_write(dev, cap, pos, val, PCI_SIZE_32);
+}
+
+/**
+ * dm_pci_capability_clear_and_set() - PCI capability register update
+ *
+ * @dev:	PCI device to update
+ * @cap:	capability code
+ * @pos:	register offset
+ * @clear:	bits to clear
+ * @set:	bits to set
+ * @size:	register width
+ *
+ * Returns 0 if OK or appropriate error value.
+ */
+int dm_pci_capability_clear_and_set(struct udevice *dev, int cap, int pos,
+				    ulong clear, ulong set,
+				    enum pci_size_t size)
+{
+	int ret;
+	ulong val;
+
+	ret = dm_pci_capability_read(dev, cap, pos, &val, size);
+	if (!ret) {
+		val &= ~clear;
+		val |= set;
+		ret = dm_pci_capability_write(dev, cap, pos, val, size);
+	}
+
+	return ret;
+}
+
+int dm_pci_capability_clear_and_set_word(struct udevice *dev, int cap,
+					 int pos, u16 clear, u16 set)
+{
+	return dm_pci_capability_clear_and_set(dev, cap, pos, clear,
+					       set, PCI_SIZE_16);
+}
+
+int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap,
+					  int pos, u32 clear, u32 set)
+{
+	return dm_pci_capability_clear_and_set(dev, cap, pos, clear,
+					       set, PCI_SIZE_32);
+}
+
 UCLASS_DRIVER(pci) = {
 	.id		= UCLASS_PCI,
 	.name		= "pci",
include/pci.h +20 -0
index 041f8e3747..d7b6d9f4ff 100644
@@ -1405,6 +1405,26 @@ int dm_pci_find_next_ext_capability(struct udevice *dev, int start, int cap);
  */
 int dm_pci_find_ext_capability(struct udevice *dev, int cap);
 
+int dm_pci_capability_read(struct udevice *dev, int cap, int pos,
+			   ulong *val, enum pci_size_t size);
+int dm_pci_capability_write(struct udevice *dev, int cap, int pos,
+			    ulong val, enum pci_size_t size);
+int dm_pci_capability_read_word(struct udevice *dev, int cap,
+				int pos, u16 *val);
+int dm_pci_capability_write_word(struct udevice *dev, int cap,
+				 int pos, u16 val);
+int dm_pci_capability_read_dword(struct udevice *dev, int cap,
+				 int pos, u32 *val);
+int dm_pci_capability_write_dword(struct udevice *dev, int cap,
+				  int pos, u32 val);
+int dm_pci_capability_clear_and_set(struct udevice *dev, int cap, int pos,
+				    ulong clear, ulong set,
+				    enum pci_size_t size);
+int dm_pci_capability_clear_and_set_word(struct udevice *dev, int cap,
+					 int pos, u16 clear, u16 set);
+int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap,
+					  int pos, u32 clear, u32 set);
+
 #define dm_pci_virt_to_bus(dev, addr, flags) \
 	dm_pci_phys_to_bus(dev, (virt_to_phys(addr)), (flags))
 #define dm_pci_bus_to_virt(dev, addr, flags, len, map_flags) \
Signature · 1 line
2.17.1
author
#11 lore raw

PATCH v4 10/12 dm: pci: add APIs for MPS and MRRS accessors

In reply to Z.q. Hou

From: Hou Zhiqiang <[email protected]>

This patch introduce APIs for getting and updating the MPS and MRRS fields of Device capability Device control register.

---
V4:
- New patch

 drivers/pci/pci-uclass.c | 92 ++++++++++++++++++++++++++++++++++++++++
 include/pci.h            | 13 ++++++
 2 files changed, 105 insertions(+)
drivers/pci/pci-uclass.c +92 -0
index 4bb30f5d2b..b2d295435a 100644
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <dm.h>
 #include <errno.h>
+#include <linux/log2.h>
 #include <pci.h>
 #include <asm/io.h>
 #include <dm/device-internal.h>
@@ -1596,6 +1597,97 @@ int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap,
 					       set, PCI_SIZE_32);
 }
 
+/**
+ * dm_pci_get_readrq - get PCI Express read request size
+ * @dev: PCI device to query
+ *
+ * Returns maximum memory read request in bytes
+ *    or appropriate error value.
+ */
+int dm_pci_get_readrq(struct udevice *dev)
+{
+	u16 ctl;
+	int ret;
+
+	ret = dm_pci_capability_read_word(dev, PCI_CAP_ID_EXP,
+					  PCI_EXP_DEVCTL, &ctl);
+	if (ret)
+		return ret;
+
+	return 128 << ((ctl & PCI_EXP_DEVCTL_READRQ) >> 12);
+}
+
+/**
+ * dm_pci_set_readrq - set PCI Express maximum memory read request
+ * @dev: PCI device to query
+ * @rq: maximum memory read count in bytes
+ *    valid values are 128, 256, 512, 1024, 2048, 4096
+ */
+int dm_pci_set_readrq(struct udevice *dev, int rq)
+{
+	u16 val;
+
+	if (rq < 128 || rq > 4096 || !is_power_of_2(rq))
+		return -EINVAL;
+
+	val = (ffs(rq) - 8) << 12;
+
+	return dm_pci_capability_clear_and_set_word(dev, PCI_CAP_ID_EXP,
+						    PCI_EXP_DEVCTL,
+						    PCI_EXP_DEVCTL_READRQ,
+						    val);
+}
+
+/**
+ * dm_pci_get_mps - get PCI Express maximum payload size
+ * @dev: PCI device to query
+ *
+ * Returns maximum payload size in bytes
+ */
+int dm_pci_get_mps(struct udevice *dev)
+{
+	u16 ctl;
+	int ret;
+
+	ret = dm_pci_capability_read_word(dev, PCI_CAP_ID_EXP,
+					  PCI_EXP_DEVCTL, &ctl);
+	if (ret)
+		return ret;
+
+	return 128 << ((ctl & PCI_EXP_DEVCTL_PAYLOAD) >> 5);
+}
+
+/**
+ * dm_pci_set_mps - set PCI Express maximum payload size
+ * @dev: PCI device to query
+ * @mps: maximum payload size in bytes
+ *    valid values are 128, 256, 512, 1024, 2048, 4096
+ */
+int dm_pci_set_mps(struct udevice *dev, int mps)
+{
+	u16 val, cap;
+	int ret;
+
+	if (mps < 128 || mps > 4096 || !is_power_of_2(mps))
+		return -EINVAL;
+
+	ret = dm_pci_capability_read_word(dev, PCI_CAP_ID_EXP,
+					  PCI_EXP_DEVCAP, &cap);
+	if (ret)
+		return ret;
+
+	val = ffs(mps) - 8;
+	if (val > (cap & PCI_EXP_DEVCAP_PAYLOAD))
+		return -EINVAL;
+
+	val <<= 5;
+
+	return dm_pci_capability_clear_and_set_word(dev, PCI_CAP_ID_EXP,
+						    PCI_EXP_DEVCTL,
+						    PCI_EXP_DEVCTL_PAYLOAD,
+						    val);
+}
+
 UCLASS_DRIVER(pci) = {
 	.id		= UCLASS_PCI,
 	.name		= "pci",
include/pci.h +13 -0
index d7b6d9f4ff..b48df8a363 100644
@@ -414,6 +414,14 @@
 #define PCI_MAX_PCI_DEVICES	32
 #define PCI_MAX_PCI_FUNCTIONS	8
 
+/* PCI Express capability registers */
+#define PCI_EXP_DEVCAP			4	/* Device capabilities */
+#define  PCI_EXP_DEVCAP_PAYLOAD		0x0007	/* Max_Payload_Size */
+
+#define PCI_EXP_DEVCTL			8	/* Device Control */
+#define  PCI_EXP_DEVCTL_PAYLOAD		0x00e0	/* Max_Payload_Size */
+#define  PCI_EXP_DEVCTL_READRQ		0x7000	/* Max_Read_Request_Size */
+
 #define PCI_FIND_CAP_TTL 0x48
 #define CAP_START_POS 0x40
 
@@ -1425,6 +1433,11 @@ int dm_pci_capability_clear_and_set_word(struct udevice *dev, int cap,
 int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap,
 					  int pos, u32 clear, u32 set);
 
+int dm_pci_get_readrq(struct udevice *dev);
+int dm_pci_set_readrq(struct udevice *dev, int rq);
+int dm_pci_get_mps(struct udevice *dev);
+int dm_pci_set_mps(struct udevice *dev, int mps);
+
 #define dm_pci_virt_to_bus(dev, addr, flags) \
 	dm_pci_phys_to_bus(dev, (virt_to_phys(addr)), (flags))
 #define dm_pci_bus_to_virt(dev, addr, flags, len, map_flags) \
Signature · 1 line
2.17.1
author
#12 lore raw

PATCH v4 11/12 pci: ls_pcie_g4: Add Workaround for A-011451

In reply to Z.q. Hou

From: Hou Zhiqiang <[email protected]>

When LAYERSCAPE Gen4 PCIe controller is sending multiple split completions and ACK latency expires indicating that ACK should be send at priority. But because of large number of split completions and FC update DLLP, the controller does not give priority to ACK transmission. This results into ACK latency timer timeout error at the link partner and the pending TLPs are replayed by the link partner again.

Workaround:
1. Reduce the ACK latency timeout value to a very small value.
2. Restrict the number of completions from the PCIe controller to 1, by changing the Max Read Request Size (MRRS) of link partner to the same value as Max Packet size (MPS).

This ERRATA is only for LX2160A Rev1.0 and will be fixed in Rev2.0.

---
V4:
- V3 patch find root port wrongly, fix it in V4.
- Change to use the MPS and MRRS accessors.

 drivers/pci/pci_auto.c             | 35 ++++++++++++++++++++++++++++++
 drivers/pci/pcie_layerscape_gen4.c |  8 +++++++
 drivers/pci/pcie_layerscape_gen4.h |  4 ++++
 include/pci_ids.h                  |  1 +
 4 files changed, 48 insertions(+)
drivers/pci/pci_auto.c +35 -0
index d7237f6eee..611462d1d4 100644
@@ -22,6 +22,8 @@ void dm_pciauto_setup_device(struct udevice *dev, int bars_num,
 			     struct pci_region *prefetch, struct pci_region *io,
 			     bool enum_only)
 {
+	struct udevice *ctrl = pci_get_controller(dev);
+	struct udevice *rp;
 	u32 bar_response;
 	pci_size_t bar_size;
 	u16 cmdstat = 0;
@@ -32,6 +34,8 @@ void dm_pciauto_setup_device(struct udevice *dev, int bars_num,
 	struct pci_region *bar_res = NULL;
 	int found_mem64 = 0;
 	u16 class;
+	u16 vendor, dev_id;
+	u8 rev;
 
 	dm_pci_read_config16(dev, PCI_COMMAND, &cmdstat);
 	cmdstat = (cmdstat & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) |
@@ -161,6 +165,37 @@ void dm_pciauto_setup_device(struct udevice *dev, int bars_num,
 	dm_pci_write_config8(dev, PCI_CACHE_LINE_SIZE,
 			     CONFIG_SYS_PCI_CACHE_LINE_SIZE);
 	dm_pci_write_config8(dev, PCI_LATENCY_TIMER, 0x80);
+
+	/*
+	 * When NXP LAYERSCAPE Gen4 PCIe controller is sending multiple split
+	 * completions and ACK latency expires indicating that ACK should be
+	 * send at priority. But because of large number of split completions
+	 * and FC update DLLP, the controller does not give priority to ACK
+	 * transmission. This results into ACK latency timer timeout error at
+	 * the link partner and the pending TLPs are replayed by the link
+	 * partner again.
+	 *
+	 * The workaround:
+	 * Restrict the number of completions from the PCIe controller to 1,
+	 * by changing the Max Read Request Size (MRRS) of link partner to the
+	 * same value as Max Packet size (MPS).
+	 *
+	 * So, set both the MPS and MRRS to the minimum 128B.
+	 */
+	device_find_first_child(ctrl, &rp);
+	if (!rp) {
+		debug("%s: Host: %s, RP is NULL\n", __func__, ctrl->name);
+		return;
+	}
+
+	dm_pci_read_config16(rp, PCI_VENDOR_ID, &vendor);
+	dm_pci_read_config16(rp, PCI_DEVICE_ID, &dev_id);
+	dm_pci_read_config8(rp, PCI_REVISION_ID, &rev);
+	if (vendor == PCI_VENDOR_ID_FREESCALE &&
+	    dev_id == PCI_DEVICE_ID_LX2160A && rev == 0x10) {
+		dm_pci_set_mps(dev, 128);
+		dm_pci_set_readrq(dev, 128);
+	}
 }
 
 void dm_pciauto_prescan_setup_bridge(struct udevice *dev, int sub_bus)
drivers/pci/pcie_layerscape_gen4.c +8 -0
index 799da2f7df..b530a9979c 100644
@@ -526,6 +526,14 @@ static int ls_pcie_g4_probe(struct udevice *dev)
 
 	pcie->rev = readb(pcie->ccsr + PCI_REVISION_ID);
 
+	/* Set ACK latency timeout */
+	if (pcie->rev == REV_1_0) {
+		val = ccsr_readl(pcie, GPEX_ACK_REPLAY_TO);
+		val &= ~(ACK_LAT_TO_VAL_MASK << ACK_LAT_TO_VAL_SHIFT);
+		val |= (4 << ACK_LAT_TO_VAL_SHIFT);
+		ccsr_writel(pcie, GPEX_ACK_REPLAY_TO, val);
+	}
+
 	pcie->mode = readb(pcie->ccsr + PCI_HEADER_TYPE) & 0x7f;
 
 	if (pcie->mode == PCI_HEADER_TYPE_NORMAL) {
drivers/pci/pcie_layerscape_gen4.h +4 -0
index 137768cae7..ebde52e49a 100644
@@ -58,6 +58,10 @@
 #define INI_VF_SHIFT				0
 #define GPEX_SRIOV_VF_OFFSET_STRIDE(pf)		(0x704 + (pf) * 4)
 
+#define GPEX_ACK_REPLAY_TO			0x438
+#define ACK_LAT_TO_VAL_SHIFT			0
+#define ACK_LAT_TO_VAL_MASK			0x1fff
+
 /* PAB CSR */
 #define PAB_CTRL				0x808
 #define PAB_CTRL_APIO_EN			BIT(0)
include/pci_ids.h +1 -0
index fdda679cc0..92a4339e3e 100644
@@ -2481,6 +2481,7 @@
 #define PCI_DEVICE_ID_MPC8641		0x7010
 #define PCI_DEVICE_ID_MPC8641D		0x7011
 #define PCI_DEVICE_ID_MPC8610		0x7018
+#define PCI_DEVICE_ID_LX2160A		0x8D80
 
 #define PCI_VENDOR_ID_PASEMI		0x1959
 
Signature · 1 line
2.17.1
author
#13 lore raw

PATCH v4 11/12 pci: ls_pcie_g4: Add Workaround for A-011451

Hi All,

Please ignore this patch, rev1.0 will not be production.

Thanks,
Zhiqiang

Quoted 153 lines

-----Original Message-----
From: Z.q. Hou
Sent: 2019年3月11日 10:59
To: u-boot at lists.denx.de; bmeng.cn at gmail.com; albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; York Sun <[email protected]>; sriram.dash at nxp.com; yamada.masahiro at socionext.com; Prabhakar Kushwaha <[email protected]>; Mingkai Hu <[email protected]>; M.h. Lian <[email protected]>
Cc: Z.q. Hou <[email protected]>
Subject: [PATCHv4 11/12] pci: ls_pcie_g4: Add Workaround for A-011451

From: Hou Zhiqiang <[email protected]>

When LAYERSCAPE Gen4 PCIe controller is sending multiple split completions and ACK latency expires indicating that ACK should be send at priority. But because of large number of split completions and FC update DLLP, the controller does not give priority to ACK transmission. This results into ACK latency timer timeout error at the link partner and the pending TLPs are replayed by the link partner again.

Workaround:
1. Reduce the ACK latency timeout value to a very small value.
2. Restrict the number of completions from the PCIe controller to 1, by changing the Max Read Request Size (MRRS) of link partner to the same value as Max Packet size (MPS).

This ERRATA is only for LX2160A Rev1.0 and will be fixed in Rev2.0.

---
V4:
- V3 patch find root port wrongly, fix it in V4.
- Change to use the MPS and MRRS accessors.

 drivers/pci/pci_auto.c             | 35
++++++++++++++++++++++++++++++
 drivers/pci/pcie_layerscape_gen4.c |  8 +++++++
drivers/pci/pcie_layerscape_gen4.h |  4 ++++
 include/pci_ids.h                  |  1 +
 4 files changed, 48 insertions(+)
drivers/pci/pci_auto.c index renamed from drivers/pci/pci_auto.c +0 -0

d7237f6eee..611462d1d4 100644

drivers/pci/pci_auto.c +2 -0
@@ -22,6 +22,8 @@ void dm_pciauto_setup_device(struct udevice *dev, int
 bars_num,
 			     struct pci_region *prefetch, struct pci_region *io,
 			     bool enum_only)
 {
+	struct udevice *ctrl = pci_get_controller(dev);
+	struct udevice *rp;
 	u32 bar_response;
 	pci_size_t bar_size;
drivers/pci/pci_auto.c +2 -0
 	u16 cmdstat = 0;
@@ -32,6 +34,8 @@ void dm_pciauto_setup_device(struct udevice *dev, int
 bars_num,
 	struct pci_region *bar_res = NULL;
 	int found_mem64 = 0;
 	u16 class;
+	u16 vendor, dev_id;
+	u8 rev;
 
 	dm_pci_read_config16(dev, PCI_COMMAND, &cmdstat);

cmdstat = (cmdstat & ~(PCI_COMMAND_IO |
PCI_COMMAND_MEMORY)) | @@ -161,6 +165,37 @@ void dm_pciauto_setup_device(struct udevice *dev, int bars_num,

drivers/pci/pci_auto.c +31 -0
 	dm_pci_write_config8(dev, PCI_CACHE_LINE_SIZE,
 			     CONFIG_SYS_PCI_CACHE_LINE_SIZE);
 	dm_pci_write_config8(dev, PCI_LATENCY_TIMER, 0x80);
+
+	/*
+	 * When NXP LAYERSCAPE Gen4 PCIe controller is sending multiple split
+	 * completions and ACK latency expires indicating that ACK should be
+	 * send at priority. But because of large number of split completions
+	 * and FC update DLLP, the controller does not give priority to ACK
+	 * transmission. This results into ACK latency timer timeout error at
+	 * the link partner and the pending TLPs are replayed by the link
+	 * partner again.
+	 *
+	 * The workaround:
+	 * Restrict the number of completions from the PCIe controller to 1,
+	 * by changing the Max Read Request Size (MRRS) of link partner to the
+	 * same value as Max Packet size (MPS).
+	 *
+	 * So, set both the MPS and MRRS to the minimum 128B.
+	 */
+	device_find_first_child(ctrl, &rp);
+	if (!rp) {
+		debug("%s: Host: %s, RP is NULL\n", __func__, ctrl->name);
+		return;
+	}
+
+	dm_pci_read_config16(rp, PCI_VENDOR_ID, &vendor);
+	dm_pci_read_config16(rp, PCI_DEVICE_ID, &dev_id);
+	dm_pci_read_config8(rp, PCI_REVISION_ID, &rev);
+	if (vendor == PCI_VENDOR_ID_FREESCALE &&
+	    dev_id == PCI_DEVICE_ID_LX2160A && rev == 0x10) {
+		dm_pci_set_mps(dev, 128);
+		dm_pci_set_readrq(dev, 128);
+	}
 }
 
 void dm_pciauto_prescan_setup_bridge(struct udevice *dev, int sub_bus)
drivers/pci/pcie_layerscape_gen4.c +8 -0
index 799da2f7df..b530a9979c 100644
@@ -526,6 +526,14 @@ static int ls_pcie_g4_probe(struct udevice *dev)
 
 	pcie->rev = readb(pcie->ccsr + PCI_REVISION_ID);
 
+	/* Set ACK latency timeout */
+	if (pcie->rev == REV_1_0) {
+		val = ccsr_readl(pcie, GPEX_ACK_REPLAY_TO);
+		val &= ~(ACK_LAT_TO_VAL_MASK << ACK_LAT_TO_VAL_SHIFT);
+		val |= (4 << ACK_LAT_TO_VAL_SHIFT);
+		ccsr_writel(pcie, GPEX_ACK_REPLAY_TO, val);
+	}
+
 	pcie->mode = readb(pcie->ccsr + PCI_HEADER_TYPE) & 0x7f;
 
 	if (pcie->mode == PCI_HEADER_TYPE_NORMAL) { diff --git

a/drivers/pci/pcie_layerscape_gen4.h b/drivers/pci/pcie_layerscape_gen4.h index 137768cae7..ebde52e49a 100644

drivers/pci/pcie_layerscape_gen4.h +4 -0
@@ -58,6 +58,10 @@
 #define INI_VF_SHIFT				0
 #define GPEX_SRIOV_VF_OFFSET_STRIDE(pf)		(0x704 + (pf) * 4)
 
+#define GPEX_ACK_REPLAY_TO			0x438
+#define ACK_LAT_TO_VAL_SHIFT			0
+#define ACK_LAT_TO_VAL_MASK			0x1fff
+
 /* PAB CSR */
 #define PAB_CTRL				0x808
 #define PAB_CTRL_APIO_EN			BIT(0)
include/pci_ids.h index renamed from include/pci_ids.h +0 -0

fdda679cc0..92a4339e3e 100644

include/pci_ids.h +1 -1
@@ -2481,6 +2481,7 @@
 #define PCI_DEVICE_ID_MPC8641		0x7010
 #define PCI_DEVICE_ID_MPC8641D		0x7011
 #define PCI_DEVICE_ID_MPC8610		0x7018
+#define PCI_DEVICE_ID_LX2160A		0x8D80
 
 #define PCI_VENDOR_ID_PASEMI		0x1959
 
--

2.17.1

#14 lore raw

PATCH v4 11/12 pci: ls_pcie_g4: Add Workaround for A-011451

Hi Zhiqiang,

Quoted 5 lines · Z.q. Hou

Hi All,

Please ignore this patch, rev1.0 will not be production.

OK, thanks for the update.

So let's not touch the generic PCI codes this time.

Regards,
Bin

author
#15 lore raw

PATCH v4 12/12 pci: ls_pcie_g4: add Workaround for A-011452

In reply to Z.q. Hou

From: Hou Zhiqiang <[email protected]>

For PCIe controllers with SRIOV, MSIx table entries of all the VFs are not accessible if BAR size is set to less than 8MB.

This ERRATA is only for LX2160A Rev1.0 and will be fixed in Rev2.0.

---
V4:
- No change

 drivers/pci/pcie_layerscape_gen4.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/pci/pcie_layerscape_gen4.c +5 -0
index b530a9979c..3792dbdf55 100644
@@ -378,6 +378,11 @@ static void ls_pcie_g4_ep_set_bar_size(struct ls_pcie_g4 *pcie, int pf,
 	u32 mask_l = lower_32_bits(~(size - 1));
 	u32 mask_h = upper_32_bits(~(size - 1));
 
+	/* A-011452 workaround: set the VF BAR1 to 8MB */
+	if (pcie->rev == REV_1_0 && vf_bar && bar == 1) {
+		mask_l = lower_32_bits(~(SZ_8M - 1));
+		mask_h = upper_32_bits(~(SZ_8M - 1));
+	}
 	ccsr_writel(pcie, GPEX_BAR_SELECT, bar_pos);
 	ccsr_writel(pcie, GPEX_BAR_SIZE_LDW, mask_l);
 	ccsr_writel(pcie, GPEX_BAR_SIZE_UDW, mask_h);
Signature · 1 line
2.17.1
author
#16 lore raw

PATCH v4 12/12 pci: ls_pcie_g4: add Workaround for A-011452

Hi All,

Please ignore this patch, rev1.0 will not be production.

Thanks,
Zhiqiang

Quoted 46 lines

-----Original Message-----
From: Z.q. Hou
Sent: 2019年3月11日 10:59
To: u-boot at lists.denx.de; bmeng.cn at gmail.com; albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; York Sun <[email protected]>; sriram.dash at nxp.com; yamada.masahiro at socionext.com; Prabhakar Kushwaha <[email protected]>; Mingkai Hu <[email protected]>; M.h. Lian <[email protected]>
Cc: Z.q. Hou <[email protected]>
Subject: [PATCHv4 12/12] pci: ls_pcie_g4: add Workaround for A-011452

From: Hou Zhiqiang <[email protected]>

For PCIe controllers with SRIOV, MSIx table entries of all the VFs are not accessible if BAR size is set to less than 8MB.

This ERRATA is only for LX2160A Rev1.0 and will be fixed in Rev2.0.

---
V4:
- No change

 drivers/pci/pcie_layerscape_gen4.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/pci/pcie_layerscape_gen4.c +5 -0
index b530a9979c..3792dbdf55 100644
@@ -378,6 +378,11 @@ static void ls_pcie_g4_ep_set_bar_size(struct
 ls_pcie_g4 *pcie, int pf,
 	u32 mask_l = lower_32_bits(~(size - 1));
 	u32 mask_h = upper_32_bits(~(size - 1));
 
+	/* A-011452 workaround: set the VF BAR1 to 8MB */
+	if (pcie->rev == REV_1_0 && vf_bar && bar == 1) {
+		mask_l = lower_32_bits(~(SZ_8M - 1));
+		mask_h = upper_32_bits(~(SZ_8M - 1));
+	}
 	ccsr_writel(pcie, GPEX_BAR_SELECT, bar_pos);
 	ccsr_writel(pcie, GPEX_BAR_SIZE_LDW, mask_l);

ccsr_writel(pcie, GPEX_BAR_SIZE_UDW, mask_h);
--
2.17.1

#17 lore raw

PATCH v4 12/12 pci: ls_pcie_g4: add Workaround for A-011452

Quoted 11 lines

-----Original Message-----
From: Z.q. Hou
Sent: Wednesday, March 13, 2019 8:25 PM
To: u-boot at lists.denx.de; bmeng.cn at gmail.com; albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; York Sun <[email protected]>; sriram.dash at nxp.com; yamada.masahiro at socionext.com; Prabhakar Kushwaha <[email protected]>; Mingkai Hu <[email protected]>; M.h. Lian <[email protected]>
Subject: RE: [PATCHv4 12/12] pci: ls_pcie_g4: add Workaround for A-011452

Quoted 4 lines

Hi All,

Please ignore this patch, rev1.0 will not be production.

I request you to resend your patch-set with the patches which you want to reviewed and accepted. Please use [RESEND] in subject.

--pk

author
#18 lore raw

PATCH v4 12/12 pci: ls_pcie_g4: add Workaround for A-011452

Hi Prabhakar,

Thanks a lot for your comments!

Quoted 24 lines

-----Original Message-----
From: Prabhakar Kushwaha
Sent: 2019年3月17日 11:28
To: Z.q. Hou <[email protected]>; u-boot at lists.denx.de; bmeng.cn at gmail.com; albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; York Sun <[email protected]>; sriram.dash at nxp.com; yamada.masahiro at socionext.com; Mingkai Hu <[email protected]>; M.h. Lian <[email protected]>
Subject: RE: [PATCHv4 12/12] pci: ls_pcie_g4: add Workaround for A-011452

Quoted 8 lines

-----Original Message-----
From: Z.q. Hou
Sent: Wednesday, March 13, 2019 8:25 PM
To: u-boot at lists.denx.de; bmeng.cn at gmail.com; albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; York Sun <[email protected]>; sriram.dash at nxp.com; yamada.masahiro at socionext.com; Prabhakar Kushwaha <[email protected]>; Mingkai Hu <[email protected]>;

M.h.

Quoted 4 lines

Lian <[email protected]>
Subject: RE: [PATCHv4 12/12] pci: ls_pcie_g4: add Workaround for A-011452

Quoted 8 lines
Quoted 4 lines

Hi All,

Please ignore this patch, rev1.0 will not be production.

I request you to resend your patch-set with the patches which you want to reviewed and accepted.
Please use [RESEND] in subject.

Resent the patch set with the workaround patches removed. Thanks,
Zhiqiang