[PATCH v4 07/12] PCI: imx6: Add help function imx_pcie_match_device()

From: Frank Li
Date: Tue May 07 2024 - 14:49:04 EST


Introduce the help function imx_pcie_match_device() to facilitate
imx_pcie_quirk() in verifying whether the device's bus driver corresponds
to the IMX6 PCI controller. This addition lays the groundwork for future
support of ITS and IOMMU in the IMX95.

Signed-off-by: Frank Li <Frank.Li@xxxxxxx>
---
drivers/pci/controller/dwc/pci-imx6.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
index d074bcc34d7a7..b33d8790a93af 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -1652,17 +1652,25 @@ static struct platform_driver imx_pcie_driver = {
.shutdown = imx_pcie_shutdown,
};

-static void imx_pcie_quirk(struct pci_dev *dev)
+static bool imx_pcie_match_device(struct pci_bus *bus)
{
- struct pci_bus *bus = dev->bus;
- struct dw_pcie_rp *pp = bus->sysdata;
-
/* Bus parent is the PCI bridge, its parent is this platform driver */
if (!bus->dev.parent || !bus->dev.parent->parent)
- return;
+ return false;

/* Make sure we only quirk devices associated with this driver */
if (bus->dev.parent->parent->driver != &imx_pcie_driver.driver)
+ return false;
+
+ return true;
+}
+
+static void imx_pcie_quirk(struct pci_dev *dev)
+{
+ struct pci_bus *bus = dev->bus;
+ struct dw_pcie_rp *pp = bus->sysdata;
+
+ if (!imx_pcie_match_device(bus))
return;

if (pci_is_root_bus(bus)) {

--
2.34.1