ALT Linux kernel packages development
 help / color / mirror / Atom feed
From: Daniil Gnusarev <gnusarevda@basealt.ru>
To: gnusarevda@basealt.ru, devel-kernel@lists.altlinux.org
Subject: [d-kernel] [PATCH 3/5] pci: baikal-pcie: driver compatibility with SDK versions 5.4
Date: Fri, 24 Apr 2026 18:33:24 +0400
Message-ID: <20260424143329.427971-4-gnusarevda@basealt.ru> (raw)
In-Reply-To: <20260424143329.427971-1-gnusarevda@basealt.ru>

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>
Do-not-upstream: this is a feature of Baikal-M
---
 drivers/pci/controller/dwc/pcie-baikal-core.c | 59 ++++++++++++++++++-
 1 file changed, 56 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-baikal-core.c b/drivers/pci/controller/dwc/pcie-baikal-core.c
index d67e6cab6e0de..a1de90e0ef6e1 100644
--- a/drivers/pci/controller/dwc/pcie-baikal-core.c
+++ b/drivers/pci/controller/dwc/pcie-baikal-core.c
@@ -650,10 +650,63 @@ 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



  parent reply	other threads:[~2026-04-24 14:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24 14:33 [d-kernel] [PATCH 0/5] Kernel 6.18 with support for the Baikal-M SoC Daniil Gnusarev
2026-04-24 14:33 ` [d-kernel] [PATCH 1/5] pci: baikal-pcie: add support for PCIe controller for Baikal BE-M1000 Daniil Gnusarev
2026-04-24 14:33 ` [d-kernel] [PATCH 2/5] pci: baikal-pcie: driver compatibility with SDK earlier than 5.7 Daniil Gnusarev
2026-04-24 14:33 ` Daniil Gnusarev [this message]
2026-04-24 14:33 ` [d-kernel] [PATCH 4/5] pci: baikal-pcie: use raw_spinlock for regmap of gbr registers Daniil Gnusarev
2026-04-24 14:33 ` [d-kernel] [PATCH 5/5] pci: baikal-pcie: forced enable dma-coherent for pcie on Baikal-M Daniil Gnusarev
2026-04-26  6:06 ` [d-kernel] [PATCH 0/5] Kernel 6.18 with support for the Baikal-M SoC Vitaly Chikunov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260424143329.427971-4-gnusarevda@basealt.ru \
    --to=gnusarevda@basealt.ru \
    --cc=devel-kernel@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux kernel packages development

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel-kernel/0 devel-kernel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel-kernel devel-kernel/ http://lore.altlinux.org/devel-kernel \
		devel-kernel@altlinux.org devel-kernel@altlinux.ru devel-kernel@altlinux.com
	public-inbox-index devel-kernel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git