Skip to content

Commit a50e3a9

Browse files
lategoodbyedavem330
authored andcommitted
net: bcmgenet: Add BCM2711 support
The BCM2711 needs a different maximum DMA burst length. If not set accordingly a timeout in the transmit queue happens and no package can be sent. So use the new compatible to derive this value. Until now the GENET HW version was used as the platform identifier. This doesn't work with SoC-specific modifications, so introduce a proper platform data structure. Signed-off-by: Stefan Wahren <[email protected]> Acked-by: Florian Fainelli <[email protected]> Reviewed-by: Matthias Brugger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f7bda51 commit a50e3a9

File tree

2 files changed

+54
-10
lines changed

2 files changed

+54
-10
lines changed

drivers/net/ethernet/broadcom/genet/bcmgenet.c

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,7 +2576,8 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *priv)
25762576
}
25772577

25782578
/* Init rDma */
2579-
bcmgenet_rdma_writel(priv, DMA_MAX_BURST_LENGTH, DMA_SCB_BURST_SIZE);
2579+
bcmgenet_rdma_writel(priv, priv->dma_max_burst_length,
2580+
DMA_SCB_BURST_SIZE);
25802581

25812582
/* Initialize Rx queues */
25822583
ret = bcmgenet_init_rx_queues(priv->dev);
@@ -2589,7 +2590,8 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *priv)
25892590
}
25902591

25912592
/* Init tDma */
2592-
bcmgenet_tdma_writel(priv, DMA_MAX_BURST_LENGTH, DMA_SCB_BURST_SIZE);
2593+
bcmgenet_tdma_writel(priv, priv->dma_max_burst_length,
2594+
DMA_SCB_BURST_SIZE);
25932595

25942596
/* Initialize Tx queues */
25952597
bcmgenet_init_tx_queues(priv->dev);
@@ -3420,12 +3422,48 @@ static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv)
34203422
params->words_per_bd);
34213423
}
34223424

3425+
struct bcmgenet_plat_data {
3426+
enum bcmgenet_version version;
3427+
u32 dma_max_burst_length;
3428+
};
3429+
3430+
static const struct bcmgenet_plat_data v1_plat_data = {
3431+
.version = GENET_V1,
3432+
.dma_max_burst_length = DMA_MAX_BURST_LENGTH,
3433+
};
3434+
3435+
static const struct bcmgenet_plat_data v2_plat_data = {
3436+
.version = GENET_V2,
3437+
.dma_max_burst_length = DMA_MAX_BURST_LENGTH,
3438+
};
3439+
3440+
static const struct bcmgenet_plat_data v3_plat_data = {
3441+
.version = GENET_V3,
3442+
.dma_max_burst_length = DMA_MAX_BURST_LENGTH,
3443+
};
3444+
3445+
static const struct bcmgenet_plat_data v4_plat_data = {
3446+
.version = GENET_V4,
3447+
.dma_max_burst_length = DMA_MAX_BURST_LENGTH,
3448+
};
3449+
3450+
static const struct bcmgenet_plat_data v5_plat_data = {
3451+
.version = GENET_V5,
3452+
.dma_max_burst_length = DMA_MAX_BURST_LENGTH,
3453+
};
3454+
3455+
static const struct bcmgenet_plat_data bcm2711_plat_data = {
3456+
.version = GENET_V5,
3457+
.dma_max_burst_length = 0x08,
3458+
};
3459+
34233460
static const struct of_device_id bcmgenet_match[] = {
3424-
{ .compatible = "brcm,genet-v1", .data = (void *)GENET_V1 },
3425-
{ .compatible = "brcm,genet-v2", .data = (void *)GENET_V2 },
3426-
{ .compatible = "brcm,genet-v3", .data = (void *)GENET_V3 },
3427-
{ .compatible = "brcm,genet-v4", .data = (void *)GENET_V4 },
3428-
{ .compatible = "brcm,genet-v5", .data = (void *)GENET_V5 },
3461+
{ .compatible = "brcm,genet-v1", .data = &v1_plat_data },
3462+
{ .compatible = "brcm,genet-v2", .data = &v2_plat_data },
3463+
{ .compatible = "brcm,genet-v3", .data = &v3_plat_data },
3464+
{ .compatible = "brcm,genet-v4", .data = &v4_plat_data },
3465+
{ .compatible = "brcm,genet-v5", .data = &v5_plat_data },
3466+
{ .compatible = "brcm,bcm2711-genet-v5", .data = &bcm2711_plat_data },
34293467
{ },
34303468
};
34313469
MODULE_DEVICE_TABLE(of, bcmgenet_match);
@@ -3435,6 +3473,7 @@ static int bcmgenet_probe(struct platform_device *pdev)
34353473
struct bcmgenet_platform_data *pd = pdev->dev.platform_data;
34363474
struct device_node *dn = pdev->dev.of_node;
34373475
const struct of_device_id *of_id = NULL;
3476+
const struct bcmgenet_plat_data *pdata;
34383477
struct bcmgenet_priv *priv;
34393478
struct net_device *dev;
34403479
const void *macaddr;
@@ -3516,10 +3555,14 @@ static int bcmgenet_probe(struct platform_device *pdev)
35163555

35173556
priv->dev = dev;
35183557
priv->pdev = pdev;
3519-
if (of_id)
3520-
priv->version = (enum bcmgenet_version)of_id->data;
3521-
else
3558+
if (of_id) {
3559+
pdata = of_id->data;
3560+
priv->version = pdata->version;
3561+
priv->dma_max_burst_length = pdata->dma_max_burst_length;
3562+
} else {
35223563
priv->version = pd->genet_version;
3564+
priv->dma_max_burst_length = DMA_MAX_BURST_LENGTH;
3565+
}
35233566

35243567
priv->clk = devm_clk_get(&priv->pdev->dev, "enet");
35253568
if (IS_ERR(priv->clk)) {

drivers/net/ethernet/broadcom/genet/bcmgenet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ struct bcmgenet_priv {
664664
bool crc_fwd_en;
665665

666666
unsigned int dma_rx_chk_bit;
667+
u32 dma_max_burst_length;
667668

668669
u32 msg_enable;
669670

0 commit comments

Comments
 (0)