[PATCH v11 1/4] net: stmmac: platform: read channels irq

Jan Petrous via B4 Relay
2026-03-12T08:55:45Z

Read IRQ resources for all rx/tx channels, to allow Multi-IRQ mode
for platform glue drivers.

Reviewed-by: Matthias Brugger <mbrugger@suse.com>
Signed-off-by: Jan Petrous (OSS) <jan.petrous@oss.nxp.com>
---
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 57 +++++++++++++++++++++-
1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 5c9fd91a1db9..542cd629df11 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -697,9 +697,47 @@ struct clk *stmmac_pltfr_find_clk(struct plat_stmmacenet_data *plat_dat,
}
EXPORT_SYMBOL_GPL(stmmac_pltfr_find_clk);

+/**
+ * stmmac_pltfr_get_irq_array - Read per-channel IRQs from platform device
+ * @pdev: platform device
+ * @fmt: IRQ name format string (e.g., "tx-queue-%d")
+ * @irqs: array to store IRQ numbers
+ * @num: maximum number of IRQs to read
+ *
+ * Return: 0 on success, -EPROBE_DEFER if IRQ is deferred, -EINVAL on error.
+ * Missing IRQs are set to 0 and iteration stops at first missing IRQ.
+ */
+static int stmmac_pltfr_get_irq_array(struct platform_device *pdev,
+ const char *fmt, int *irqs, size_t num)
+{
+ char name[16];
+ int i;
+
+ for (i = 0; i < num; i++) {
+ if (snprintf(name, sizeof(name), fmt, i) >= sizeof(name))
+ return -EINVAL;
+
+ irqs[i] = platform_get_irq_byname_optional(pdev, name);
+ if (irqs[i] == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+
+ if (irqs[i] <= 0) {
+ dev_dbg(&pdev->dev, "IRQ %s not found\n", name);
+
+ /* Stop silently on first unset irq */
+ irqs[i] = 0;
+ break;
+ }
+ }
+
+ return 0;
+}
+
int stmmac_get_platform_resources(struct platform_device *pdev,
struct stmmac_resources *stmmac_res)
{
+ int ret;
+
memset(stmmac_res, 0, sizeof(*stmmac_res));

/* Get IRQ information early to have an ability to ask for deferred
@@ -735,7 +773,24 @@ int stmmac_get_platform_resources(struct platform_device *pdev,

stmmac_res->addr = devm_platform_ioremap_resource(pdev, 0);

- return PTR_ERR_OR_ZERO(stmmac_res->addr);
+ if (IS_ERR(stmmac_res->addr))
+ return PTR_ERR(stmmac_res->addr);
+
+ /* TX channels irq */
+ ret = stmmac_pltfr_get_irq_array(pdev, "tx-queue-%d",
+ stmmac_res->tx_irq,
+ MTL_MAX_TX_QUEUES);
+ if (ret)
+ return ret;
+
+ /* RX channels irq */
+ ret = stmmac_pltfr_get_irq_array(pdev, "rx-queue-%d",
+ stmmac_res->rx_irq,
+ MTL_MAX_RX_QUEUES);
+ if (ret)
+ return ret;
+
+ return 0;
}
EXPORT_SYMBOL_GPL(stmmac_get_platform_resources);

--
2.47.0