Skip to contentSkip to conversation

drivers: pcie_xilinx: Fix "reg" not found error

PATCH In review Mayuresh Chitale 3 participants 9 messages Nov 11, 2023 – Nov 16, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drivers: pcie_xilinx: Fix "reg" not found error

Fix the driver to use the dev_read_addr_size API to fetch the reg property from the DT.

---
Changes in v2:
====
- Remove global_data.h from include
- Use devm_ioremap instead of map_phsymem

 drivers/pci/pcie_xilinx.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)
drivers/pci/pcie_xilinx.c +9 -17
index 53fd121e90..c1f5bbbb1b 100644
@@ -8,11 +8,9 @@
 #include <common.h>
 #include <dm.h>
 #include <pci.h>
-#include <asm/global_data.h>
 #include <linux/bitops.h>
 #include <linux/printk.h>
-
-#include <asm/io.h>
+#include <linux/io.h>
 
 /**
  * struct xilinx_pcie - Xilinx PCIe controller state
@@ -140,20 +138,14 @@ static int pcie_xilinx_write_config(struct udevice *bus, pci_dev_t bdf,
 static int pcie_xilinx_of_to_plat(struct udevice *dev)
 {
 	struct xilinx_pcie *pcie = dev_get_priv(dev);
-	struct fdt_resource reg_res;
-	DECLARE_GLOBAL_DATA_PTR;
-	int err;
-
-	err = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev), "reg",
-			       0, &reg_res);
-	if (err < 0) {
-		pr_err("\"reg\" resource not found\n");
-		return err;
-	}
-
-	pcie->cfg_base = map_physmem(reg_res.start,
-				     fdt_resource_size(&reg_res),
-				     MAP_NOCACHE);
+	fdt_addr_t addr;
+	fdt_size_t size;
+
+	addr = dev_read_addr_size(dev, &size);
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	pcie->cfg_base = devm_ioremap(dev, addr, size);
 
 	return 0;
 }
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/1 net: axi_emac: Use reg property for DMA registers

As per the xlnx,axi-ethernet-1.00.a DT documentation in linux, the AXI DMA registers can be obtained via the reg property or via a separate node for the axistream DMA controller. Currently only the latter is supported, so add support to fetch the DMA controller registers from the "reg" property.

---
Changes in v2:
====
Add Reviewed-by Tag.

 drivers/net/xilinx_axi_emac.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/xilinx_axi_emac.c +4 -5
index 54f2232768..ef151ee51b 100644
@@ -903,12 +903,11 @@ static int axi_emac_of_to_plat(struct udevice *dev)
 
 	ret = dev_read_phandle_with_args(dev, "axistream-connected", NULL, 0, 0,
 					 &axistream_node);
-	if (ret) {
-		printf("%s: axistream is not found\n", __func__);
-		return -EINVAL;
-	}
+	if (!ret)
+		plat->dmatx = (struct axidma_reg *)ofnode_get_addr(axistream_node.node);
+	else
+		plat->dmatx = (struct axidma_reg *)dev_read_addr_index(dev, 1);
 
-	plat->dmatx = (struct axidma_reg *)ofnode_get_addr(axistream_node.node);
 	if (!plat->dmatx) {
 		printf("%s: axi_dma register space not found\n", __func__);
 		return -EINVAL;
Signature · 1 line
2.34.1
#4 lore raw

PATCH v2 1/1 pci: xilinx: Enable MMIO region

In reply to Mayuresh Chitale

The host bridge MMIO region is disabled by default due to which MMIO accesses cause an exception. Fix it by setting the bridge enable bit. This change is ported from the linux pcie-xilinx driver.

---
Changes in v2:
====
Add Reviewed-by Tag.

 drivers/pci/pcie_xilinx.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/pci/pcie_xilinx.c +8 -0
index c1f5bbbb1b..7052d6dac8 100644
@@ -23,6 +23,8 @@ struct xilinx_pcie {
 /* Register definitions */
 #define XILINX_PCIE_REG_PSCR		0x144
 #define XILINX_PCIE_REG_PSCR_LNKUP	BIT(11)
+#define XILINX_PCIE_REG_RPSC		0x148
+#define XILINX_PCIE_REG_RPSC_BEN	BIT(0)
 
 /**
  * pcie_xilinx_link_up() - Check whether the PCIe link is up
@@ -140,6 +142,7 @@ static int pcie_xilinx_of_to_plat(struct udevice *dev)
 	struct xilinx_pcie *pcie = dev_get_priv(dev);
 	fdt_addr_t addr;
 	fdt_size_t size;
+	u32 rpsc;
 
 	addr = dev_read_addr_size(dev, &size);
 	if (addr == FDT_ADDR_T_NONE)
@@ -147,6 +150,11 @@ static int pcie_xilinx_of_to_plat(struct udevice *dev)
 
 	pcie->cfg_base = devm_ioremap(dev, addr, size);
 
+	/* Enable the Bridge enable bit */
+	rpsc = __raw_readl(pcie->cfg_base + XILINX_PCIE_REG_RPSC);
+	rpsc |= XILINX_PCIE_REG_RPSC_BEN;
+	__raw_writel(rpsc, pcie->cfg_base + XILINX_PCIE_REG_RPSC);
+
 	return 0;
 }
 
Signature · 1 line
2.34.1
maintainer
#5 lore raw
In reply to Mayuresh Chitale
Quoted 46 lines · Mayuresh Chitale

Fix the driver to use the dev_read_addr_size API to fetch the reg property from the DT.

---
Changes in v2:
====
- Remove global_data.h from include
- Use devm_ioremap instead of map_phsymem

  drivers/pci/pcie_xilinx.c | 26 +++++++++-----------------
  1 file changed, 9 insertions(+), 17 deletions(-)
drivers/pci/pcie_xilinx.c +1 -15
index 53fd121e90..c1f5bbbb1b 100644
@@ -8,11 +8,9 @@
  #include <common.h>
  #include <dm.h>
  #include <pci.h>
-#include <asm/global_data.h>
  #include <linux/bitops.h>
  #include <linux/printk.h>
-
-#include <asm/io.h>
+#include <linux/io.h>
 
  /**
   * struct xilinx_pcie - Xilinx PCIe controller state
@@ -140,20 +138,14 @@ static int pcie_xilinx_write_config(struct udevice *bus, pci_dev_t bdf,
  static int pcie_xilinx_of_to_plat(struct udevice *dev)
  {
  	struct xilinx_pcie *pcie = dev_get_priv(dev);
-	struct fdt_resource reg_res;
-	DECLARE_GLOBAL_DATA_PTR;
-	int err;
-
-	err = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev), "reg",
-			       0, &reg_res);
-	if (err < 0) {
-		pr_err("\"reg\" resource not found\n");
-		return err;
-	}
-
-	pcie->cfg_base = map_physmem(reg_res.start,

drivers/pci/pcie_xilinx.c static int pcie_xilinx_write_config(struct udevice *bus, pci_dev_t bdf, · line 148

Quoted 10 lines
drivers/pci/pcie_xilinx.c +8 -2
-				     fdt_resource_size(&reg_res),
-				     MAP_NOCACHE);
+	fdt_addr_t addr;
+	fdt_size_t size;
+
+	addr = dev_read_addr_size(dev, &size);
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	pcie->cfg_base = devm_ioremap(dev, addr, size);

this can also fail.

Just put there.

	if (IS_ERR(pcie->cfg_base))
		return PTR_ERR(pcie->cfg_base);

M

maintainer
#2 lore raw

Re: [PATCH v2] net: axi_emac: Use reg property for DMA registers

In reply to Mayuresh Chitale
Quoted 27 lines · Mayuresh Chitale

As per the xlnx,axi-ethernet-1.00.a DT documentation in linux, the AXI DMA registers can be obtained via the reg property or via a separate node for the axistream DMA controller. Currently only the latter is supported, so add support to fetch the DMA controller registers from the "reg" property.

---
Changes in v2:
====
Add Reviewed-by Tag.

  drivers/net/xilinx_axi_emac.c | 9 ++++-----
  1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/xilinx_axi_emac.c +0 -3
index 54f2232768..ef151ee51b 100644
@@ -903,12 +903,11 @@ static int axi_emac_of_to_plat(struct udevice *dev)
 
  	ret = dev_read_phandle_with_args(dev, "axistream-connected", NULL, 0, 0,
  					 &axistream_node);
-	if (ret) {
-		printf("%s: axistream is not found\n", __func__);
-		return -EINVAL;

drivers/net/xilinx_axi_emac.c static int axi_emac_of_to_plat(struct udevice *dev) · line 913

Quoted 10 lines
drivers/net/xilinx_axi_emac.c +4 -2
-	}
+	if (!ret)
+		plat->dmatx = (struct axidma_reg *)ofnode_get_addr(axistream_node.node);
+	else
+		plat->dmatx = (struct axidma_reg *)dev_read_addr_index(dev, 1);
 
-	plat->dmatx = (struct axidma_reg *)ofnode_get_addr(axistream_node.node);
  	if (!plat->dmatx) {
  		printf("%s: axi_dma register space not found\n", __func__);
  		return -EINVAL;

This is the part of pcie series but it has nothing to do with it. Can you please send it separately?

M

maintainer
#7 lore raw
In reply to Mayuresh Chitale

one more thing here.

Subject of your next patch is
[PATCH v2] pci: xilinx: Enable MMIO region
and here you are using drivers: pcie_xilinx:

Please use one if you target the same code.
I prefer "pci: xilinx:" style.

Thanks,
Michal

#3 lore raw

Re: [PATCH v2] net: axi_emac: Use reg property for DMA registers

In reply to Michal Simek

Hi Michal,

Quoted 43 lines · Michal Simek
Quoted 41 lines · Mayuresh Chitale

As per the xlnx,axi-ethernet-1.00.a DT documentation in linux, the AXI
DMA registers can be obtained via the reg property or via a separate
node for the axistream DMA controller. Currently only the latter is supported, so add support to fetch the DMA controller registers from the
"reg" property.

---
Changes in v2:
====
Add Reviewed-by Tag.

  drivers/net/xilinx_axi_emac.c | 9 ++++-----
  1 file changed, 4 insertions(+), 5 deletions(-)
drivers/net/xilinx_axi_emac.c +4 -4
index 54f2232768..ef151ee51b 100644
@@ -903,12 +903,11 @@ static int axi_emac_of_to_plat(struct udevice
 *dev)
 
  	ret = dev_read_phandle_with_args(dev, "axistream-connected",
 NULL, 0, 0,
  					 &axistream_node);
-	if (ret) {
-		printf("%s: axistream is not found\n", __func__);
-		return -EINVAL;
-	}
+	if (!ret)
+		plat->dmatx = (struct axidma_reg
 *)ofnode_get_addr(axistream_node.node);
+	else
+		plat->dmatx = (struct axidma_reg
 *)dev_read_addr_index(dev, 1);
Quoted 10 lines
Quoted 6 lines
drivers/net/xilinx_axi_emac.c +0 -1
-	plat->dmatx = (struct axidma_reg

*)ofnode_get_addr(axistream_node.node);
if (!plat->dmatx) {
printf("%s: axi_dma register space not found\n",
__func__);
return -EINVAL;

This is the part of pcie series but it has nothing to do with it. Can you please
send it separately?

Yes, actually I intended to send this patch as well as the PCIe patches as individual patches but the way I invoked send-email caused those to become a series.

Quoted 2 lines

M

#6 lore raw
In reply to Michal Simek
Quoted 62 lines · Michal Simek
Quoted 47 lines · Mayuresh Chitale

Fix the driver to use the dev_read_addr_size API to fetch the reg property from the DT.

---
Changes in v2:
====
- Remove global_data.h from include
- Use devm_ioremap instead of map_phsymem

  drivers/pci/pcie_xilinx.c | 26 +++++++++-----------------
  1 file changed, 9 insertions(+), 17 deletions(-)
drivers/pci/pcie_xilinx.c +1 -15
index 53fd121e90..c1f5bbbb1b 100644
@@ -8,11 +8,9 @@
  #include <common.h>
  #include <dm.h>
  #include <pci.h>
-#include <asm/global_data.h>
  #include <linux/bitops.h>
  #include <linux/printk.h>
-
-#include <asm/io.h>
+#include <linux/io.h>
 
  /**
   * struct xilinx_pcie - Xilinx PCIe controller state
@@ -140,20 +138,14 @@ static int pcie_xilinx_write_config(struct
 udevice *bus, pci_dev_t bdf,
  static int pcie_xilinx_of_to_plat(struct udevice *dev)
  {
  	struct xilinx_pcie *pcie = dev_get_priv(dev);
-	struct fdt_resource reg_res;
-	DECLARE_GLOBAL_DATA_PTR;
-	int err;
-
-	err = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev), "reg",
-			       0, &reg_res);
-	if (err < 0) {
-		pr_err("\"reg\" resource not found\n");
-		return err;
-	}
-
-	pcie->cfg_base = map_physmem(reg_res.start,

drivers/pci/pcie_xilinx.c static int pcie_xilinx_write_config(struct · line 149

Quoted 10 lines
drivers/pci/pcie_xilinx.c +8 -2
-				     fdt_resource_size(&reg_res),
-				     MAP_NOCACHE);
+	fdt_addr_t addr;
+	fdt_size_t size;
+
+	addr = dev_read_addr_size(dev, &size);
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	pcie->cfg_base = devm_ioremap(dev, addr, size);

this can also fail.

Quoted 3 lines

Just put there.

	if (IS_ERR(pcie->cfg_base))
		return PTR_ERR(pcie->cfg_base);

Ok.

Quoted 2 lines

M

#8 lore raw
In reply to Michal Simek
Quoted 8 lines · Michal Simek

one more thing here.

Subject of your next patch is
[PATCH v2] pci: xilinx: Enable MMIO region
and here you are using drivers: pcie_xilinx:

Please use one if you target the same code.
I prefer "pci: xilinx:" style.

Ok.

Quoted 5 lines

Thanks,
Michal