Skip to content

Commit e618447

Browse files
LorenzoBianconikuba-moo
authored andcommitted
net: airoha: Allow mapping IO region for multiple qdma controllers
Map MMIO regions of both qdma controllers available on EN7581 SoC. Run airoha_hw_cleanup routine for both QDMA controllers available on EN7581 SoC removing airoha_eth module or in airoha_probe error path. This is a preliminary patch to support multi-QDMA controllers. Signed-off-by: Lorenzo Bianconi <[email protected]> Link: https://patch.msgid.link/a734ae608da14b67ae749b375d880dbbc70868ea.1722522582.git.lorenzo@kernel.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e3d6bfd commit e618447

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

drivers/net/ethernet/mediatek/airoha_eth.c

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,15 +2023,25 @@ static irqreturn_t airoha_irq_handler(int irq, void *dev_instance)
20232023
}
20242024

20252025
static int airoha_qdma_init(struct platform_device *pdev,
2026-
struct airoha_eth *eth)
2026+
struct airoha_eth *eth,
2027+
struct airoha_qdma *qdma)
20272028
{
2028-
struct airoha_qdma *qdma = &eth->qdma[0];
2029-
int err;
2029+
int err, id = qdma - &eth->qdma[0];
2030+
const char *res;
20302031

20312032
spin_lock_init(&qdma->irq_lock);
20322033
qdma->eth = eth;
20332034

2034-
qdma->irq = platform_get_irq(pdev, 0);
2035+
res = devm_kasprintf(eth->dev, GFP_KERNEL, "qdma%d", id);
2036+
if (!res)
2037+
return -ENOMEM;
2038+
2039+
qdma->regs = devm_platform_ioremap_resource_byname(pdev, res);
2040+
if (IS_ERR(qdma->regs))
2041+
return dev_err_probe(eth->dev, PTR_ERR(qdma->regs),
2042+
"failed to iomap qdma%d regs\n", id);
2043+
2044+
qdma->irq = platform_get_irq(pdev, 4 * id);
20352045
if (qdma->irq < 0)
20362046
return qdma->irq;
20372047

@@ -2052,19 +2062,13 @@ static int airoha_qdma_init(struct platform_device *pdev,
20522062
if (err)
20532063
return err;
20542064

2055-
err = airoha_qdma_hw_init(qdma);
2056-
if (err)
2057-
return err;
2058-
2059-
set_bit(DEV_STATE_INITIALIZED, &eth->state);
2060-
2061-
return 0;
2065+
return airoha_qdma_hw_init(qdma);
20622066
}
20632067

20642068
static int airoha_hw_init(struct platform_device *pdev,
20652069
struct airoha_eth *eth)
20662070
{
2067-
int err;
2071+
int err, i;
20682072

20692073
/* disable xsi */
20702074
reset_control_bulk_assert(ARRAY_SIZE(eth->xsi_rsts), eth->xsi_rsts);
@@ -2078,12 +2082,19 @@ static int airoha_hw_init(struct platform_device *pdev,
20782082
if (err)
20792083
return err;
20802084

2081-
return airoha_qdma_init(pdev, eth);
2085+
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++) {
2086+
err = airoha_qdma_init(pdev, eth, &eth->qdma[i]);
2087+
if (err)
2088+
return err;
2089+
}
2090+
2091+
set_bit(DEV_STATE_INITIALIZED, &eth->state);
2092+
2093+
return 0;
20822094
}
20832095

2084-
static void airoha_hw_cleanup(struct airoha_eth *eth)
2096+
static void airoha_hw_cleanup(struct airoha_qdma *qdma)
20852097
{
2086-
struct airoha_qdma *qdma = &eth->qdma[0];
20872098
int i;
20882099

20892100
for (i = 0; i < ARRAY_SIZE(qdma->q_rx); i++) {
@@ -2644,13 +2655,6 @@ static int airoha_probe(struct platform_device *pdev)
26442655
return dev_err_probe(eth->dev, PTR_ERR(eth->fe_regs),
26452656
"failed to iomap fe regs\n");
26462657

2647-
eth->qdma[0].regs = devm_platform_ioremap_resource_byname(pdev,
2648-
"qdma0");
2649-
if (IS_ERR(eth->qdma[0].regs))
2650-
return dev_err_probe(eth->dev,
2651-
PTR_ERR(eth->qdma[0].regs),
2652-
"failed to iomap qdma regs\n");
2653-
26542658
eth->rsts[0].id = "fe";
26552659
eth->rsts[1].id = "pdma";
26562660
eth->rsts[2].id = "qdma";
@@ -2706,7 +2710,9 @@ static int airoha_probe(struct platform_device *pdev)
27062710
return 0;
27072711

27082712
error:
2709-
airoha_hw_cleanup(eth);
2713+
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
2714+
airoha_hw_cleanup(&eth->qdma[i]);
2715+
27102716
for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
27112717
struct airoha_gdm_port *port = eth->ports[i];
27122718

@@ -2724,7 +2730,9 @@ static void airoha_remove(struct platform_device *pdev)
27242730
struct airoha_eth *eth = platform_get_drvdata(pdev);
27252731
int i;
27262732

2727-
airoha_hw_cleanup(eth);
2733+
for (i = 0; i < ARRAY_SIZE(eth->qdma); i++)
2734+
airoha_hw_cleanup(&eth->qdma[i]);
2735+
27282736
for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
27292737
struct airoha_gdm_port *port = eth->ports[i];
27302738

0 commit comments

Comments
 (0)