mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 11:03:43 +02:00
net: stmmac: platform: read channels irq
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> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Link: https://patch.msgid.link/20260313-dwmac_multi_irq-v12-1-b5c9d0aa13d6@oss.nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
cc6421acd9
commit
a31bbe5ca2
|
|
@ -695,9 +695,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
|
||||
|
|
@ -733,7 +771,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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user