Skip to contentSkip to conversation

Add support for Xilinx XDMA Soft IP as Root Port

PATCH Superseded Thippeswamy Havalige 4 participants 8 messages Jul 22, 2024 – Jul 24, 2024

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 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

 .../bindings/pci/xlnx,xdma-host.yaml          | 41 ++++++++++++-
 drivers/pci/controller/pcie-xilinx-dma-pl.c   | 58 ++++++++++++++++++-
 2 files changed, 94 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 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.

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

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

Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +39 -2
index 2f59b3a73dd2..28d9350a7fb4 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
@@ -111,4 +122,30 @@ examples:
                 interrupt-controller;
             };
         };
+
+        pcie@80000000 {
+            compatible = "xlnx,qdma-host-3.00";
+            reg = <0x0 0x80000000 0x0 0x10000000>, <0x0 0x90000000 0x0 0x10000000>;
+            reg-names = "cfg", "breg";
+            ranges = <0x2000000 0x0 0xa8000000 0x0 0xa8000000 0x0 0x8000000>,
+                     <0x43000000 0x4 0x80000000 0x4 0x80000000 0x0 0x40000000>;
+            #address-cells = <3>;
+            #size-cells = <2>;
+            #interrupt-cells = <1>;
+            device_type = "pci";
+            interrupt-parent = <&gic>;
+            interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>,
+                         <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
+            interrupt-names = "misc", "msi0", "msi1";
+            interrupt-map-mask = <0x0 0x0 0x0 0x7>;
+            interrupt-map = <0 0 0 1 &pcie_intc_0 0>,
+                            <0 0 0 2 &pcie_intc_0 1>,
+                            <0 0 0 3 &pcie_intc_0 2>,
+                            <0 0 0 4 &pcie_intc_0 3>;
+            pcie_intc_1: interrupt-controller {
+                #address-cells = <0>;
+                #interrupt-cells = <1>;
+                interrupt-controller;
+            };
+        };
     };
Signature · 1 line
2.25.1
#2 lore raw

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

Quoted 18 lines · Thippeswamy Havalige

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

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

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

Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +0 -0
index 2f59b3a73dd2..28d9350a7fb4 100644
@@ -14,10 +14,21 @@ allOf:
 
 properties:
   compatible:

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

Quoted 10 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +6 -2
-    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.

Please constrain the new entry to only the new compatible.

Quoted 11 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +7 -0
+    minItems: 1
+
+  reg-names:
+    items:
+      - const: cfg
+      - const: breg
+    minItems: 1
 
   ranges:
     maxItems: 2

Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml examples: · line 126

Quoted 5 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +2 -0
@@ -111,4 +122,30 @@ examples:
                 interrupt-controller;
             };
         };
+
+        pcie@80000000 {

tbh, don't see the point of a new example for this.

Quoted 28 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +24 -0
+            compatible = "xlnx,qdma-host-3.00";
+            reg = <0x0 0x80000000 0x0 0x10000000>, <0x0 0x90000000 0x0 0x10000000>;
+            reg-names = "cfg", "breg";
+            ranges = <0x2000000 0x0 0xa8000000 0x0 0xa8000000 0x0 0x8000000>,
+                     <0x43000000 0x4 0x80000000 0x4 0x80000000 0x0 0x40000000>;
+            #address-cells = <3>;
+            #size-cells = <2>;
+            #interrupt-cells = <1>;
+            device_type = "pci";
+            interrupt-parent = <&gic>;
+            interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>,
+                         <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
+            interrupt-names = "misc", "msi0", "msi1";
+            interrupt-map-mask = <0x0 0x0 0x0 0x7>;
+            interrupt-map = <0 0 0 1 &pcie_intc_0 0>,
+                            <0 0 0 2 &pcie_intc_0 1>,
+                            <0 0 0 3 &pcie_intc_0 2>,
+                            <0 0 0 4 &pcie_intc_0 3>;
+            pcie_intc_1: interrupt-controller {
+                #address-cells = <0>;
+                #interrupt-cells = <1>;
+                interrupt-controller;
+            };
+        };
     };
Signature · 1 line
2.25.1
#3 lore raw

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

Hi Conor Dooley,

Quoted 39 lines

-----Original Message-----
From: Conor Dooley <[email protected]>
Sent: Monday, July 22, 2024 10:15 PM
To: Havalige, Thippeswamy <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Havalige, Thippeswamy <[email protected]>; [email protected]; Simek, Michal <[email protected]>
Subject: Re: [PATCH v2 1/2] dt-bindings: PCI: xilinx-xdma: Add schemas for Xilinx QDMA PCIe Root Port Bridge

Quoted 1 line · Thippeswamy Havalige

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

Bridge.

Review

Quoted 10 lines
---
 .../bindings/pci/xlnx,xdma-host.yaml          | 41 ++++++++++++++++++-
 1 file changed, 39 insertions(+), 2 deletions(-)

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

(quoted diff) +0 -0

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

Quoted 12 lines

index 2f59b3a73dd2..28d9350a7fb4 100644

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

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

Quoted 5 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +3 -1
   reg:
-    maxItems: 1
+    items:
+      - description: configuration region and XDMA bridge register.
+      - description: QDMA bridge register.

Please constrain the new entry to only the new compatible.

- Thanks, I ll resend patch with required changes.

Quoted 9 lines
Quoted 9 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +7 -0
+    minItems: 1
+
+  reg-names:
+    items:
+      - const: cfg
+      - const: breg
+    minItems: 1
 
Quoted 10 lines

Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml examples: · line 126

Quoted 8 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +2 -0
   ranges:
     maxItems: 2
@@ -111,4 +122,30 @@ examples:
                 interrupt-controller;
             };
         };
+
+        pcie@80000000 {

tbh, don't see the point of a new example for this.

- For this in both examples ranges properties are different. So, here I wanted to make sure that our example device tree bindings work straight forward when our reference designs are used.

Quoted 8 lines

Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml examples: · line 128

Quoted 3 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +2 -0
+            compatible = "xlnx,qdma-host-3.00";
+            reg = <0x0 0x80000000 0x0 0x10000000>, <0x0 0x90000000 0x0

0x10000000>;

Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml examples: · line 130

Quoted 2 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +2 -0
+            reg-names = "cfg", "breg";
+            ranges = <0x2000000 0x0 0xa8000000 0x0 0xa8000000 0x0

0x8000000>,

Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml examples: · line 131

Quoted 1 line
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +1 -0
+                     <0x43000000 0x4 0x80000000 0x4 0x80000000 0x0
Quoted 25 lines

0x40000000>;

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

Quoted 6 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +6 -0
+            #address-cells = <3>;
+            #size-cells = <2>;
+            #interrupt-cells = <1>;
+            device_type = "pci";
+            interrupt-parent = <&gic>;
+            interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 85

IRQ_TYPE_LEVEL_HIGH>,

Quoted 17 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +13 -1
+                         <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
+            interrupt-names = "misc", "msi0", "msi1";
+            interrupt-map-mask = <0x0 0x0 0x0 0x7>;
+            interrupt-map = <0 0 0 1 &pcie_intc_0 0>,
+                            <0 0 0 2 &pcie_intc_0 1>,
+                            <0 0 0 3 &pcie_intc_0 2>,
+                            <0 0 0 4 &pcie_intc_0 3>;
+            pcie_intc_1: interrupt-controller {
+                #address-cells = <0>;
+                #interrupt-cells = <1>;
+                interrupt-controller;
+            };
+        };
     };
--

2.25.1

Regards,
Thippeswamy H

#4 lore raw

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

Quoted 41 lines · Thippeswamy

Hi Conor Dooley,

Quoted 39 lines

-----Original Message-----
From: Conor Dooley <[email protected]>
Sent: Monday, July 22, 2024 10:15 PM
To: Havalige, Thippeswamy <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Havalige, Thippeswamy <[email protected]>; [email protected]; Simek, Michal <[email protected]>
Subject: Re: [PATCH v2 1/2] dt-bindings: PCI: xilinx-xdma: Add schemas for Xilinx QDMA PCIe Root Port Bridge

Quoted 1 line · Thippeswamy Havalige

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

Bridge.

Review

Quoted 10 lines
---
 .../bindings/pci/xlnx,xdma-host.yaml          | 41 ++++++++++++++++++-
 1 file changed, 39 insertions(+), 2 deletions(-)

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

(quoted diff) +0 -0

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

Quoted 12 lines

index 2f59b3a73dd2..28d9350a7fb4 100644

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

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

Quoted 5 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +3 -1
   reg:
-    maxItems: 1
+    items:
+      - description: configuration region and XDMA bridge register.
+      - description: QDMA bridge register.

Please constrain the new entry to only the new compatible.

- Thanks, I ll resend patch with required changes.

Weird quoting btw, the - isn't needed.

Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +7 -0
+    minItems: 1
+
+  reg-names:
+    items:
+      - const: cfg
+      - const: breg
+    minItems: 1
 
Quoted 10 lines

Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml examples: · line 126

Quoted 8 lines
Documentation/devicetree/bindings/pci/xlnx,xdma-host.yaml +2 -0
   ranges:
     maxItems: 2
@@ -111,4 +122,30 @@ examples:
                 interrupt-controller;
             };
         };
+
+        pcie@80000000 {

tbh, don't see the point of a new example for this.

Quoted 1 line

- For this in both examples ranges properties are different. So, here I wanted to make sure that our example device tree bindings work straight forward when our reference designs are used.

Different ranges properties doesn't justify a new example. They don't exist to be copy-pasted, but rather to demonstrate usage of properties and validate the binding.

#5 lore raw

PATCH v2 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 | 58 +++++++++++++++++++--
 1 file changed, 55 insertions(+), 3 deletions(-)

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

drivers/pci/controller/pcie-xilinx-dma-pl.c +55 -3
index 5be5dfd8398f..933be090f92d 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)
 {
-	return readl(port->reg_base + reg);
+	if (port->variant->version == XDMA)
+		return readl(port->reg_base + reg);
+	else
+		return readl(port->reg_base + reg + QDMA_BRIDGE_BASE_OFF);
 }
 
 static inline void pcie_write(struct pl_dma_pcie *port, u32 val, u32 reg)
 {
-	writel(val, port->reg_base + reg);
+	if (port->variant->version == XDMA)
+		writel(val, port->reg_base + reg);
+	else
+		writel(val, port->reg_base + reg + QDMA_BRIDGE_BASE_OFF);
 }
 
 static inline bool xilinx_pl_dma_pcie_link_up(struct pl_dma_pcie *port)
@@ -173,7 +198,10 @@ static void __iomem *xilinx_pl_dma_pcie_map_bus(struct pci_bus *bus,
 	if (!xilinx_pl_dma_pcie_valid_device(bus, devfn))
 		return NULL;
 
-	return port->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where);
+	if (port->variant->version == XDMA)
+		return port->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where);
+	else
+		return port->cfg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where);
 }
 
 /* PCIe operations */
@@ -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
2.25.1
#6 lore raw

Re: [PATCH v2 2/2] PCI: xilinx-xdma: Add Xilinx QDMA Root Port driver

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

Capitalize brand names.

Quoted 2 lines

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

Rewrap to fill 75 columns.

Quoted 1 line

+#define QDMA_BRIDGE_BASE_OFF 0xCD8

Other #defines in this file user lower-case hex; please match them.

Quoted 20 lines

static inline u32 pcie_read(struct pl_dma_pcie *port, u32 reg) {

drivers/pci/controller/pcie-xilinx-dma-pl.c +8 -2
-	return readl(port->reg_base + reg);
+	if (port->variant->version == XDMA)
+		return readl(port->reg_base + reg);
+	else
+		return readl(port->reg_base + reg + QDMA_BRIDGE_BASE_OFF);
 }
 
 static inline void pcie_write(struct pl_dma_pcie *port, u32 val, u32 reg)
 {
-	writel(val, port->reg_base + reg);
+	if (port->variant->version == XDMA)
+		writel(val, port->reg_base + reg);
+	else
+		writel(val, port->reg_base + reg + QDMA_BRIDGE_BASE_OFF);
 }
 
 static inline bool xilinx_pl_dma_pcie_link_up(struct pl_dma_pcie *port)

drivers/pci/controller/pcie-xilinx-dma-pl.c static void __iomem *xilinx_pl_dma_pcie_map_bus(struct pci_bus *bus, · line 204

Quoted 8 lines
drivers/pci/controller/pcie-xilinx-dma-pl.c +4 -1
@@ -173,7 +198,10 @@ static void __iomem *xilinx_pl_dma_pcie_map_bus(struct pci_bus *bus,
 	if (!xilinx_pl_dma_pcie_valid_device(bus, devfn))
 		return NULL;
 
-	return port->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where);
+	if (port->variant->version == XDMA)
+		return port->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where);
+	else
+		return port->cfg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where);

If you rework the variant tests above to use
"if (port->variant->version == QDMA)" instead, they will match the one below, and you won't need to touch the existing code at all, e.g.,

+ 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);
Quoted 15 lines
drivers/pci/controller/pcie-xilinx-dma-pl.c +8 -0
 }
 
 /* PCIe operations */
@@ -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;
+	}
#7 lore raw

RE: [PATCH v2 2/2] PCI: xilinx-xdma: Add Xilinx QDMA Root Port driver

Hi Bjorn,

Thanks, will update all your review comments and resend patch.

Regards,
Thippeswamy H

Quoted 92 lines

-----Original Message-----
From: Bjorn Helgaas <[email protected]>
Sent: Tuesday, July 23, 2024 3:45 AM
To: Havalige, Thippeswamy <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Havalige, Thippeswamy <[email protected]>; [email protected]; Simek, Michal <[email protected]>
Subject: Re: [PATCH v2 2/2] PCI: xilinx-xdma: Add Xilinx QDMA Root Port driver

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

Capitalize brand names.

Quoted 2 lines

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

Rewrap to fill 75 columns.

Quoted 1 line

+#define QDMA_BRIDGE_BASE_OFF 0xCD8

Other #defines in this file user lower-case hex; please match them.

drivers/pci/controller/pcie-xilinx-dma-pl.c struct pl_dma_pcie {

Quoted 7 lines

static inline u32 pcie_read(struct pl_dma_pcie *port, u32 reg) {

drivers/pci/controller/pcie-xilinx-dma-pl.c +4 -1
-	return readl(port->reg_base + reg);
+	if (port->variant->version == XDMA)
+		return readl(port->reg_base + reg);
+	else
+		return readl(port->reg_base + reg +

QDMA_BRIDGE_BASE_OFF);

drivers/pci/controller/pcie-xilinx-dma-pl.c struct pl_dma_pcie {

Quoted 9 lines

}

static inline void pcie_write(struct pl_dma_pcie *port, u32 val, u32 reg) {

drivers/pci/controller/pcie-xilinx-dma-pl.c +4 -1
-	writel(val, port->reg_base + reg);
+	if (port->variant->version == XDMA)
+		writel(val, port->reg_base + reg);
+	else
+		writel(val, port->reg_base + reg +

QDMA_BRIDGE_BASE_OFF);

Review static void __iomem

Quoted 4 lines

}

static inline bool xilinx_pl_dma_pcie_link_up(struct pl_dma_pcie *port)

(quoted diff) +0 -0
@@ -173,7 +198,10 @@ static void __iomem

*xilinx_pl_dma_pcie_map_bus(struct pci_bus *bus,

drivers/pci/controller/pcie-xilinx-dma-pl.c static void __iomem *xilinx_pl_dma_pcie_map_bus(struct pci_bus *bus,

Quoted 4 lines
drivers/pci/controller/pcie-xilinx-dma-pl.c +0 -1
 	if (!xilinx_pl_dma_pcie_valid_device(bus, devfn))
 		return NULL;
 
-	return port->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn,

where);

Review static void __iomem · line 202

Quoted 2 lines
(quoted diff) +2 -0
+	if (port->variant->version == XDMA)
+		return port->reg_base + PCIE_ECAM_OFFSET(bus->number,

devfn, where);

Review static void __iomem · line 204

Quoted 2 lines
(quoted diff) +2 -0
+	else
+		return port->cfg_base + PCIE_ECAM_OFFSET(bus->number,

devfn, where);

If you rework the variant tests above to use
"if (port->variant->version == QDMA)" instead, they will match the one below, and you won't need to touch the existing code at all, e.g.,

+ 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);

drivers/pci/controller/pcie-xilinx-dma-pl.c static int xilinx_pl_dma_pcie_parse_dt(struct

Quoted 4 lines
drivers/pci/controller/pcie-xilinx-dma-pl.c +0 -0
 }
 
 /* PCIe operations */
@@ -731,6 +759,15 @@ static int xilinx_pl_dma_pcie_parse_dt(struct

pl_dma_pcie *port,

drivers/pci/controller/pcie-xilinx-dma-pl.c static int xilinx_pl_dma_pcie_parse_dt(struct pl_dma_pcie *port,

Quoted 6 lines
drivers/pci/controller/pcie-xilinx-dma-pl.c +3 -0
 	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");

Quoted 5 lines
drivers/pci/controller/pcie-xilinx-dma-pl.c +5 -0
+		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;
+	}