[PATCH 07/16] pci: add pci_controller_init()

Sascha Hauer s.hauer at pengutronix.de
Tue Mar 26 03:07:37 PDT 2024


Upcoming patches will add a list to struct pci_controller. To make
sure we have a single point to initialize the list introduce a
pci_controller_init() and call it from all drivers which use
register_pci_controller(). Make sure host->parent is set correctly
before calling register_pci_controller() as that will be needed for
device tree parsing later.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/mips/mach-malta/pci.c         | 2 ++
 drivers/pci/pci-ecam-generic.c     | 2 ++
 drivers/pci/pci-efi.c              | 4 +++-
 drivers/pci/pci-mvebu.c            | 3 +++
 drivers/pci/pci-tegra.c            | 4 +++-
 drivers/pci/pci.c                  | 4 ++++
 drivers/pci/pcie-designware-host.c | 4 +++-
 include/linux/pci.h                | 1 +
 8 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/arch/mips/mach-malta/pci.c b/arch/mips/mach-malta/pci.c
index c9c1c7790b..200d3c907c 100644
--- a/arch/mips/mach-malta/pci.c
+++ b/arch/mips/mach-malta/pci.c
@@ -154,6 +154,8 @@ static int pcibios_init(void)
 {
 	resource_size_t start, end, map, start1, end1, map1, mask;
 
+	pci_controller_init(&gt64120_controller);
+
 	/*
 	 * Due to a bug in the Galileo system controller, we need
 	 * to setup the PCI BAR for the Galileo internal registers.
diff --git a/drivers/pci/pci-ecam-generic.c b/drivers/pci/pci-ecam-generic.c
index e8609bd4b0..4db40975e2 100644
--- a/drivers/pci/pci-ecam-generic.c
+++ b/drivers/pci/pci-ecam-generic.c
@@ -186,6 +186,8 @@ static int pcie_ecam_probe(struct device *dev)
 	ecam->pci.io_resource = &ecam->io;
 	ecam->pci.mem_pref_resource = &ecam->prefetch;
 
+	pci_controller_init(&ecam->pci);
+
 	ret = pcie_ecam_parse_dt(ecam);
 	if (ret)
 		return ret;
diff --git a/drivers/pci/pci-efi.c b/drivers/pci/pci-efi.c
index 67868d09b6..b8cd663161 100644
--- a/drivers/pci/pci-efi.c
+++ b/drivers/pci/pci-efi.c
@@ -277,6 +277,9 @@ static int efi_pci_probe(struct efi_device *efidev)
 
 	priv = xzalloc(sizeof(*priv));
 
+	priv->pci.parent = &efidev->dev;
+	pci_controller_init(&priv->pci);
+
 	BS->handle_protocol(efidev->handle, &EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID,
 			(void **)&priv->protocol);
 	if (!priv->protocol)
@@ -310,7 +313,6 @@ static int efi_pci_probe(struct efi_device *efidev)
 		}
 	}
 
-	priv->pci.parent = &efidev->dev;
 	priv->pci.pci_ops = &efi_pci_ops;
 
 	INIT_LIST_HEAD(&priv->children);
diff --git a/drivers/pci/pci-mvebu.c b/drivers/pci/pci-mvebu.c
index 9e2c7dc648..988465a344 100644
--- a/drivers/pci/pci-mvebu.c
+++ b/drivers/pci/pci-mvebu.c
@@ -322,6 +322,9 @@ static struct mvebu_pcie *mvebu_pcie_port_probe(struct device *dev,
 	}
 
 	pcie = xzalloc(sizeof(*pcie));
+
+	pci_controller_init(&pcie->pci);
+
 	pcie->port = port;
 	pcie->lane = lane;
 	pcie->lane_mask = lane_mask;
diff --git a/drivers/pci/pci-tegra.c b/drivers/pci/pci-tegra.c
index fba8b47ece..9ef50207ab 100644
--- a/drivers/pci/pci-tegra.c
+++ b/drivers/pci/pci-tegra.c
@@ -1167,7 +1167,6 @@ static int tegra_pcie_enable(struct tegra_pcie *pcie)
 		tegra_pcie_port_free(port);
 	}
 
-	pcie->pci.parent = pcie->dev;
 	pcie->pci.pci_ops = &tegra_pcie_ops;
 	pcie->pci.mem_resource = &pcie->mem;
 	pcie->pci.mem_pref_resource = &pcie->prefetch;
@@ -1241,6 +1240,9 @@ static int tegra_pcie_probe(struct device *dev)
 	if (!pcie)
 		return -ENOMEM;
 
+	pcie->pci.parent = pcie->dev;
+	pci_controller_init(&pcie->pci);
+
 	INIT_LIST_HEAD(&pcie->buses);
 	INIT_LIST_HEAD(&pcie->ports);
 	dev_get_drvdata(dev, (const void **)&pcie->soc_data);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 15e8cd46bd..67a085d34e 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -42,6 +42,10 @@ static void pci_bus_register_devices(struct pci_bus *bus)
 		pci_bus_register_devices(child_bus);
 }
 
+void pci_controller_init(struct pci_controller *hose)
+{
+}
+
 void register_pci_controller(struct pci_controller *hose)
 {
 	struct pci_bus *bus;
diff --git a/drivers/pci/pcie-designware-host.c b/drivers/pci/pcie-designware-host.c
index 644971d4a8..387fac5c0e 100644
--- a/drivers/pci/pcie-designware-host.c
+++ b/drivers/pci/pcie-designware-host.c
@@ -80,6 +80,9 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
 	const __be32 *addrp;
 	int index, ret;
 
+	pp->pci.parent = dev;
+	pci_controller_init(&pp->pci);
+
 	/* Find the address cell size and the number of cells in order to get
 	 * the untranslated address.
 	 */
@@ -156,7 +159,6 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
 			return ret;
 	}
 
-	pp->pci.parent = dev;
 	pp->pci.pci_ops = &dw_pcie_ops;
 	pp->pci.set_busno = dw_pcie_set_local_bus_nr;
 	pp->pci.mem_resource = &pp->mem;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 4d4ab818f8..2fea9ba6c7 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -278,6 +278,7 @@ int pci_register_device(struct pci_dev *pdev);
 
 extern struct list_head pci_root_buses; /* list of all known PCI buses */
 
+extern void pci_controller_init(struct pci_controller *hose);
 extern void register_pci_controller(struct pci_controller *hose);
 
 int pci_bus_read_config_byte(struct pci_bus *bus, unsigned int devfn,
-- 
2.39.2




More information about the barebox mailing list