[d-kernel] [PATCH 31/39] pci: baikal-pcie: driver compatibility with SDK versions 5.4

Daniil Gnusarev gnusarevda на basealt.ru
Пн Окт 14 17:02:12 MSK 2024


In SDK version 5.4 for PCIe devices the interrupt names required
for the driver are not specified. In this case, interrupts are
determined by index. In addition, the "msi-map" property is used
as in subsequent versions of SDK.

Signed-off-by: Daniil Gnusarev <gnusarevda на basealt.ru>
---
 drivers/pci/controller/dwc/pcie-baikal-core.c | 58 ++++++++++++++++++-
 1 file changed, 55 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-baikal-core.c b/drivers/pci/controller/dwc/pcie-baikal-core.c
index 19cb589e48db6..242503bffd888 100644
--- a/drivers/pci/controller/dwc/pcie-baikal-core.c
+++ b/drivers/pci/controller/dwc/pcie-baikal-core.c
@@ -640,10 +640,62 @@ static int bm1000_add_pcie_port(struct platform_device *pdev)
 	struct dw_pcie_rp *pp = &pci->pp;
 	int ret;
 
-	pp->irq = platform_get_irq_byname(pdev, "aer");
+	pp->irq = platform_get_irq_byname_optional(pdev, "aer");
 	if (pp->irq < 0) {
-		dev_err(dev, "failed to get \"aer\" IRQ\n");
-		return pp->irq;
+		dev_warn(dev, "failed to get \"aer\" IRQ, trying to get by index\n");
+		pp->irq = platform_get_irq(pdev, 0);
+		if (pp->irq < 0) {
+			dev_err(dev, "failed to get \"aer\" IRQ\n");
+			return pp->irq;
+		}
+		if (IS_ENABLED(CONFIG_PCI_MSI)) {
+			u32 lcru[2];
+			u32 maps[4];
+			struct of_changeset ocs;
+			struct property *prop;
+
+			pp->msi_irq[0] = platform_get_irq(pdev, 1);
+			if (pp->msi_irq[0] < 0) {
+				dev_err(dev, "failed to get \"msi\" IRQ\n");
+				return pp->msi_irq[0];
+			}
+
+			if (of_property_read_u32_array(dev->of_node, "baikal,pcie-lcru", lcru, 2)) {
+				dev_err(dev, "failed to read LCRU\n");
+				return -EINVAL;
+			}
+			if (of_property_read_u32_array(dev->of_node, "msi-map", maps, 4)) {
+				dev_err(dev, "failed to read msi-map\n");
+				return -EINVAL;
+			}
+
+			of_changeset_init(&ocs);
+
+			prop = of_find_property(dev->of_node, "msi-map", NULL);
+			if (!prop) {
+				dev_err(dev, "failed to find property msi-map\n");
+				return -EINVAL;
+			}
+
+			ret=of_changeset_remove_property(&ocs, dev->of_node, prop);
+			if (ret) {
+				dev_err(dev, "failed to remove property msi-map\n");
+				return ret;
+			}
+
+			maps[2] = lcru[1] * 0x10000;
+			ret=of_changeset_add_prop_u32_array(&ocs,dev->of_node,"msi-map",maps,4);
+			if (ret) {
+				dev_err(dev, "failed to modify property msi-map\n");
+				return ret;
+			}
+
+			ret=of_changeset_apply(&ocs);
+			if (ret) {
+				dev_err(dev, "failed to modify property msi-map\n");
+				return ret;
+			}
+		}
 	}
 
 	ret = devm_request_irq(dev, pp->irq, bm1000_pcie_aer_irq_handler,
-- 
2.42.2



Подробная информация о списке рассылки devel-kernel