Skip to contentSkip to conversation

pci: Add PCIe Gen4 controller driver for NXP Layerscape SoCs

PATCH RESEND Superseded Z.q. Hou 3 participants 39 messages Mar 25, 2019 – Apr 8, 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. Resend this patch set with the rev1.0 only workaround patches removed.

Hou Zhiqiang (9):
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
dm: pci: add APIs for capability accessors
dm: pci: add APIs for MPS and MRRS accessors

 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/pcie_layerscape_gen4.c            | 572 ++++++++++++++++++
 drivers/pci/pcie_layerscape_gen4.h            | 264 ++++++++
 drivers/pci/pcie_layerscape_gen4_fixup.c      | 249 ++++++++
 include/pci.h                                 |  33 +
 16 files changed, 1515 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 RESEND v4 1/9 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
#2 lore raw

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

Quoted 6 lines · Z.q. Hou

From: Hou Zhiqiang <[email protected]>

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

Quoted 8 lines

---
V4:
- No change

 arch/arm/include/asm/arch-fsl-layerscape/cpu.h | 7 +++++++
 1 file changed, 7 insertions(+)
author
#3 lore raw

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

Hi Bin,

Quoted 24 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 11:22
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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: [RESEND PATCHv4 1/9] armv8: fsl-layerscpae: correct the PCIe controllers' region size

Quoted 11 lines · Z.q. Hou

From: Hou Zhiqiang <[email protected]>

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

---
V4:
- No change

Quoted 5 lines
Quoted 3 lines
 arch/arm/include/asm/arch-fsl-layerscape/cpu.h | 7 +++++++
 1 file changed, 7 insertions(+)

Thanks a lot for your review!

Zhiqiang

author
#4 lore raw

PATCH RESEND v4 2/9 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
#5 lore raw

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

Quoted 44 lines · 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 +0 -0
index 89124cdb0e..bdeb62576c 100644

arch/arm/include/asm/arch-fsl-layerscape/cpu.h line 48

Quoted 5 lines
arch/arm/include/asm/arch-fsl-layerscape/cpu.h +2 -0
@@ -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

Why are these macros not CONFIG_ prefixed?

Quoted 8 lines
arch/arm/include/asm/arch-fsl-layerscape/cpu.h +0 -0
 #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 +0 -0
index 9fab88ab2f..c9aa0cad71 100644

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h line 172

Quoted 7 lines
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +3 -1
@@ -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)

ditto.

Quoted 4 lines
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +4 -0
+#endif
+
+#ifdef CONFIG_ARCH_LX2160A
+#define CONFIG_SYS_PCIE1_PHYS_ADDR             0x8000000000ULL

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h

Quoted 10 lines
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +6 -1
+#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
--

Regards,
Bin

author
#6 lore raw

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

Hi Bin,

Thanks a lot for your comments!

Quoted 58 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 11:22
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

Quoted 6 lines · 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.

Quoted 6 lines

---
V4:
- No change

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c            | 12

++++++++++++

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = { · line 258

Quoted 13 lines
 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 +0 -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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 7 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +6 -0
        },
+#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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 5 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +5 -0
+       },
+       { 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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 3 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +1 -0
+       },
 #endif
        { CONFIG_SYS_FSL_WRIOP1_BASE,

CONFIG_SYS_FSL_WRIOP1_BASE,

Quoted 14 lines

arch/arm/include/asm/arch-fsl-layerscape/cpu.h line 48

Quoted 12 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +0 -0
          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

Why are these macros not CONFIG_ prefixed?

The new added macros with prefix CONFIG_ will result in build error, so we don't add the CONFIG_ prefix.

Quoted 43 lines

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h line 167

Quoted 11 lines
arch/arm/include/asm/arch-fsl-layerscape/cpu.h +0 -0
 #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 +0 -0
index 9fab88ab2f..c9aa0cad71 100644
@@ -167,7 +167,19 @@
 #define CONFIG_SYS_PCIE2_ADDR

(CONFIG_SYS_IMMR + 0x2500000)

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h line 168

Quoted 1 line
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +0 -0
 #define CONFIG_SYS_PCIE3_ADDR

(CONFIG_SYS_IMMR + 0x2600000)

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h line 169

Quoted 1 line
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +0 -0
 #define CONFIG_SYS_PCIE4_ADDR

(CONFIG_SYS_IMMR + 0x2700000)

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h

Quoted 3 lines
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +2 -1
-#ifdef CONFIG_ARCH_LS1088A
+#ifdef CONFIG_ARCH_LX2160A
+#define SYS_PCIE5_ADDR

(CONFIG_SYS_IMMR + 0x2800000)

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h line 172

Quoted 1 line
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +1 -0
+#define SYS_PCIE6_ADDR

(CONFIG_SYS_IMMR + 0x2900000)

ditto.

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h

Quoted 4 lines
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +4 -0
+#endif
+
+#ifdef CONFIG_ARCH_LX2160A
+#define CONFIG_SYS_PCIE1_PHYS_ADDR

0x8000000000ULL

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h line 177

Quoted 1 line
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +1 -0
+#define CONFIG_SYS_PCIE2_PHYS_ADDR

0x8800000000ULL

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h line 178

Quoted 1 line
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +1 -0
+#define CONFIG_SYS_PCIE3_PHYS_ADDR

0x9000000000ULL

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h line 179

Quoted 1 line
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +1 -0
+#define CONFIG_SYS_PCIE4_PHYS_ADDR

0x9800000000ULL

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h line 180

Quoted 1 line
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +1 -0
+#define SYS_PCIE5_PHYS_ADDR

0xa000000000ULL

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h line 181

Quoted 1 line
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +1 -0
+#define SYS_PCIE6_PHYS_ADDR

0xa800000000ULL

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h line 183

Quoted 2 lines
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +1 -0
+#elif CONFIG_ARCH_LS1088A
 #define CONFIG_SYS_PCIE1_PHYS_ADDR

0x2000000000ULL

Quoted 8 lines

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h line 184

Quoted 1 line
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +0 -0
 #define CONFIG_SYS_PCIE2_PHYS_ADDR

0x2800000000ULL

arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h line 185

Quoted 1 line
arch/arm/include/asm/arch-fsl-layerscape/immap_lsch3.h +0 -0
 #define CONFIG_SYS_PCIE3_PHYS_ADDR

0x3000000000ULL

Quoted 1 line

--

Regards,
Bin

Thanks,
Zhiqiang

#7 lore raw

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

Hi Zhiqiang,

Quoted 78 lines · Z.q. Hou

Hi Bin,

Thanks a lot for your comments!

Quoted 58 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 11:22
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

Quoted 6 lines · 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.

Quoted 6 lines

---
V4:
- No change

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c            | 12

++++++++++++

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = { · line 258

Quoted 13 lines
 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 +0 -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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 7 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +6 -0
        },
+#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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 5 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +5 -0
+       },
+       { 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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 3 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +1 -0
+       },
 #endif
        { CONFIG_SYS_FSL_WRIOP1_BASE,

CONFIG_SYS_FSL_WRIOP1_BASE,

Quoted 14 lines

arch/arm/include/asm/arch-fsl-layerscape/cpu.h line 48

Quoted 12 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +0 -0
          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

Why are these macros not CONFIG_ prefixed?

Quoted 2 lines

The new added macros with prefix CONFIG_ will result in build error, so we don't add the CONFIG_ prefix.

I am curious how can such prefix cause build error?

Regards,
Bin

author
#8 lore raw

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

Hi Bin,

Thanks a lot for your comments!

Quoted 94 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 13:32
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; York Sun <[email protected]>; yamada.masahiro at socionext.com; Prabhakar Kushwaha <[email protected]>; Mingkai Hu <[email protected]>; M.h. Lian <[email protected]>
Subject: Re: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

Hi Zhiqiang,

Quoted 18 lines · Z.q. Hou

Hi Bin,

Thanks a lot for your comments!

Quoted 13 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 11:22
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

On Mon, Mar 25, 2019 at 10:24 AM Z.q. Hou <[email protected]>

Quoted 60 lines · wrote:
Quoted 59 lines
Quoted 6 lines

From: Hou Zhiqiang <[email protected]>

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

Quoted 6 lines

---
V4:
- No change

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c            | 12

++++++++++++

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = { · line 258

Quoted 13 lines
 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 +0 -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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 7 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +6 -0
        },
+#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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 5 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +5 -0
+       },
+       { 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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 3 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +1 -0
+       },
 #endif
        { CONFIG_SYS_FSL_WRIOP1_BASE,

CONFIG_SYS_FSL_WRIOP1_BASE,

arch/arm/include/asm/arch-fsl-layerscape/cpu.h line 48

Quoted 12 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +0 -0
          CONFIG_SYS_FSL_WRIOP1_SIZE, diff --git

a/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
b/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
index 89124cdb0e..bdeb62576c 100644

arch/arm/include/asm/arch-fsl-layerscape/cpu.h +2 -0
@@ -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

Why are these macros not CONFIG_ prefixed?

Quoted 5 lines
Quoted 1 line

The new added macros with prefix CONFIG_ will result in build error, so we

don't add the CONFIG_ prefix.

Quoted 1 line

I am curious how can such prefix cause build error?

It looks like the CFGCHK scripts reports the error as following:
CFGCHK u-boot.cfg
Error: You must add new CONFIG options using Kconfig The following new ad-hoc CONFIG options were detected:
CONFIG_SYS_PCIE5_ADDR

Quoted 3 lines

Regards,
Bin

Thanks,
Zhiqiang

#9 lore raw

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

Quoted 103 lines · Z.q. Hou

Hi Bin,

Thanks a lot for your comments!

Quoted 98 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 13:32
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; York Sun <[email protected]>; yamada.masahiro at socionext.com; Prabhakar Kushwaha <[email protected]>; Mingkai Hu <[email protected]>; M.h. Lian <[email protected]>
Subject: Re: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

Hi Zhiqiang,

Quoted 18 lines · Z.q. Hou

Hi Bin,

Thanks a lot for your comments!

Quoted 13 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 11:22
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

On Mon, Mar 25, 2019 at 10:24 AM Z.q. Hou <[email protected]>

Quoted 60 lines · wrote:
Quoted 45 lines
Quoted 6 lines

From: Hou Zhiqiang <[email protected]>

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

Quoted 6 lines

---
V4:
- No change

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c            | 12

++++++++++++

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = { · line 258

Quoted 13 lines
 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 +0 -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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 7 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +6 -0
        },
+#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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 5 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +5 -0
+       },
+       { 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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 3 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +1 -0
+       },
 #endif
        { CONFIG_SYS_FSL_WRIOP1_BASE,

CONFIG_SYS_FSL_WRIOP1_BASE,

Quoted 14 lines

arch/arm/include/asm/arch-fsl-layerscape/cpu.h line 48

Quoted 12 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +0 -0
          CONFIG_SYS_FSL_WRIOP1_SIZE, diff --git

a/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
b/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
index 89124cdb0e..bdeb62576c 100644

arch/arm/include/asm/arch-fsl-layerscape/cpu.h +2 -0
@@ -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

Why are these macros not CONFIG_ prefixed?

Quoted 1 line

The new added macros with prefix CONFIG_ will result in build error, so we

don't add the CONFIG_ prefix.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

I am curious how can such prefix cause build error?

It looks like the CFGCHK scripts reports the error as following:
CFGCHK u-boot.cfg
Error: You must add new CONFIG options using Kconfig The following new ad-hoc CONFIG options were detected:
CONFIG_SYS_PCIE5_ADDR

If so, I think we need convert other CONFIG_SYS_PCIE* macros to either Kconfig, or remove the CONFIG_ prefix too.

Since it is configurable by the user, not hardcoded by the SoC, it is preferable to be converted to Kconfig. Thanks!

Regards,
Bin

author
#10 lore raw

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

Hi Bin,

Quoted 128 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 17:15
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; York Sun <[email protected]>; yamada.masahiro at socionext.com; Prabhakar Kushwaha <[email protected]>; Mingkai Hu <[email protected]>; M.h. Lian <[email protected]>
Subject: Re: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

Quoted 13 lines · Z.q. Hou

Hi Bin,

Thanks a lot for your comments!

Quoted 8 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 13:32
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; York Sun <[email protected]>; yamada.masahiro at socionext.com; Prabhakar Kushwaha <[email protected]>; Mingkai Hu <[email protected]>;

M.h.

Quoted 7 lines
Quoted 7 lines

Lian <[email protected]>
Subject: Re: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

Hi Zhiqiang,

On Mon, Apr 1, 2019 at 12:08 PM Z.q. Hou <[email protected]>

Quoted 84 lines · wrote:
Quoted 84 lines
Quoted 18 lines

Hi Bin,

Thanks a lot for your comments!

Quoted 13 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 11:22
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

On Mon, Mar 25, 2019 at 10:24 AM Z.q. Hou <[email protected]>

Quoted 60 lines · wrote:
Quoted 45 lines
Quoted 6 lines

From: Hou Zhiqiang <[email protected]>

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

Quoted 6 lines

---
V4:
- No change

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c            | 12

++++++++++++

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = { · line 258

Quoted 13 lines
 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 +0 -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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 7 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +6 -0
        },
+#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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 5 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +5 -0
+       },
+       { 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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = {

Quoted 3 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +1 -0
+       },
 #endif
        { CONFIG_SYS_FSL_WRIOP1_BASE,

CONFIG_SYS_FSL_WRIOP1_BASE,

Quoted 14 lines

arch/arm/include/asm/arch-fsl-layerscape/cpu.h line 48

Quoted 12 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +0 -0
          CONFIG_SYS_FSL_WRIOP1_SIZE, diff --git

a/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
b/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
index 89124cdb0e..bdeb62576c 100644

arch/arm/include/asm/arch-fsl-layerscape/cpu.h +2 -0
@@ -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

Why are these macros not CONFIG_ prefixed?

Quoted 2 lines

The new added macros with prefix CONFIG_ will result in build error, so we

don't add the CONFIG_ prefix.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

I am curious how can such prefix cause build error?

It looks like the CFGCHK scripts reports the error as following:
CFGCHK u-boot.cfg
Error: You must add new CONFIG options using Kconfig The following new ad-hoc CONFIG options were detected:
CONFIG_SYS_PCIE5_ADDR

Quoted 5 lines

If so, I think we need convert other CONFIG_SYS_PCIE* macros to either Kconfig, or remove the CONFIG_ prefix too.

Since it is configurable by the user, not hardcoded by the SoC, it is preferable to be converted to Kconfig. Thanks!

Actually, they are hardcoded by SoC, that's the reason I appended they in the .h file instead Kconfig.

So, I think remove the prefix make more sense, while it is another story, will submit a separate patch to do that, not only for the PCIe related macros.

Quoted 3 lines

Regards,
Bin

Thanks,
Zhiqiang

#11 lore raw

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

Hi Zhiqiang,

Quoted 131 lines · Z.q. Hou

Hi Bin,

Quoted 128 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 17:15
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; York Sun <[email protected]>; yamada.masahiro at socionext.com; Prabhakar Kushwaha <[email protected]>; Mingkai Hu <[email protected]>; M.h. Lian <[email protected]>
Subject: Re: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

Quoted 13 lines · Z.q. Hou

Hi Bin,

Thanks a lot for your comments!

Quoted 8 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 13:32
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; albert.u.boot at aribaud.net; Priyanka Jain <[email protected]>; York Sun <[email protected]>; yamada.masahiro at socionext.com; Prabhakar Kushwaha <[email protected]>; Mingkai Hu <[email protected]>;

M.h.

Quoted 7 lines
Quoted 7 lines

Lian <[email protected]>
Subject: Re: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

Hi Zhiqiang,

On Mon, Apr 1, 2019 at 12:08 PM Z.q. Hou <[email protected]>

Quoted 92 lines · wrote:
Quoted 79 lines
Quoted 18 lines

Hi Bin,

Thanks a lot for your comments!

Quoted 13 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 11:22
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

On Mon, Mar 25, 2019 at 10:24 AM Z.q. Hou <[email protected]>

Quoted 60 lines · wrote:
Quoted 59 lines
Quoted 6 lines

From: Hou Zhiqiang <[email protected]>

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

Quoted 6 lines

---
V4:
- No change

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c            | 12

++++++++++++

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = { · line 258

Quoted 13 lines
 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 +0 -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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = { · line 265

Quoted 7 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +6 -0
        },
+#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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = { · line 270

Quoted 5 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +5 -0
+       },
+       { 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

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = { · line 273

Quoted 3 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +1 -0
+       },
 #endif
        { CONFIG_SYS_FSL_WRIOP1_BASE,

CONFIG_SYS_FSL_WRIOP1_BASE,

arch/arm/include/asm/arch-fsl-layerscape/cpu.h line 48

Quoted 12 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +0 -0
          CONFIG_SYS_FSL_WRIOP1_SIZE, diff --git

a/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
b/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
index 89124cdb0e..bdeb62576c 100644

arch/arm/include/asm/arch-fsl-layerscape/cpu.h +2 -0
@@ -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

Why are these macros not CONFIG_ prefixed?

Quoted 6 lines
Quoted 2 lines

The new added macros with prefix CONFIG_ will result in build error, so we

don't add the CONFIG_ prefix.

Quoted 1 line

I am curious how can such prefix cause build error?

It looks like the CFGCHK scripts reports the error as following:
CFGCHK u-boot.cfg
Error: You must add new CONFIG options using Kconfig The following new ad-hoc CONFIG options were detected:
CONFIG_SYS_PCIE5_ADDR

Quoted 9 lines
Quoted 5 lines

If so, I think we need convert other CONFIG_SYS_PCIE* macros to either Kconfig, or remove the CONFIG_ prefix too.

Since it is configurable by the user, not hardcoded by the SoC, it is preferable to be converted to Kconfig. Thanks!

Actually, they are hardcoded by SoC, that's the reason I appended they in the .h file instead Kconfig.

OK, thanks for the clarification.

Quoted 3 lines

So, I think remove the prefix make more sense, while it is another story, will submit a separate patch to do that, not only for the PCIe related macros.

Sound a good plan to me.

Regards,
Bin

#12 lore raw

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

In reply to Z.q. Hou
Quoted 34 lines

-----Original Message-----
From: Z.q. Hou
Sent: Monday, March 25, 2019 7:54 AM
To: u-boot at lists.denx.de; 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]>; bmeng.cn at gmail.com
Cc: Z.q. Hou <[email protected]>
Subject: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

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 +0 -0
index 978d46b32f..2805e5f6f2 100644

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = { · line 261

Quoted 5 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +2 -0
@@ -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

Request to avoid SoC name in #ifdef. Use #ifdef SYS_PCIE5_PHYS_ADDR,

--pk

author
#13 lore raw

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

Hi Prabhakar,

Thanks a lot for your comments!

Quoted 43 lines

-----Original Message-----
From: Prabhakar Kushwaha
Sent: 2019年4月7日 18:49
To: Z.q. Hou <[email protected]>; u-boot at lists.denx.de; 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]>; bmeng.cn at gmail.com
Subject: RE: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

Quoted 6 lines

-----Original Message-----
From: Z.q. Hou
Sent: Monday, March 25, 2019 7:54 AM
To: u-boot at lists.denx.de; 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

Quoted 1 line

<[email protected]>; Mingkai Hu <[email protected]>;

M.h.

Quoted 10 lines

Lian <[email protected]>; bmeng.cn at gmail.com
Cc: Z.q. Hou <[email protected]>
Subject: [RESEND PATCHv4 2/9] armv8: lx2160a: add MMU table entries for PCIe

From: Hou Zhiqiang <[email protected]>

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

Quoted 6 lines

---
V4:
- No change

 arch/arm/cpu/armv8/fsl-layerscape/cpu.c            | 12

++++++++++++

Quoted 5 lines
 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(-)
Quoted 13 lines

arch/arm/cpu/armv8/fsl-layerscape/cpu.c static struct mm_region final_map[] = { · line 261

Quoted 11 lines
arch/arm/cpu/armv8/fsl-layerscape/cpu.c +2 -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

Request to avoid SoC name in #ifdef. Use #ifdef SYS_PCIE5_PHYS_ADDR,

Yes, will change in next version.

Thanks,
Zhiqiang

author
#14 lore raw

PATCH RESEND v4 3/9 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
#15 lore raw

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

Quoted 26 lines · 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 +0 -0
index 1521885bde..2638a5a72d 100644

drivers/pci/Kconfig config PCI_RCAR_GEN2 · line 72

Quoted 4 lines
drivers/pci/Kconfig +1 -0
@@ -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

nits: should be put in the alphabetical order

drivers/pci/Kconfig config PCI_RCAR_GEN2 · line 82

Quoted 10 lines
drivers/pci/Kconfig +7 -0
+       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

Regards,
Bin

author
#16 lore raw

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

Hi Bin,

Thanks a lot for your comments!

Quoted 44 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 11:22
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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]>; Xiaowei Bao <[email protected]>
Subject: Re: [RESEND PATCHv4 3/9] pci: Add PCIe Gen4 controller driver for NXP Layerscape SoCs

Quoted 30 lines · 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 index renamed from drivers/pci/Kconfig +0 -0

1521885bde..2638a5a72d 100644

drivers/pci/Kconfig +0 -0
@@ -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.
 
Quoted 3 lines

drivers/pci/Kconfig config PCI_RCAR_GEN2 · line 72

Quoted 1 line
drivers/pci/Kconfig +1 -0
+config PCIE_LAYERSCAPE_GEN4

nits: should be put in the alphabetical order

Yes, will fix in v5.

Quoted 6 lines

drivers/pci/Kconfig config PCI_RCAR_GEN2

Quoted 5 lines
drivers/pci/Kconfig +4 -0
+       bool "Layerscape Gen4 PCIe support"
+       depends on DM_PCI
+       help
+         Support PCIe Gen4 on NXP Layerscape SoCs, which may have

one or

Quoted 8 lines

drivers/pci/Kconfig config PCI_RCAR_GEN2 · line 82

Quoted 6 lines
drivers/pci/Kconfig +3 -0
+         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

Thanks for your review!

Regards,
Zhiqiang

author
#17 lore raw

PATCH RESEND v4 4/9 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
#18 lore raw

PATCH RESEND v4 4/9 kconfig: add dependency PCIE_LAYERSCAPE_GEN4 for FSL_PCIE_COMPAT

Quoted 6 lines · Z.q. Hou

From: Hou Zhiqiang <[email protected]>

The LX2160A PCIe is using driver PCIE_LAYERSCAPE_GEN4 instead of PCIE_LAYERSCAPE.

Quoted 8 lines

---
V4:
- No change

 arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
author
#19 lore raw

PATCH RESEND v4 4/9 kconfig: add dependency PCIE_LAYERSCAPE_GEN4 for FSL_PCIE_COMPAT

Hi Bin,

Quoted 24 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 11:22
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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: [RESEND PATCHv4 4/9] kconfig: add dependency PCIE_LAYERSCAPE_GEN4 for FSL_PCIE_COMPAT

Quoted 11 lines · Z.q. Hou

From: Hou Zhiqiang <[email protected]>

The LX2160A PCIe is using driver PCIE_LAYERSCAPE_GEN4 instead of PCIE_LAYERSCAPE.

---
V4:
- No change

Quoted 5 lines
Quoted 3 lines
 arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks for your review!

Regards,
Zhiqiang

author
#20 lore raw

PATCH RESEND v4 5/9 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
#21 lore raw

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

Quoted 60 lines

-----Original Message-----
From: Z.q. Hou
Sent: Monday, March 25, 2019 7:55 AM
To: u-boot at lists.denx.de; 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]>;
bmeng.cn at gmail.com
Cc: Z.q. Hou <[email protected]>
Subject: [RESEND PATCHv4 5/9] pci: ls_pcie_g4: add device tree fixups for PCI Stream IDs

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 index renamed from drivers/pci/Makefile +0 -0

7f585aad55..8ee828af6d 100644

drivers/pci/Makefile +2 -1
@@ -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 diff --git

a/drivers/pci/pcie_layerscape_gen4.c b/drivers/pci/pcie_layerscape_gen4.c index fbe7d35911..4e0d5b168e 100644

drivers/pci/pcie_layerscape_gen4.c +0 -3
@@ -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) -{ -} diff --git

a/drivers/pci/pcie_layerscape_gen4_fixup.c
b/drivers/pci/pcie_layerscape_gen4_fixup.c
new file mode 100644
index 0000000000..ceeea17f19

drivers/pci/pcie_layerscape_gen4_fixup.c line 3

Quoted 3 lines
drivers/pci/pcie_layerscape_gen4_fixup.c new file +3 -0
@@ -0,0 +1,249 @@
+// SPDX-License-Identifier: GPL-2.0+ OR X11
+/*
+ * Copyright 2018 NXP

Copyright should be now 2018-2019

Check for other files also.

author
#22 lore raw

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

Hi Prabhakar,

Thanks a lot for your coments!

Quoted 80 lines

-----Original Message-----
From: Prabhakar Kushwaha
Sent: 2019年4月7日 18:52
To: Z.q. Hou <[email protected]>; u-boot at lists.denx.de; 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]>; bmeng.cn at gmail.com
Subject: RE: [RESEND PATCHv4 5/9] pci: ls_pcie_g4: add device tree fixups for PCI Stream IDs

Quoted 6 lines

-----Original Message-----
From: Z.q. Hou
Sent: Monday, March 25, 2019 7:55 AM
To: u-boot at lists.denx.de; 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

Quoted 1 line

<[email protected]>; Mingkai Hu <[email protected]>;

M.h.

Quoted 53 lines

Lian <[email protected]>; bmeng.cn at gmail.com
Cc: Z.q. Hou <[email protected]>
Subject: [RESEND PATCHv4 5/9] pci: ls_pcie_g4: add device tree fixups for PCI Stream IDs

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 index renamed from drivers/pci/Makefile +0 -0

7f585aad55..8ee828af6d 100644

drivers/pci/Makefile +2 -1
@@ -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 diff --git

a/drivers/pci/pcie_layerscape_gen4.c
b/drivers/pci/pcie_layerscape_gen4.c
index fbe7d35911..4e0d5b168e 100644

drivers/pci/pcie_layerscape_gen4.c +0 -3
@@ -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) -{ -} diff --git

a/drivers/pci/pcie_layerscape_gen4_fixup.c
b/drivers/pci/pcie_layerscape_gen4_fixup.c
new file mode 100644
index 0000000000..ceeea17f19

drivers/pci/pcie_layerscape_gen4_fixup.c line 3

Quoted 3 lines
drivers/pci/pcie_layerscape_gen4_fixup.c new file +3 -0
@@ -0,0 +1,249 @@
+// SPDX-License-Identifier: GPL-2.0+ OR X11
+/*
+ * Copyright 2018 NXP

Copyright should be now 2018-2019

Quoted 1 line

Check for other files also.

OK, will update the Copyright for all files.

Thanks,
Zhiqiang

author
#23 lore raw

PATCH RESEND v4 6/9 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
#25 lore raw

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

Hi Bin,

Quoted 23 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 11:22
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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: [RESEND PATCHv4 6/9] armv8: lx2160a: add PCIe controller DT nodes

Quoted 10 lines · Z.q. Hou

From: Hou Zhiqiang <[email protected]>

The LX2160A integrated 6 PCIe Gen4 controllers.

---
V4:
- No change

Quoted 6 lines
Quoted 1 line
 arch/arm/dts/fsl-lx2160a.dtsi | 85

+++++++++++++++++++++++++++++++++++

Quoted 2 lines
 1 file changed, 85 insertions(+)

Thanks for your review!

Regards,
Zhiqiang

author
#26 lore raw

PATCH RESEND v4 7/9 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
#27 lore raw

PATCH RESEND v4 7/9 armv8: lx2160a: enable PCIe support

Quoted 23 lines · 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 +0 -0
index 58841053ec..367502da37 100644

configs/lx2160aqds_tfa_SECURE_BOOT_defconfig CONFIG_RSA=y · line 62

Quoted 7 lines
configs/lx2160aqds_tfa_SECURE_BOOT_defconfig +4 -0
@@ -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

Since this is a new feature support, can we not depend on CONFIG_DM_PCI_COMPAT?

Quoted 33 lines
configs/lx2160aqds_tfa_SECURE_BOOT_defconfig +1 -0
+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 +0 -0
index 2dc49c7f5d..73b3b91034 100644

configs/lx2160ardb_tfa_defconfig CONFIG_DM_USB=y

Quoted 10 lines
configs/lx2160ardb_tfa_defconfig +6 -1
@@ -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
--

Regards,
Bin

author
#28 lore raw

PATCH RESEND v4 7/9 armv8: lx2160a: enable PCIe support

Hi Bin,

Thanks for your comments!

Quoted 30 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 11:22
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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: [RESEND PATCHv4 7/9] armv8: lx2160a: enable PCIe support

Quoted 18 lines · 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(+)
Quoted 16 lines

configs/lx2160aqds_tfa_SECURE_BOOT_defconfig CONFIG_RSA=y · line 62

Quoted 13 lines
configs/lx2160aqds_tfa_SECURE_BOOT_defconfig +4 -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

Since this is a new feature support, can we not depend on CONFIG_DM_PCI_COMPAT?

Yes, it should not take effect, will remove it in v5.

Quoted 42 lines
Quoted 42 lines
configs/lx2160aqds_tfa_SECURE_BOOT_defconfig +1 -0
+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 +2 -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
Quoted 8 lines

configs/lx2160ardb_tfa_defconfig CONFIG_DM_USB=y

Quoted 5 lines
configs/lx2160ardb_tfa_defconfig +4 -1
+CONFIG_DM_PCI=y
+CONFIG_DM_PCI_COMPAT=y
+CONFIG_PCIE_LAYERSCAPE_GEN4=y
+CONFIG_E1000=y
--

Regards,
Bin

Thanks,
Zhiqiang

#29 lore raw

PATCH RESEND v4 7/9 armv8: lx2160a: enable PCIe support

In reply to Z.q. Hou
Quoted 24 lines

-----Original Message-----
From: Z.q. Hou
Sent: Monday, March 25, 2019 7:55 AM
To: u-boot at lists.denx.de; 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]>; bmeng.cn at gmail.com
Cc: Z.q. Hou <[email protected]>
Subject: [RESEND PATCHv4 7/9] armv8: lx2160a: enable PCIe support

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

Quoted 6 lines
 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(+)

Generate defconfig using make savedefconfig

--pk

author
#30 lore raw

PATCH RESEND v4 7/9 armv8: lx2160a: enable PCIe support

Hi Prabhakar,

Thanks a lot for your comments!

Quoted 43 lines

-----Original Message-----
From: Prabhakar Kushwaha
Sent: 2019年4月7日 18:53
To: Z.q. Hou <[email protected]>; u-boot at lists.denx.de; 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]>; bmeng.cn at gmail.com
Subject: RE: [RESEND PATCHv4 7/9] armv8: lx2160a: enable PCIe support

Quoted 6 lines

-----Original Message-----
From: Z.q. Hou
Sent: Monday, March 25, 2019 7:55 AM
To: u-boot at lists.denx.de; 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

Quoted 1 line

<[email protected]>; Mingkai Hu <[email protected]>;

M.h.

Quoted 15 lines

Lian <[email protected]>; bmeng.cn at gmail.com
Cc: Z.q. Hou <[email protected]>
Subject: [RESEND PATCHv4 7/9] armv8: lx2160a: enable PCIe support

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

Quoted 6 lines
 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(+)
Quoted 1 line

Generate defconfig using make savedefconfig

Yes, will fix in next version.

Thanks,
Zhiqiang

author
#31 lore raw

PATCH RESEND v4 8/9 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
#32 lore raw

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

Quoted 5 lines · 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

No 8-bit accessors?

Quoted 20 lines

operations.

---
V4:
- New patch

 drivers/pci/pci-uclass.c | 153 +++++++++++++++++++++++++++++++++++++++
 include/pci.h            |  20 +++++
 2 files changed, 173 insertions(+)
drivers/pci/pci-uclass.c +1 -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);
 }
 
+/**

drivers/pci/pci-uclass.c int dm_pci_find_ext_capability(struct udevice *dev, int cap) · line 1456

Quoted 10 lines
drivers/pci/pci-uclass.c +10 -0
+ * 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.
+ */

Please move the comment block to pci.h

Quoted 167 lines
drivers/pci/pci-uclass.c +142 -0
+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 +14 -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,

include/pci.h int dm_pci_find_next_ext_capability(struct udevice *dev, int start, int cap);

Quoted 10 lines
include/pci.h +6 -1
+                                   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) \
--

Please also add test cases test/dm/pci.c::dm_test_pci_cap()

Regards,
Bin

author
#33 lore raw

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

Hi Bin,

Thanks a lot for your comments!

Quoted 11 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 11:37
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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: [RESEND PATCHv4 8/9] dm: pci: add APIs for capability accessors

Quoted 8 lines
Quoted 5 lines · 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

No 8-bit accessors?

Is the 8-bit accessors needed? I'm not sure, will check.

Quoted 33 lines
Quoted 9 lines

operations.

---
V4:
- New patch

 drivers/pci/pci-uclass.c | 153

+++++++++++++++++++++++++++++++++++++++

drivers/pci/pci-uclass.c int dm_pci_find_ext_capability(struct udevice

Quoted 8 lines
 include/pci.h            |  20 +++++
 2 files changed, 173 insertions(+)
drivers/pci/pci-uclass.c index renamed from drivers/pci/pci-uclass.c +0 -0

824fa11907..4bb30f5d2b 100644

drivers/pci/pci-uclass.c +0 -0
@@ -1443,6 +1443,159 @@ int dm_pci_find_ext_capability(struct udevice

*dev, int cap)

drivers/pci/pci-uclass.c int dm_pci_find_ext_capability(struct udevice *dev, int cap) · line 1456

Quoted 13 lines
drivers/pci/pci-uclass.c +11 -0
        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.
+ */
Quoted 1 line

Please move the comment block to pci.h

Yes, will fix in v5.

Quoted 171 lines
Quoted 74 lines
drivers/pci/pci-uclass.c +73 -0
+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

drivers/pci/pci-uclass.c int dm_pci_find_ext_capability(struct udevice *dev, int cap)

Quoted 10 lines
drivers/pci/pci-uclass.c +10 -0
+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);

Quoted 32 lines
drivers/pci/pci-uclass.c +32 -0
+       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) {

drivers/pci/pci-uclass.c int dm_pci_find_ext_capability(struct udevice *dev, int cap)

Quoted 10 lines
drivers/pci/pci-uclass.c +10 -0
+               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)

drivers/pci/pci-uclass.c int dm_pci_find_ext_capability(struct udevice *dev, int cap)

Quoted 3 lines
drivers/pci/pci-uclass.c +3 -0
+{
+       return dm_pci_capability_clear_and_set(dev, cap, pos, clear,
+                                              set,

PCI_SIZE_16); }

drivers/pci/pci-uclass.c int dm_pci_find_ext_capability(struct udevice *dev, int cap)

Quoted 3 lines
drivers/pci/pci-uclass.c +3 -0
+
+int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap,
+                                         int pos, u32 clear, u32

set)

drivers/pci/pci-uclass.c int dm_pci_find_ext_capability(struct udevice *dev, int cap)

Quoted 3 lines
drivers/pci/pci-uclass.c +3 -0
+{
+       return dm_pci_capability_clear_and_set(dev, cap, pos, clear,
+                                              set,

PCI_SIZE_32); }

include/pci.h int dm_pci_find_next_ext_capability(struct

Quoted 9 lines
drivers/pci/pci-uclass.c +1 -0
+
 UCLASS_DRIVER(pci) = {
        .id             = UCLASS_PCI,
        .name           = "pci",
include/pci.h index renamed from include/pci.h +0 -0

041f8e3747..d7b6d9f4ff 100644

include/pci.h +0 -0
@@ -1405,6 +1405,26 @@ int dm_pci_find_next_ext_capability(struct

udevice *dev, int start, int cap);

Quoted 10 lines
include/pci.h +7 -0
  */
 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,

include/pci.h int dm_pci_find_next_ext_capability(struct · line 1424

Quoted 10 lines
include/pci.h +10 -0
+                                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);

Quoted 10 lines
Quoted 8 lines
include/pci.h +4 -0
+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) \
--

Please also add test cases test/dm/pci.c::dm_test_pci_cap()

Yes, will add.

Quoted 3 lines

Regards,
Bin

Thanks,
Zhiqiang

author
#34 lore raw

PATCH RESEND v4 9/9 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
#35 lore raw

PATCH RESEND v4 9/9 dm: pci: add APIs for MPS and MRRS accessors

Quoted 28 lines · 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 +1 -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>

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap, · line 1606

Quoted 10 lines
drivers/pci/pci-uclass.c +7 -0
@@ -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.
+ */

Please move the comment block to pci.h

Quoted 109 lines
drivers/pci/pci-uclass.c +84 -0
+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 +8 -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);

include/pci.h int dm_pci_capability_clear_and_set_word(struct udevice *dev, int cap,

Quoted 10 lines
include/pci.h +5 -1
 
+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) \
--

Please add test cases test/dm/pci.c::dm_test_pci_cap()

Regards,
Bin

#36 lore raw

PATCH RESEND v4 9/9 dm: pci: add APIs for MPS and MRRS accessors

Quoted 153 lines · Bin Meng
Quoted 28 lines · 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 +1 -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>

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap, · line 1606

Quoted 10 lines
drivers/pci/pci-uclass.c +7 -0
@@ -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.
+ */

Please move the comment block to pci.h

Quoted 110 lines
drivers/pci/pci-uclass.c +84 -0
+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 +8 -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);
 
Quoted 11 lines

include/pci.h int dm_pci_capability_clear_and_set_word(struct udevice *dev, int cap,

Quoted 9 lines
include/pci.h +5 -1
+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) \
--

Please add test cases test/dm/pci.c::dm_test_pci_cap()

Zhiqiang, when you do new version patches, please split patch [8,9] to a separate series, since it is not tightly coupled with other 7 patches, and can go separately.

Regards,
Bin

author
#37 lore raw

PATCH RESEND v4 9/9 dm: pci: add APIs for MPS and MRRS accessors

Hi Bin,

Thanks a lot for your comments!

Quoted 189 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 15:32
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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: [RESEND PATCHv4 9/9] dm: pci: add APIs for MPS and MRRS accessors

Quoted 2 lines · Bin Meng

On Mon, Mar 25, 2019 at 10:24 AM Z.q. Hou <[email protected]>

Quoted 6 lines · wrote:
Quoted 6 lines

From: Hou Zhiqiang <[email protected]>

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

Quoted 6 lines
Quoted 6 lines

---
V4:
- New patch

 drivers/pci/pci-uclass.c | 92

++++++++++++++++++++++++++++++++++++++++

Quoted 16 lines

drivers/pci/pci-uclass.c int

Quoted 16 lines
 include/pci.h            | 13 ++++++
 2 files changed, 105 insertions(+)
drivers/pci/pci-uclass.c +1 -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,

Quoted 1 line

drivers/pci/pci-uclass.c int · line 1597

Quoted 1 line
drivers/pci/pci-uclass.c +0 -0
                                               set,

PCI_SIZE_32); }

Quoted 9 lines

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap, · line 1606

Quoted 8 lines
drivers/pci/pci-uclass.c +7 -0
+/**
+ * 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.
+ */
Quoted 8 lines

Please move the comment block to pci.h

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap, · line 1636

Quoted 6 lines
drivers/pci/pci-uclass.c +6 -0
+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);

Quoted 12 lines
Quoted 12 lines
drivers/pci/pci-uclass.c +12 -0
+       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) {
Quoted 8 lines

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap,

Quoted 8 lines
drivers/pci/pci-uclass.c +8 -0
+       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,

Quoted 1 line

drivers/pci/pci-uclass.c int · line 1631

Quoted 1 line
drivers/pci/pci-uclass.c +1 -0
+

PCI_EXP_DEVCTL,

Quoted 1 line

drivers/pci/pci-uclass.c int · line 1632

Quoted 1 line
drivers/pci/pci-uclass.c +1 -0
+

PCI_EXP_DEVCTL_READRQ,

Quoted 5 lines
Quoted 5 lines
drivers/pci/pci-uclass.c +5 -0
+                                                   val); }
+
+/**
+ * dm_pci_get_mps - get PCI Express maximum payload size
+ * @dev: PCI device to query
Quoted 8 lines

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap, · line 1636

Quoted 8 lines
drivers/pci/pci-uclass.c +8 -0
+ *
+ * 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);

Quoted 12 lines
Quoted 12 lines
drivers/pci/pci-uclass.c +12 -0
+       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) {
Quoted 8 lines

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap,

Quoted 8 lines
drivers/pci/pci-uclass.c +8 -0
+       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);

Quoted 10 lines

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap,

Quoted 10 lines
drivers/pci/pci-uclass.c +10 -0
+       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,

Quoted 1 line

drivers/pci/pci-uclass.c int · line 1676

Quoted 1 line
drivers/pci/pci-uclass.c +1 -0
+

PCI_EXP_DEVCTL,

Quoted 1 line

drivers/pci/pci-uclass.c int · line 1677

Quoted 1 line
drivers/pci/pci-uclass.c +1 -0
+

PCI_EXP_DEVCTL_PAYLOAD,

Quoted 13 lines
Quoted 13 lines
drivers/pci/pci-uclass.c +2 -0
+                                                   val); }
+
 UCLASS_DRIVER(pci) = {
        .id             = UCLASS_PCI,
        .name           = "pci",
include/pci.h index renamed from include/pci.h +0 -0

d7b6d9f4ff..b48df8a363 100644

include/pci.h +0 -0
@@ -414,6 +414,14 @@
 #define PCI_MAX_PCI_DEVICES    32
 #define PCI_MAX_PCI_FUNCTIONS  8
 
Quoted 2 lines

include/pci.h line 418

Quoted 2 lines
include/pci.h +2 -0
+/* PCI Express capability registers */
+#define PCI_EXP_DEVCAP                 4       /* Device

capabilities */

Quoted 1 line

include/pci.h line 419

Quoted 1 line
include/pci.h +1 -0
+#define  PCI_EXP_DEVCAP_PAYLOAD                0x0007  /*

Max_Payload_Size */

Quoted 2 lines

include/pci.h line 421

Quoted 2 lines
include/pci.h +2 -0
+
+#define PCI_EXP_DEVCTL                 8       /* Device

Control */

Quoted 1 line

include/pci.h line 422

Quoted 1 line
include/pci.h +1 -0
+#define  PCI_EXP_DEVCTL_PAYLOAD                0x00e0  /*

Max_Payload_Size */

Quoted 1 line

include/pci.h line 423

Quoted 1 line
include/pci.h +1 -0
+#define  PCI_EXP_DEVCTL_READRQ         0x7000  /*

Max_Read_Request_Size */

Quoted 6 lines
Quoted 6 lines
include/pci.h +1 -0
+
 #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,

Quoted 1 line
Quoted 1 line

int pos, u32 clear,

u32

Quoted 13 lines
Quoted 11 lines

set);

include/pci.h +5 -0
+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) \
--

Please add test cases test/dm/pci.c::dm_test_pci_cap()

Quoted 3 lines

Zhiqiang, when you do new version patches, please split patch [8,9] to a separate series, since it is not tightly coupled with other 7 patches, and can go separately.

Ok, make sense.

Quoted 3 lines

Regards,
Bin

Thanks,
Zhiqiang

author
#38 lore raw

PATCH RESEND v4 9/9 dm: pci: add APIs for MPS and MRRS accessors

In reply to Bin Meng

Hi Bin,

Thanks a lot for your comments!

Quoted 54 lines

-----Original Message-----
From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: 2019年4月1日 14:00
To: Z.q. Hou <[email protected]>
Cc: u-boot at lists.denx.de; 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: [RESEND PATCHv4 9/9] dm: pci: add APIs for MPS and MRRS accessors

Quoted 6 lines · 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.

Quoted 6 lines

---
V4:
- New patch

 drivers/pci/pci-uclass.c | 92

++++++++++++++++++++++++++++++++++++++++

drivers/pci/pci-uclass.c int

Quoted 16 lines
 include/pci.h            | 13 ++++++
 2 files changed, 105 insertions(+)
drivers/pci/pci-uclass.c index renamed from drivers/pci/pci-uclass.c +0 -0

4bb30f5d2b..b2d295435a 100644

drivers/pci/pci-uclass.c +1 -0
@@ -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,

drivers/pci/pci-uclass.c int · line 1597

Quoted 1 line
drivers/pci/pci-uclass.c +0 -0
                                               set,

PCI_SIZE_32); }

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap, · line 1606

Quoted 8 lines
drivers/pci/pci-uclass.c +7 -0
+/**
+ * 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.
+ */
Quoted 1 line

Please move the comment block to pci.h

Yes, will fix in v5.

Quoted 119 lines

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap, · line 1636

Quoted 7 lines
drivers/pci/pci-uclass.c +6 -0
+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);

Quoted 10 lines
drivers/pci/pci-uclass.c +10 -0
+       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

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap,

Quoted 10 lines
drivers/pci/pci-uclass.c +10 -0
+ */
+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,

drivers/pci/pci-uclass.c int · line 1631

Quoted 1 line
drivers/pci/pci-uclass.c +1 -0
+

PCI_EXP_DEVCTL,

drivers/pci/pci-uclass.c int · line 1632

Quoted 1 line
drivers/pci/pci-uclass.c +1 -0
+

PCI_EXP_DEVCTL_READRQ,

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap, · line 1686

Quoted 13 lines
drivers/pci/pci-uclass.c +13 -0
+                                                   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);

Quoted 10 lines
drivers/pci/pci-uclass.c +10 -0
+       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

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap,

Quoted 10 lines
drivers/pci/pci-uclass.c +10 -0
+ */
+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);

drivers/pci/pci-uclass.c int dm_pci_capability_clear_and_set_dword(struct udevice *dev, int cap,

Quoted 10 lines
drivers/pci/pci-uclass.c +10 -0
+       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,

drivers/pci/pci-uclass.c int · line 1676

Quoted 1 line
drivers/pci/pci-uclass.c +1 -0
+

PCI_EXP_DEVCTL,

drivers/pci/pci-uclass.c int · line 1677

Quoted 1 line
drivers/pci/pci-uclass.c +1 -0
+

PCI_EXP_DEVCTL_PAYLOAD,

Quoted 10 lines
drivers/pci/pci-uclass.c +2 -0
+                                                   val); }
+
 UCLASS_DRIVER(pci) = {
        .id             = UCLASS_PCI,
        .name           = "pci",
include/pci.h index renamed from include/pci.h +0 -0

d7b6d9f4ff..b48df8a363 100644

include/pci.h line 418

Quoted 5 lines
include/pci.h +2 -0
@@ -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 */

include/pci.h line 419

Quoted 1 line
include/pci.h +1 -0
+#define  PCI_EXP_DEVCAP_PAYLOAD                0x0007  /*

Max_Payload_Size */

include/pci.h line 421

Quoted 2 lines
include/pci.h +2 -0
+
+#define PCI_EXP_DEVCTL                 8       /* Device Control

*/

include/pci.h line 422

Quoted 1 line
include/pci.h +1 -0
+#define  PCI_EXP_DEVCTL_PAYLOAD                0x00e0  /*

Max_Payload_Size */

include/pci.h line 423

Quoted 1 line
include/pci.h +1 -0
+#define  PCI_EXP_DEVCTL_READRQ         0x7000  /*

Max_Read_Request_Size */

include/pci.h int

Quoted 5 lines
include/pci.h +1 -0
+
 #define PCI_FIND_CAP_TTL 0x48
 #define CAP_START_POS 0x40
 
@@ -1425,6 +1433,11 @@ int

dm_pci_capability_clear_and_set_word(struct

Quoted 1 line

udevice *dev, int cap, int dm_pci_capability_clear_and_set_dword(struct

udevice *dev, int cap,

Quoted 3 lines
                                          int pos, u32 clear, u32

set);

Quoted 11 lines
Quoted 9 lines
include/pci.h +5 -0
+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) \
--

Please add test cases test/dm/pci.c::dm_test_pci_cap()

Will add in v5.

Quoted 3 lines

Regards,
Bin

Thanks,
Zhiqiang