Skip to contentSkip to conversation

Add support for Xilinx XDMA Soft IP as Root Port

PATCH Superseded Thippeswamy Havalige 4 participants 6 messages Aug 9, 2024 – Aug 11, 2024

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add support for Xilinx XDMA Soft IP as Root Port

This series of patch add support for Xilinx QDMA Soft IP as Root Port.

The Xilinx QDMA Soft IP support's 32 bit and 64bit BAR's. As Root Port it supports MSI and legacy interrupts.

Thippeswamy Havalige (2):
dt-bindings: PCI: xilinx-xdma: Add schemas for Xilinx QDMA PCIe Root
Port Bridge
PCI: xilinx-xdma: Add Xilinx QDMA Root Port driver

 .../devicetree/bindings/pci/xlnx,xdma-host.yaml    | 36 ++++++++++++++-
 drivers/pci/controller/pcie-xilinx-dma-pl.c        | 54 +++++++++++++++++++++-
 2 files changed, 87 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v3 1/2 dt-bindings: PCI: xilinx-xdma: Add schemas for Xilinx QDMA PCIe Root Port Bridge

Add YAML devicetree schemas for Xilinx QDMA Soft IP PCIe Root Port Bridge.

---
 .../devicetree/bindings/pci/xlnx,xdma-host.yaml    | 36 ++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

---
changes in v3
- constrain the new entry to only the new compatible.
- Remove example.

changes in v2
- update dt node label with pcie.
---

Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +34 -2
index 2f59b3a..f1efd919 100644
@@ -14,10 +14,21 @@ allOf:
 
 properties:
   compatible:
-    const: xlnx,xdma-host-3.00
+    enum:
+      - xlnx,xdma-host-3.00
+      - xlnx,qdma-host-3.00
 
   reg:
-    maxItems: 1
+    items:
+      - description: configuration region and XDMA bridge register.
+      - description: QDMA bridge register.
+    minItems: 1
+
+  reg-names:
+    items:
+      - const: cfg
+      - const: breg
+    minItems: 1
 
   ranges:
     maxItems: 2
@@ -76,6 +87,27 @@ required:
   - "#interrupt-cells"
   - interrupt-controller
 
+if:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - xlnx,qdma-host-3.00
+then:
+  properties:
+    reg:
+      minItems: 2
+    reg-names:
+      minItems: 2
+  required:
+    - reg-names
+else:
+  properties:
+    reg:
+      maxItems: 1
+    reg-names:
+      maxItems: 1
+
 unevaluatedProperties: false
 
 examples:
Signature · 1 line
1.8.3.1
maintainer
#3 lore raw

Re: [PATCH v3 1/2] dt-bindings: PCI: xilinx-xdma: Add schemas for Xilinx QDMA PCIe Root Port Bridge

In reply to Thippeswamy Havalige
Quoted 20 lines · Thippeswamy Havalige

Add YAML devicetree schemas for Xilinx QDMA Soft IP PCIe Root Port Bridge.

---
 .../devicetree/bindings/pci/xlnx,xdma-host.yaml    | 36 ++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

---
changes in v3
- constrain the new entry to only the new compatible.
- Remove example.

changes in v2
- update dt node label with pcie.
---

Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +0 -0
index 2f59b3a..f1efd919 100644

Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml allOf: · line 19

Quoted 7 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +3 -1
@@ -14,10 +14,21 @@ allOf:
 
 properties:
   compatible:
-    const: xlnx,xdma-host-3.00
+    enum:
+      - xlnx,xdma-host-3.00
+      - xlnx,qdma-host-3.00

Kind of odd that both IP have the exact same version number. Please explain in the commit message where it comes from. If you just copied it from the previous one, then nak.

Quoted 47 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +31 -1
   reg:
-    maxItems: 1
+    items:
+      - description: configuration region and XDMA bridge register.
+      - description: QDMA bridge register.
+    minItems: 1
+
+  reg-names:
+    items:
+      - const: cfg
+      - const: breg
+    minItems: 1
 
   ranges:
     maxItems: 2
@@ -76,6 +87,27 @@ required:
   - "#interrupt-cells"
   - interrupt-controller
 
+if:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - xlnx,qdma-host-3.00
+then:
+  properties:
+    reg:
+      minItems: 2
+    reg-names:
+      minItems: 2
+  required:
+    - reg-names
+else:
+  properties:
+    reg:
+      maxItems: 1
+    reg-names:
+      maxItems: 1
+
 unevaluatedProperties: false
 
 examples:
Signature · 1 line
1.8.3.1
#4 lore raw

RE: [PATCH v3 1/2] dt-bindings: PCI: xilinx-xdma: Add schemas for Xilinx QDMA PCIe Root Port Bridge

Hi Rob Herring,

Quoted 36 lines

-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Friday, August 9, 2024 11:40 PM
To: Havalige, Thippeswamy <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Havalige, Thippeswamy <[email protected]>; linux-arm- [email protected]; Simek, Michal <[email protected]>
Subject: Re: [PATCH v3 1/2] dt-bindings: PCI: xilinx-xdma: Add schemas for Xilinx QDMA PCIe Root Port Bridge

Quoted 6 lines · Thippeswamy Havalige

Add YAML devicetree schemas for Xilinx QDMA Soft IP PCIe Root Port Bridge.

---
 .../devicetree/bindings/pci/xlnx,xdma-host.yaml    | 36

++++++++++++++++++++--

Review

Quoted 10 lines
 1 file changed, 34 insertions(+), 2 deletions(-)

---
changes in v3
- constrain the new entry to only the new compatible.
- Remove example.

changes in v2
- update dt node label with pcie.
---

(quoted diff) +0 -0

b/Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml

Quoted 5 lines

index 2f59b3a..f1efd919 100644

Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +0 -0
@@ -14,10 +14,21 @@ allOf:
 
Quoted 10 lines

Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml allOf: · line 19

Quoted 6 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +3 -1
 properties:
   compatible:
-    const: xlnx,xdma-host-3.00
+    enum:
+      - xlnx,xdma-host-3.00
+      - xlnx,qdma-host-3.00

Kind of odd that both IP have the exact same version number. Please explain in the commit message where it comes from. If you just copied it from the previous one, then nak.

When QDMA IP bought up we were using 3.0 version initially so the compatible String is xlnx,qdma-host-3.00

Quoted 48 lines
Quoted 48 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +31 -2
   reg:
-    maxItems: 1
+    items:
+      - description: configuration region and XDMA bridge register.
+      - description: QDMA bridge register.
+    minItems: 1
+
+  reg-names:
+    items:
+      - const: cfg
+      - const: breg
+    minItems: 1
 
   ranges:
     maxItems: 2
@@ -76,6 +87,27 @@ required:
   - "#interrupt-cells"
   - interrupt-controller
 
+if:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - xlnx,qdma-host-3.00
+then:
+  properties:
+    reg:
+      minItems: 2
+    reg-names:
+      minItems: 2
+  required:
+    - reg-names
+else:
+  properties:
+    reg:
+      maxItems: 1
+    reg-names:
+      maxItems: 1
+
 unevaluatedProperties: false
 
 examples:
--

1.8.3.1

#5 lore raw

PATCH v3 2/2 PCI: xilinx-xdma: Add Xilinx QDMA Root Port driver

In reply to Thippeswamy Havalige

Add support for Xilinx QDMA Soft IP core as Root Port.

The Versal Prime devices support QDMA soft IP module in programmable logic.

The integrated QDMA Soft IP block has integrated bridge function that can act as PCIe Root Port.

---
 drivers/pci/controller/pcie-xilinx-dma-pl.c | 54 ++++++++++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)

---
changes in v3:
- Modify macro value to lower case.
- Change return type based QDMA compatible.

changes in v2:
- Add description for struct pl_dma_pcie
---

drivers/pci/controller/pcie-xilinx-dma-pl.c +53 -1
index 5be5dfd..1ea6a1d 100644
@@ -13,6 +13,7 @@
 #include <linux/msi.h>
 #include <linux/of_address.h>
 #include <linux/of_pci.h>
+#include <linux/of_platform.h>
 
 #include "../pci.h"
 #include "pcie-xilinx-common.h"
@@ -71,10 +72,24 @@
 
 /* Phy Status/Control Register definitions */
 #define XILINX_PCIE_DMA_REG_PSCR_LNKUP	BIT(11)
+#define QDMA_BRIDGE_BASE_OFF		0xcd8
 
 /* Number of MSI IRQs */
 #define XILINX_NUM_MSI_IRQS	64
 
+enum xilinx_pl_dma_version {
+	XDMA,
+	QDMA,
+};
+
+/**
+ * struct xilinx_pl_dma_variant - PL DMA PCIe variant information
+ * @version: DMA version
+ */
+struct xilinx_pl_dma_variant {
+	enum xilinx_pl_dma_version version;
+};
+
 struct xilinx_msi {
 	struct irq_domain	*msi_domain;
 	unsigned long		*bitmap;
@@ -88,6 +103,7 @@ struct xilinx_msi {
  * struct pl_dma_pcie - PCIe port information
  * @dev: Device pointer
  * @reg_base: IO Mapped Register Base
+ * @cfg_base: IO Mapped Configuration Base
  * @irq: Interrupt number
  * @cfg: Holds mappings of config space window
  * @phys_reg_base: Physical address of reg base
@@ -97,10 +113,12 @@ struct xilinx_msi {
  * @msi: MSI information
  * @intx_irq: INTx error interrupt number
  * @lock: Lock protecting shared register access
+ * @variant: PL DMA PCIe version check pointer
  */
 struct pl_dma_pcie {
 	struct device			*dev;
 	void __iomem			*reg_base;
+	void __iomem			*cfg_base;
 	int				irq;
 	struct pci_config_window	*cfg;
 	phys_addr_t			phys_reg_base;
@@ -110,16 +128,23 @@ struct pl_dma_pcie {
 	struct xilinx_msi		msi;
 	int				intx_irq;
 	raw_spinlock_t			lock;
+	const struct xilinx_pl_dma_variant   *variant;
 };
 
 static inline u32 pcie_read(struct pl_dma_pcie *port, u32 reg)
 {
+	if (port->variant->version == QDMA)
+		return readl(port->reg_base + reg + QDMA_BRIDGE_BASE_OFF);
+
 	return readl(port->reg_base + reg);
 }
 
 static inline void pcie_write(struct pl_dma_pcie *port, u32 val, u32 reg)
 {
-	writel(val, port->reg_base + reg);
+	if (port->variant->version == QDMA)
+		writel(val, port->reg_base + reg + QDMA_BRIDGE_BASE_OFF);
+	else
+		writel(val, port->reg_base + reg);
 }
 
 static inline bool xilinx_pl_dma_pcie_link_up(struct pl_dma_pcie *port)
@@ -173,6 +198,9 @@ static void __iomem *xilinx_pl_dma_pcie_map_bus(struct pci_bus *bus,
 	if (!xilinx_pl_dma_pcie_valid_device(bus, devfn))
 		return NULL;
 
+	if (port->variant->version == QDMA)
+		return port->cfg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where);
+
 	return port->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where);
 }
 
@@ -731,6 +759,15 @@ static int xilinx_pl_dma_pcie_parse_dt(struct pl_dma_pcie *port,
 
 	port->reg_base = port->cfg->win;
 
+	if (port->variant->version == QDMA) {
+		port->cfg_base = port->cfg->win;
+		res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "breg");
+		port->reg_base = devm_ioremap_resource(dev, res);
+		if (IS_ERR(port->reg_base))
+			return PTR_ERR(port->reg_base);
+		port->phys_reg_base = res->start;
+	}
+
 	err = xilinx_request_msi_irq(port);
 	if (err) {
 		pci_ecam_free(port->cfg);
@@ -760,6 +797,8 @@ static int xilinx_pl_dma_pcie_probe(struct platform_device *pdev)
 	if (!bus)
 		return -ENODEV;
 
+	port->variant = of_device_get_match_data(dev);
+
 	err = xilinx_pl_dma_pcie_parse_dt(port, bus->res);
 	if (err) {
 		dev_err(dev, "Parsing DT failed\n");
@@ -791,9 +830,22 @@ static int xilinx_pl_dma_pcie_probe(struct platform_device *pdev)
 	return err;
 }
 
+static const struct xilinx_pl_dma_variant xdma_host = {
+	.version = XDMA,
+};
+
+static const struct xilinx_pl_dma_variant qdma_host = {
+	.version = QDMA,
+};
+
 static const struct of_device_id xilinx_pl_dma_pcie_of_match[] = {
 	{
 		.compatible = "xlnx,xdma-host-3.00",
+		.data = &xdma_host,
+	},
+	{
+		.compatible = "xlnx,qdma-host-3.00",
+		.data = &qdma_host,
 	},
 	{}
 };
Signature · 1 line
1.8.3.1