2024-05-28 19:44:14

by Frank Li

[permalink] [raw]
Subject: [PATCH v5 07/12] PCI: imx6: Add help function imx_pcie_match_device()

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 <[email protected]>
---
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 5533b7ad0f092..29309ad0e352b 100644
--- a/drivers/pci/controller/dwc/pci-imx6.c
+++ b/drivers/pci/controller/dwc/pci-imx6.c
@@ -1646,17 +1646,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