Skip to contentSkip to conversation

Add support for Xilinx Versal CPM5 Root Port

PATCH Superseded Bharat Kumar Gogada 3 participants 8 messages Jun 16, 2022 – Jun 18, 2022

Subsystems (5)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add support for Xilinx Versal CPM5 Root Port

Xilinx Versal Premium series has CPM5 block which supports Root Port functioning at Gen5 speed.

Xilinx Versal CPM5 has few changes with existing CPM block.
- CPM5 has dedicated register space for control and status registers.
- CPM5 legacy interrupt handling needs additonal register bit to enable and handle legacy interrupts.

Changes in v5:
- Added of_device_get_match_data to identify CPM version.

Bharat Kumar Gogada (2):
dt-bindings: PCI: xilinx-cpm: Add Versal CPM5 Root Port
PCI: xilinx-cpm: Add support for Versal CPM5 Root Port

 .../bindings/pci/xilinx-versal-cpm.yaml       | 48 ++++++++++++--
 drivers/pci/controller/pcie-xilinx-cpm.c      | 62 ++++++++++++++++++-
 2 files changed, 103 insertions(+), 7 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v5 1/2 dt-bindings: PCI: xilinx-cpm: Add Versal CPM5 Root Port

Xilinx Versal Premium series has CPM5 block which supports Root Port functionality at Gen5 speed.

Add support for YAML schemas documentation for Versal CPM5 Root Port driver.

---
 .../bindings/pci/xilinx-versal-cpm.yaml       | 48 +++++++++++++++++--
 1 file changed, 44 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/pci/xilinx-versal-cpm.yaml +44 -4
index cca395317a4c..80597f2974e5 100644
@@ -14,17 +14,27 @@ allOf:
 
 properties:
   compatible:
-    const: xlnx,versal-cpm-host-1.00
+    contains:
+      enum:
+        - xlnx,versal-cpm-host-1.00
+        - xlnx,versal-cpm5-host
 
   reg:
     items:
       - description: CPM system level control and status registers.
       - description: Configuration space region and bridge registers.
+      - description: CPM5 control and status registers.
+    minItems: 2
 
   reg-names:
-    items:
-      - const: cpm_slcr
-      - const: cfg
+    oneOf:
+      - items:
+          - const: cpm_slcr
+          - const: cfg
+      - items:
+          - const: cpm_slcr
+          - const: cfg
+          - const: cpm_csr
 
   interrupts:
     maxItems: 1
@@ -95,4 +105,34 @@ examples:
                                interrupt-controller;
                        };
                };
+
+               cpm5_pcie: pcie@fcdd0000 {
+                       compatible = "xlnx,versal-cpm5-host";
+                       device_type = "pci";
+                       #address-cells = <3>;
+                       #interrupt-cells = <1>;
+                       #size-cells = <2>;
+                       interrupts = <0 72 4>;
+                       interrupt-parent = <&gic>;
+                       interrupt-map-mask = <0 0 0 7>;
+                       interrupt-map = <0 0 0 1 &pcie_intc_1 0>,
+                                       <0 0 0 2 &pcie_intc_1 1>,
+                                       <0 0 0 3 &pcie_intc_1 2>,
+                                       <0 0 0 4 &pcie_intc_1 3>;
+                       bus-range = <0x00 0xff>;
+                       ranges = <0x02000000 0x0 0xe0000000 0x0 0xe0000000 0x0 0x10000000>,
+                                <0x43000000 0x80 0x00000000 0x80 0x00000000 0x0 0x80000000>;
+                       msi-map = <0x0 &its_gic 0x0 0x10000>;
+                       reg = <0x00 0xfcdd0000 0x00 0x1000>,
+                             <0x06 0x00000000 0x00 0x1000000>,
+                             <0x00 0xfce20000 0x00 0x1000000>;
+                       reg-names = "cpm_slcr", "cfg", "cpm_csr";
+
+                       pcie_intc_1: interrupt-controller {
+                               #address-cells = <0>;
+                               #interrupt-cells = <1>;
+                               interrupt-controller;
+                       };
+               };
+
     };
Signature · 1 line
2.17.1
#2 lore raw

RE: [PATCH v5 1/2] dt-bindings: PCI: xilinx-cpm: Add Versal CPM5 Root Port

Hi Rob,

Please neglect this, i picked up old patch. Will resend this series, with correct device tree patch.

Regards,
Bharat

Quoted 88 lines

Xilinx Versal Premium series has CPM5 block which supports Root Port functionality at Gen5 speed.

Add support for YAML schemas documentation for Versal CPM5 Root Port driver.

---
 .../bindings/pci/xilinx-versal-cpm.yaml       | 48 +++++++++++++++++--
 1 file changed, 44 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/pci/xilinx-versal-cpm.yaml +31 -4
index cca395317a4c..80597f2974e5 100644
@@ -14,17 +14,27 @@ allOf:
 
 properties:
   compatible:
-    const: xlnx,versal-cpm-host-1.00
+    contains:
+      enum:
+        - xlnx,versal-cpm-host-1.00
+        - xlnx,versal-cpm5-host
 
   reg:
     items:
       - description: CPM system level control and status registers.
       - description: Configuration space region and bridge registers.
+      - description: CPM5 control and status registers.
+    minItems: 2
 
   reg-names:
-    items:
-      - const: cpm_slcr
-      - const: cfg
+    oneOf:
+      - items:
+          - const: cpm_slcr
+          - const: cfg
+      - items:
+          - const: cpm_slcr
+          - const: cfg
+          - const: cpm_csr
 
   interrupts:
     maxItems: 1
@@ -95,4 +105,34 @@ examples:
                                interrupt-controller;
                        };
                };
+
+               cpm5_pcie: pcie@fcdd0000 {
+                       compatible = "xlnx,versal-cpm5-host";
+                       device_type = "pci";
+                       #address-cells = <3>;
+                       #interrupt-cells = <1>;
+                       #size-cells = <2>;
+                       interrupts = <0 72 4>;
+                       interrupt-parent = <&gic>;
+                       interrupt-map-mask = <0 0 0 7>;
+                       interrupt-map = <0 0 0 1 &pcie_intc_1 0>,
+                                       <0 0 0 2 &pcie_intc_1 1>,
+                                       <0 0 0 3 &pcie_intc_1 2>,
+                                       <0 0 0 4 &pcie_intc_1 3>;
+                       bus-range = <0x00 0xff>;
+                       ranges = <0x02000000 0x0 0xe0000000 0x0 0xe0000000 0x0
 0x10000000>,
+                                <0x43000000 0x80 0x00000000 0x80 0x00000000 0x0

0x80000000>;

Documentation/devicetree/bindings/pci/xilinx-versal-cpm.yaml +13 -1
+                       msi-map = <0x0 &its_gic 0x0 0x10000>;
+                       reg = <0x00 0xfcdd0000 0x00 0x1000>,
+                             <0x06 0x00000000 0x00 0x1000000>,
+                             <0x00 0xfce20000 0x00 0x1000000>;
+                       reg-names = "cpm_slcr", "cfg", "cpm_csr";
+
+                       pcie_intc_1: interrupt-controller {
+                               #address-cells = <0>;
+                               #interrupt-cells = <1>;
+                               interrupt-controller;
+                       };
+               };
+
     };
--

2.17.1

#3 lore raw

PATCH v5 2/2 PCI: xilinx-cpm: Add support for Versal CPM5 Root Port

In reply to Bharat Kumar Gogada

Xilinx Versal Premium series has CPM5 block which supports Root Port functioning at Gen5 speed.

Xilinx Versal CPM5 has few changes with existing CPM block.
- CPM5 has dedicated register space for control and status registers.
- CPM5 legacy interrupt handling needs additional register bit to enable and handle legacy interrupts.

---
 drivers/pci/controller/pcie-xilinx-cpm.c | 62 ++++++++++++++++++++++--
 1 file changed, 59 insertions(+), 3 deletions(-)
drivers/pci/controller/pcie-xilinx-cpm.c +59 -3
index c7cd44ed4dfc..0bcd11d27eeb 100644
@@ -35,6 +35,10 @@
 #define XILINX_CPM_PCIE_MISC_IR_ENABLE	0x00000348
 #define XILINX_CPM_PCIE_MISC_IR_LOCAL	BIT(1)
 
+#define XILINX_CPM_PCIE_IR_STATUS       0x000002A0
+#define XILINX_CPM_PCIE_IR_ENABLE       0x000002A8
+#define XILINX_CPM_PCIE_IR_LOCAL        BIT(0)
+
 /* Interrupt registers definitions */
 #define XILINX_CPM_PCIE_INTR_LINK_DOWN		0
 #define XILINX_CPM_PCIE_INTR_HOT_RESET		3
@@ -98,6 +102,16 @@
 /* Phy Status/Control Register definitions */
 #define XILINX_CPM_PCIE_REG_PSCR_LNKUP		BIT(11)
 
+/**
+ * struct xilinx_cpm_variant - CPM variant information
+ * @cpm_version: CPM5 has few changes compared to CPM block.
+ *      CPM5 has dedicated register space for control and status registers.
+ *
+ */
+struct xilinx_cpm_variant {
+	bool cpm_version;
+};
+
 /**
  * struct xilinx_cpm_pcie - PCIe port information
  * @dev: Device pointer
@@ -109,6 +123,7 @@
  * @intx_irq: legacy interrupt number
  * @irq: Error interrupt number
  * @lock: lock protecting shared register access
+ * @is_cpm5: value to check cpm version
  */
 struct xilinx_cpm_pcie {
 	struct device			*dev;
@@ -120,6 +135,7 @@ struct xilinx_cpm_pcie {
 	int				intx_irq;
 	int				irq;
 	raw_spinlock_t			lock;
+	bool                            is_cpm5;
 };
 
 static u32 pcie_read(struct xilinx_cpm_pcie *port, u32 reg)
@@ -285,6 +301,14 @@ static void xilinx_cpm_pcie_event_flow(struct irq_desc *desc)
 		generic_handle_domain_irq(port->cpm_domain, i);
 	pcie_write(port, val, XILINX_CPM_PCIE_REG_IDR);
 
+	if (port->is_cpm5) {
+		val = readl_relaxed(port->cpm_base + XILINX_CPM_PCIE_IR_STATUS);
+		if (val)
+			writel_relaxed(val,
+				       port->cpm_base +
+				       XILINX_CPM_PCIE_IR_STATUS);
+	}
+
 	/*
 	 * XILINX_CPM_PCIE_MISC_IR_STATUS register is mapped to
 	 * CPM SLCR block.
@@ -484,6 +508,12 @@ static void xilinx_cpm_pcie_init_port(struct xilinx_cpm_pcie *port)
 	 */
 	writel(XILINX_CPM_PCIE_MISC_IR_LOCAL,
 	       port->cpm_base + XILINX_CPM_PCIE_MISC_IR_ENABLE);
+
+	if (port->is_cpm5) {
+		writel(XILINX_CPM_PCIE_IR_LOCAL,
+		       port->cpm_base + XILINX_CPM_PCIE_IR_ENABLE);
+	}
+
 	/* Enable the Bridge enable bit */
 	pcie_write(port, pcie_read(port, XILINX_CPM_PCIE_REG_RPSC) |
 		   XILINX_CPM_PCIE_REG_RPSC_BEN,
@@ -503,6 +533,10 @@ static int xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie *port,
 	struct device *dev = port->dev;
 	struct platform_device *pdev = to_platform_device(dev);
 	struct resource *res;
+	const struct xilinx_cpm_variant *variant =
+		of_device_get_match_data(dev);
+
+	port->is_cpm5 = variant->cpm_version;
 
 	port->cpm_base = devm_platform_ioremap_resource_byname(pdev,
 							       "cpm_slcr");
@@ -518,7 +552,14 @@ static int xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie *port,
 	if (IS_ERR(port->cfg))
 		return PTR_ERR(port->cfg);
 
-	port->reg_base = port->cfg->win;
+	if (port->is_cpm5) {
+		port->reg_base = devm_platform_ioremap_resource_byname(pdev,
+								       "cpm_csr");
+		if (IS_ERR(port->reg_base))
+			return PTR_ERR(port->reg_base);
+	} else {
+		port->reg_base = port->cfg->win;
+	}
 
 	return 0;
 }
@@ -591,9 +632,24 @@ static int xilinx_cpm_pcie_probe(struct platform_device *pdev)
 	return err;
 }
 
+static const struct xilinx_cpm_variant cpm_host = {
+	.cpm_version = false,
+};
+
+static const struct xilinx_cpm_variant cpm5_host = {
+	.cpm_version = true,
+};
+
 static const struct of_device_id xilinx_cpm_pcie_of_match[] = {
-	{ .compatible = "xlnx,versal-cpm-host-1.00", },
-	{}
+	{
+		.compatible = "xlnx,versal-cpm-host-1.00",
+		.data = &cpm_host,
+	},
+	{
+		.compatible = "xlnx,versal-cpm5-host",
+		.data = &cpm5_host,
+	},
+	{},
 };
 
 static struct platform_driver xilinx_cpm_pcie_driver = {
Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH v5 2/2] PCI: xilinx-cpm: Add support for Versal CPM5 Root Port

Quoted 29 lines · Bharat Kumar Gogada

Xilinx Versal Premium series has CPM5 block which supports Root Port functioning at Gen5 speed.

Xilinx Versal CPM5 has few changes with existing CPM block.
- CPM5 has dedicated register space for control and status registers.
- CPM5 legacy interrupt handling needs additional register bit to enable and handle legacy interrupts.

---
 drivers/pci/controller/pcie-xilinx-cpm.c | 62 ++++++++++++++++++++++--
 1 file changed, 59 insertions(+), 3 deletions(-)
drivers/pci/controller/pcie-xilinx-cpm.c +4 -0
index c7cd44ed4dfc..0bcd11d27eeb 100644
@@ -35,6 +35,10 @@
 #define XILINX_CPM_PCIE_MISC_IR_ENABLE	0x00000348
 #define XILINX_CPM_PCIE_MISC_IR_LOCAL	BIT(1)
 
+#define XILINX_CPM_PCIE_IR_STATUS       0x000002A0
+#define XILINX_CPM_PCIE_IR_ENABLE       0x000002A8
+#define XILINX_CPM_PCIE_IR_LOCAL        BIT(0)
+
 /* Interrupt registers definitions */
 #define XILINX_CPM_PCIE_INTR_LINK_DOWN		0
 #define XILINX_CPM_PCIE_INTR_HOT_RESET		3

drivers/pci/controller/pcie-xilinx-cpm.c line 109

Quoted 8 lines
drivers/pci/controller/pcie-xilinx-cpm.c +5 -0
@@ -98,6 +102,16 @@
 /* Phy Status/Control Register definitions */
 #define XILINX_CPM_PCIE_REG_PSCR_LNKUP		BIT(11)
 
+/**
+ * struct xilinx_cpm_variant - CPM variant information
+ * @cpm_version: CPM5 has few changes compared to CPM block.
+ *      CPM5 has dedicated register space for control and status registers.
+ *

Superfluous blank line.

drivers/pci/controller/pcie-xilinx-cpm.c line 112

Quoted 3 lines
drivers/pci/controller/pcie-xilinx-cpm.c +3 -0
+ */
+struct xilinx_cpm_variant {
+	bool cpm_version;

This is not really a bool, unless you want to preclude the possibility of ever having a CPM6 or other future variants.

Quoted 50 lines
drivers/pci/controller/pcie-xilinx-cpm.c +18 -0
+};
+
 /**
  * struct xilinx_cpm_pcie - PCIe port information
  * @dev: Device pointer
@@ -109,6 +123,7 @@
  * @intx_irq: legacy interrupt number
  * @irq: Error interrupt number
  * @lock: lock protecting shared register access
+ * @is_cpm5: value to check cpm version
  */
 struct xilinx_cpm_pcie {
 	struct device			*dev;
@@ -120,6 +135,7 @@ struct xilinx_cpm_pcie {
 	int				intx_irq;
 	int				irq;
 	raw_spinlock_t			lock;
+	bool                            is_cpm5;
 };
 
 static u32 pcie_read(struct xilinx_cpm_pcie *port, u32 reg)
@@ -285,6 +301,14 @@ static void xilinx_cpm_pcie_event_flow(struct irq_desc *desc)
 		generic_handle_domain_irq(port->cpm_domain, i);
 	pcie_write(port, val, XILINX_CPM_PCIE_REG_IDR);
 
+	if (port->is_cpm5) {
+		val = readl_relaxed(port->cpm_base + XILINX_CPM_PCIE_IR_STATUS);
+		if (val)
+			writel_relaxed(val,
+				       port->cpm_base +
+				       XILINX_CPM_PCIE_IR_STATUS);
+	}
+
 	/*
 	 * XILINX_CPM_PCIE_MISC_IR_STATUS register is mapped to
 	 * CPM SLCR block.
@@ -484,6 +508,12 @@ static void xilinx_cpm_pcie_init_port(struct xilinx_cpm_pcie *port)
 	 */
 	writel(XILINX_CPM_PCIE_MISC_IR_LOCAL,
 	       port->cpm_base + XILINX_CPM_PCIE_MISC_IR_ENABLE);
+
+	if (port->is_cpm5) {
+		writel(XILINX_CPM_PCIE_IR_LOCAL,
+		       port->cpm_base + XILINX_CPM_PCIE_IR_ENABLE);
+	}
+
 	/* Enable the Bridge enable bit */
 	pcie_write(port, pcie_read(port, XILINX_CPM_PCIE_REG_RPSC) |
 		   XILINX_CPM_PCIE_REG_RPSC_BEN,

drivers/pci/controller/pcie-xilinx-cpm.c static int xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie *port, · line 539

Quoted 7 lines
drivers/pci/controller/pcie-xilinx-cpm.c +4 -0
@@ -503,6 +533,10 @@ static int xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie *port,
 	struct device *dev = port->dev;
 	struct platform_device *pdev = to_platform_device(dev);
 	struct resource *res;
+	const struct xilinx_cpm_variant *variant =
+		of_device_get_match_data(dev);
+
+	port->is_cpm5 = variant->cpm_version;

It's a little clunky to use booleans for a potentially multi-valued version and to copy them around. Something like this might leave room for future variants that need more knobs:

  enum xilinx_cpm_version {
    CPM,
    CPM5,
  };

  struct xilinx_cpm_variant {
    enum xilinx_cpm_version version;
  };

  struct xilinx_cpm_pcie {
    ...
    const struct xilinx_cpm_variant   *variant;

  static const struct xilinx_cpm_variant cpm5 = {
    .version = CPM5,
  };

  xilinx_cpm_pcie_event_flow()
  {
    ...
    if (port->variant->version == CPM5)

  xilinx_cpm_pcie_probe()
  {
    ...
    port->variant = of_device_get_match_data(dev);
Quoted 48 lines
drivers/pci/controller/pcie-xilinx-cpm.c +25 -3
 	port->cpm_base = devm_platform_ioremap_resource_byname(pdev,
 							       "cpm_slcr");
@@ -518,7 +552,14 @@ static int xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie *port,
 	if (IS_ERR(port->cfg))
 		return PTR_ERR(port->cfg);
 
-	port->reg_base = port->cfg->win;
+	if (port->is_cpm5) {
+		port->reg_base = devm_platform_ioremap_resource_byname(pdev,
+								       "cpm_csr");
+		if (IS_ERR(port->reg_base))
+			return PTR_ERR(port->reg_base);
+	} else {
+		port->reg_base = port->cfg->win;
+	}
 
 	return 0;
 }
@@ -591,9 +632,24 @@ static int xilinx_cpm_pcie_probe(struct platform_device *pdev)
 	return err;
 }
 
+static const struct xilinx_cpm_variant cpm_host = {
+	.cpm_version = false,
+};
+
+static const struct xilinx_cpm_variant cpm5_host = {
+	.cpm_version = true,
+};
+
 static const struct of_device_id xilinx_cpm_pcie_of_match[] = {
-	{ .compatible = "xlnx,versal-cpm-host-1.00", },
-	{}
+	{
+		.compatible = "xlnx,versal-cpm-host-1.00",
+		.data = &cpm_host,
+	},
+	{
+		.compatible = "xlnx,versal-cpm5-host",
+		.data = &cpm5_host,
+	},
+	{},
 };
 
 static struct platform_driver xilinx_cpm_pcie_driver = {
Signature · 1 line
2.17.1
#5 lore raw

RE: [PATCH v5 2/2] PCI: xilinx-cpm: Add support for Versal CPM5 Root Port

Quoted 106 lines · Bharat Kumar Gogada
Quoted 31 lines

Xilinx Versal Premium series has CPM5 block which supports Root Port functioning at Gen5 speed.

Xilinx Versal CPM5 has few changes with existing CPM block.
- CPM5 has dedicated register space for control and status registers.
- CPM5 legacy interrupt handling needs additional register bit to enable and handle legacy interrupts.

---
 drivers/pci/controller/pcie-xilinx-cpm.c | 62
++++++++++++++++++++++--
 1 file changed, 59 insertions(+), 3 deletions(-)
drivers/pci/controller/pcie-xilinx-cpm.c +4 -0
index c7cd44ed4dfc..0bcd11d27eeb 100644
@@ -35,6 +35,10 @@
 #define XILINX_CPM_PCIE_MISC_IR_ENABLE       0x00000348
 #define XILINX_CPM_PCIE_MISC_IR_LOCAL        BIT(1)
 
+#define XILINX_CPM_PCIE_IR_STATUS       0x000002A0
+#define XILINX_CPM_PCIE_IR_ENABLE       0x000002A8
+#define XILINX_CPM_PCIE_IR_LOCAL        BIT(0)
+
 /* Interrupt registers definitions */
 #define XILINX_CPM_PCIE_INTR_LINK_DOWN               0
 #define XILINX_CPM_PCIE_INTR_HOT_RESET               3

drivers/pci/controller/pcie-xilinx-cpm.c line 109

Quoted 8 lines
drivers/pci/controller/pcie-xilinx-cpm.c +5 -0
@@ -98,6 +102,16 @@
 /* Phy Status/Control Register definitions */
 #define XILINX_CPM_PCIE_REG_PSCR_LNKUP               BIT(11)
 
+/**
+ * struct xilinx_cpm_variant - CPM variant information
+ * @cpm_version: CPM5 has few changes compared to CPM block.
+ *      CPM5 has dedicated register space for control and status registers.
+ *

Superfluous blank line.

drivers/pci/controller/pcie-xilinx-cpm.c line 112

Quoted 3 lines
drivers/pci/controller/pcie-xilinx-cpm.c +3 -0
+ */
+struct xilinx_cpm_variant {
+     bool cpm_version;

This is not really a bool, unless you want to preclude the possibility of ever having a CPM6 or other future variants.

Quoted 17 lines
drivers/pci/controller/pcie-xilinx-cpm.c +3 -0
+};
+
 /**
  * struct xilinx_cpm_pcie - PCIe port information
  * @dev: Device pointer
@@ -109,6 +123,7 @@
  * @intx_irq: legacy interrupt number
  * @irq: Error interrupt number
  * @lock: lock protecting shared register access
+ * @is_cpm5: value to check cpm version
  */
 struct xilinx_cpm_pcie {
      struct device                   *dev;
@@ -120,6 +135,7 @@ struct xilinx_cpm_pcie {
      int                             intx_irq;
      int                             irq;
      raw_spinlock_t                  lock;

drivers/pci/controller/pcie-xilinx-cpm.c struct xilinx_cpm_pcie {

Quoted 10 lines
drivers/pci/controller/pcie-xilinx-cpm.c +4 -0
+     bool                            is_cpm5;
 };
 
 static u32 pcie_read(struct xilinx_cpm_pcie *port, u32 reg) @@ -285,6
+301,14 @@ static void xilinx_cpm_pcie_event_flow(struct irq_desc *desc)
              generic_handle_domain_irq(port->cpm_domain, i);
      pcie_write(port, val, XILINX_CPM_PCIE_REG_IDR);
 
+     if (port->is_cpm5) {
+             val = readl_relaxed(port->cpm_base +

XILINX_CPM_PCIE_IR_STATUS);

drivers/pci/controller/pcie-xilinx-cpm.c static void xilinx_cpm_pcie_init_port(struct

Quoted 10 lines
drivers/pci/controller/pcie-xilinx-cpm.c +6 -0
+             if (val)
+                     writel_relaxed(val,
+                                    port->cpm_base +
+                                    XILINX_CPM_PCIE_IR_STATUS);
+     }
+
      /*
       * XILINX_CPM_PCIE_MISC_IR_STATUS register is mapped to
       * CPM SLCR block.
@@ -484,6 +508,12 @@ static void xilinx_cpm_pcie_init_port(struct

xilinx_cpm_pcie *port)

Quoted 16 lines
drivers/pci/controller/pcie-xilinx-cpm.c +6 -0
       */
      writel(XILINX_CPM_PCIE_MISC_IR_LOCAL,
             port->cpm_base + XILINX_CPM_PCIE_MISC_IR_ENABLE);
+
+     if (port->is_cpm5) {
+             writel(XILINX_CPM_PCIE_IR_LOCAL,
+                    port->cpm_base + XILINX_CPM_PCIE_IR_ENABLE);
+     }
+
      /* Enable the Bridge enable bit */
      pcie_write(port, pcie_read(port, XILINX_CPM_PCIE_REG_RPSC) |
                 XILINX_CPM_PCIE_REG_RPSC_BEN, @@ -503,6 +533,10 @@

static int xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie *port,

      struct device *dev = port->dev;
      struct platform_device *pdev = to_platform_device(dev);
      struct resource *res;
Quoted 8 lines

drivers/pci/controller/pcie-xilinx-cpm.c static int xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie *port, · line 539

Quoted 4 lines
drivers/pci/controller/pcie-xilinx-cpm.c +4 -0
+     const struct xilinx_cpm_variant *variant =
+             of_device_get_match_data(dev);
+
+     port->is_cpm5 = variant->cpm_version;

It's a little clunky to use booleans for a potentially multi-valued version and to copy them around. Something like this might leave room for future variants that need more knobs:

Agreed will fix this in next patch.

Regards,
Bharat

Quoted 79 lines
  enum xilinx_cpm_version {
    CPM,
    CPM5,
  };

  struct xilinx_cpm_variant {
    enum xilinx_cpm_version version;
  };

  struct xilinx_cpm_pcie {
    ...
    const struct xilinx_cpm_variant   *variant;

  static const struct xilinx_cpm_variant cpm5 = {
    .version = CPM5,
  };

  xilinx_cpm_pcie_event_flow()
  {
    ...
    if (port->variant->version == CPM5)

  xilinx_cpm_pcie_probe()
  {
    ...
    port->variant = of_device_get_match_data(dev);
Quoted 3 lines
      port->cpm_base = devm_platform_ioremap_resource_byname(pdev,

"cpm_slcr"); @@ -518,7 +552,14 @@ static int

xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie *port,

drivers/pci/controller/pcie-xilinx-cpm.c static int xilinx_cpm_pcie_parse_dt(struct xilinx_cpm_pcie *port,

Quoted 6 lines
      if (IS_ERR(port->cfg))
              return PTR_ERR(port->cfg);
drivers/pci/controller/pcie-xilinx-cpm.c +2 -1
-     port->reg_base = port->cfg->win;
+     if (port->is_cpm5) {
+             port->reg_base =

devm_platform_ioremap_resource_byname(pdev,

drivers/pci/controller/pcie-xilinx-cpm.c static int xilinx_cpm_pcie_probe(struct

Quoted 10 lines
drivers/pci/controller/pcie-xilinx-cpm.c +6 -0
+                                                                    "cpm_csr");
+             if (IS_ERR(port->reg_base))
+                     return PTR_ERR(port->reg_base);
+     } else {
+             port->reg_base = port->cfg->win;
+     }
 
      return 0;
 }
@@ -591,9 +632,24 @@ static int xilinx_cpm_pcie_probe(struct

platform_device *pdev)

Quoted 29 lines
drivers/pci/controller/pcie-xilinx-cpm.c +17 -3
      return err;
 }
 
+static const struct xilinx_cpm_variant cpm_host = {
+     .cpm_version = false,
+};
+
+static const struct xilinx_cpm_variant cpm5_host = {
+     .cpm_version = true,
+};
+
 static const struct of_device_id xilinx_cpm_pcie_of_match[] = {
-     { .compatible = "xlnx,versal-cpm-host-1.00", },
-     {}
+     {
+             .compatible = "xlnx,versal-cpm-host-1.00",
+             .data = &cpm_host,
+     },
+     {
+             .compatible = "xlnx,versal-cpm5-host",
+             .data = &cpm5_host,
+     },
+     {},
 };
 
 static struct platform_driver xilinx_cpm_pcie_driver = {
--

2.17.1

#6 lore raw
In reply to Bharat Kumar Gogada
Quoted 12 lines · Bharat Kumar Gogada

Xilinx Versal Premium series has CPM5 block which supports Root Port functioning at Gen5 speed.

Xilinx Versal CPM5 has few changes with existing CPM block.
- CPM5 has dedicated register space for control and status registers.
- CPM5 legacy interrupt handling needs additonal register bit to enable and handle legacy interrupts.

Changes in v5:
- Added of_device_get_match_data to identify CPM version.

Quoted 7 lines

Bharat Kumar Gogada (2):
dt-bindings: PCI: xilinx-cpm: Add Versal CPM5 Root Port
PCI: xilinx-cpm: Add support for Versal CPM5 Root Port

 .../bindings/pci/xilinx-versal-cpm.yaml       | 48 ++++++++++++--
 drivers/pci/controller/pcie-xilinx-cpm.c      | 62 ++++++++++++++++++-
 2 files changed, 103 insertions(+), 7 deletions(-)

Weren't you going to include a MAINTAINERS update here?

https://lore.kernel.org/r/BY5PR02MB6947C5B34801AD5F289127ABA5A69@BY5PR02MB6947.namprd02.prod.outlook.com

Maybe I missed it?

Thanks,
Bjorn

#7 lore raw
Quoted 26 lines

CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

Quoted 12 lines · Bharat Kumar Gogada

Xilinx Versal Premium series has CPM5 block which supports Root Port functioning at Gen5 speed.

Xilinx Versal CPM5 has few changes with existing CPM block.
- CPM5 has dedicated register space for control and status registers.
- CPM5 legacy interrupt handling needs additonal register bit to enable and handle legacy interrupts.

Changes in v5:
- Added of_device_get_match_data to identify CPM version.

Quoted 7 lines

Bharat Kumar Gogada (2):
dt-bindings: PCI: xilinx-cpm: Add Versal CPM5 Root Port
PCI: xilinx-cpm: Add support for Versal CPM5 Root Port

 .../bindings/pci/xilinx-versal-cpm.yaml       | 48 ++++++++++++--
 drivers/pci/controller/pcie-xilinx-cpm.c      | 62 ++++++++++++++++++-
 2 files changed, 103 insertions(+), 7 deletions(-)
Quoted 7 lines

Weren't you going to include a MAINTAINERS update here?

https://lore.kernel.org/r/BY5PR02MB6947C5B34801AD5F289127ABA5A69@B
Y5PR02MB6947.namprd02.prod.outlook.com

Maybe I missed it?

HI Bjorn,

I planned to send it separately. Will send this soon.

Regards,
Bharat