[1/1] PCI: layerscape(ep): Implement common 'dbi' reg-names for dbi_base

Message ID 20240229194559.709182-1-Frank.Li@nxp.com
State New
Headers
Series [1/1] PCI: layerscape(ep): Implement common 'dbi' reg-names for dbi_base |

Commit Message

Frank Li Feb. 29, 2024, 7:45 p.m. UTC
  Apply 'dbi' as the primary name for dbi_base register space in line with
Designware common binding. Attempt resource acquisition using 'dbi' first
via platform_get_resource_byname(). If encountering older device tree
files, gracefully fallback to 'regs', issuing a warning message.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/pci/controller/dwc/pci-layerscape-ep.c | 7 ++++++-
 drivers/pci/controller/dwc/pci-layerscape.c    | 7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
  

Patch

diff --git a/drivers/pci/controller/dwc/pci-layerscape-ep.c b/drivers/pci/controller/dwc/pci-layerscape-ep.c
index 1f6ee1460ec2a..92d4750611d07 100644
--- a/drivers/pci/controller/dwc/pci-layerscape-ep.c
+++ b/drivers/pci/controller/dwc/pci-layerscape-ep.c
@@ -259,7 +259,12 @@  static int __init ls_pcie_ep_probe(struct platform_device *pdev)
 	pcie->pci = pci;
 	pcie->ls_epc = ls_epc;
 
-	dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
+	dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi");
+	if (!dbi_base) {
+		dev_warn(dev, "Please update your dtb, reg-names 'regs' should be 'dbi'");
+		dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
+	}
+
 	pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base);
 	if (IS_ERR(pci->dbi_base))
 		return PTR_ERR(pci->dbi_base);
diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c
index ee6f525681337..1985086f6a1f3 100644
--- a/drivers/pci/controller/dwc/pci-layerscape.c
+++ b/drivers/pci/controller/dwc/pci-layerscape.c
@@ -345,7 +345,12 @@  static int ls_pcie_probe(struct platform_device *pdev)
 	pcie->pci = pci;
 	pci->pp.ops = pcie->drvdata->ops;
 
-	dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
+	dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi");
+	if (!dbi_base) {
+		dev_err(dev, "Please update your dtb, reg-names 'regs' should be 'dbi'");
+		dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
+	}
+
 	pci->dbi_base = devm_pci_remap_cfg_resource(dev, dbi_base);
 	if (IS_ERR(pci->dbi_base))
 		return PTR_ERR(pci->dbi_base);