Message ID | 1573455341-22813-5-git-send-email-wahrenst@gmx.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ARM: Enable GENET support for RPi 4 | expand |
On 11/11/2019 07:55, Stefan Wahren wrote: > 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 <wahrenst@gmx.net> > Acked-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Matthias Brugger <mbrugger@suse.com> > =2D-- > drivers/net/ethernet/broadcom/genet/bcmgenet.c | 63 +++++++++++++++++++++= > +---- > drivers/net/ethernet/broadcom/genet/bcmgenet.h | 1 + > 2 files changed, 54 insertions(+), 10 deletions(-) > > diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/= > ethernet/broadcom/genet/bcmgenet.c > index ee4d8ef..120fa05 100644 > =2D-- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c > +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c > @@ -2576,7 +2576,8 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *p= > riv) > } > > /* Init rDma */ > - bcmgenet_rdma_writel(priv, DMA_MAX_BURST_LENGTH, DMA_SCB_BURST_SIZE); > + bcmgenet_rdma_writel(priv, priv->dma_max_burst_length, > + DMA_SCB_BURST_SIZE); > > /* Initialize Rx queues */ > ret =3D bcmgenet_init_rx_queues(priv->dev); > @@ -2589,7 +2590,8 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *p= > riv) > } > > /* Init tDma */ > - bcmgenet_tdma_writel(priv, DMA_MAX_BURST_LENGTH, DMA_SCB_BURST_SIZE); > + bcmgenet_tdma_writel(priv, priv->dma_max_burst_length, > + DMA_SCB_BURST_SIZE); > > /* Initialize Tx queues */ > bcmgenet_init_tx_queues(priv->dev); > @@ -3420,12 +3422,48 @@ static void bcmgenet_set_hw_params(struct bcmgenet= > _priv *priv) > params->words_per_bd); > } > > +struct bcmgenet_plat_data { > + enum bcmgenet_version version; > + u32 dma_max_burst_length; > +}; > + > +static const struct bcmgenet_plat_data v1_plat_data =3D { > + .version =3D GENET_V1, > + .dma_max_burst_length =3D DMA_MAX_BURST_LENGTH, > +}; > + > +static const struct bcmgenet_plat_data v2_plat_data =3D { > + .version =3D GENET_V2, > + .dma_max_burst_length =3D DMA_MAX_BURST_LENGTH, > +}; > + > +static const struct bcmgenet_plat_data v3_plat_data =3D { > + .version =3D GENET_V3, > + .dma_max_burst_length =3D DMA_MAX_BURST_LENGTH, > +}; > + > +static const struct bcmgenet_plat_data v4_plat_data =3D { > + .version =3D GENET_V4, > + .dma_max_burst_length =3D DMA_MAX_BURST_LENGTH, > +}; > + > +static const struct bcmgenet_plat_data v5_plat_data =3D { > + .version =3D GENET_V5, > + .dma_max_burst_length =3D DMA_MAX_BURST_LENGTH, > +}; > + > +static const struct bcmgenet_plat_data bcm2711_plat_data =3D { > + .version =3D GENET_V5, > + .dma_max_burst_length =3D 0x08, > +}; > + > static const struct of_device_id bcmgenet_match[] =3D { > - { .compatible =3D "brcm,genet-v1", .data =3D (void *)GENET_V1 }, > - { .compatible =3D "brcm,genet-v2", .data =3D (void *)GENET_V2 }, > - { .compatible =3D "brcm,genet-v3", .data =3D (void *)GENET_V3 }, > - { .compatible =3D "brcm,genet-v4", .data =3D (void *)GENET_V4 }, > - { .compatible =3D "brcm,genet-v5", .data =3D (void *)GENET_V5 }, > + { .compatible =3D "brcm,genet-v1", .data =3D &v1_plat_data }, > + { .compatible =3D "brcm,genet-v2", .data =3D &v2_plat_data }, > + { .compatible =3D "brcm,genet-v3", .data =3D &v3_plat_data }, > + { .compatible =3D "brcm,genet-v4", .data =3D &v4_plat_data }, > + { .compatible =3D "brcm,genet-v5", .data =3D &v5_plat_data }, > + { .compatible =3D "brcm,bcm2711-genet-v5", .data =3D &bcm2711_plat_data = > }, > { }, > }; > MODULE_DEVICE_TABLE(of, bcmgenet_match); > @@ -3435,6 +3473,7 @@ static int bcmgenet_probe(struct platform_device *pd= > ev) > struct bcmgenet_platform_data *pd =3D pdev->dev.platform_data; > struct device_node *dn =3D pdev->dev.of_node; > const struct of_device_id *of_id =3D NULL; > + const struct bcmgenet_plat_data *pdata; > struct bcmgenet_priv *priv; > struct net_device *dev; > const void *macaddr; > @@ -3516,10 +3555,14 @@ static int bcmgenet_probe(struct platform_device *= > pdev) > > priv->dev =3D dev; > priv->pdev =3D pdev; > - if (of_id) > - priv->version =3D (enum bcmgenet_version)of_id->data; > - else > + if (of_id) { > + pdata =3D of_id->data; > + priv->version =3D pdata->version; > + priv->dma_max_burst_length =3D pdata->dma_max_burst_length; > + } else { > priv->version =3D pd->genet_version; > + priv->dma_max_burst_length =3D DMA_MAX_BURST_LENGTH; > + } > > priv->clk =3D devm_clk_get(&priv->pdev->dev, "enet"); > if (IS_ERR(priv->clk)) { > diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/= > ethernet/broadcom/genet/bcmgenet.h > index dbc69d8..a565919 100644 > =2D-- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h > +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h > @@ -664,6 +664,7 @@ struct bcmgenet_priv { > bool crc_fwd_en; > > unsigned int dma_rx_chk_bit; > + u32 dma_max_burst_length; > > u32 msg_enable; > > =2D- > 2.7.4 >
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index ee4d8ef..120fa05 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c @@ -2576,7 +2576,8 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *priv) } /* Init rDma */ - bcmgenet_rdma_writel(priv, DMA_MAX_BURST_LENGTH, DMA_SCB_BURST_SIZE); + bcmgenet_rdma_writel(priv, priv->dma_max_burst_length, + DMA_SCB_BURST_SIZE); /* Initialize Rx queues */ ret = bcmgenet_init_rx_queues(priv->dev); @@ -2589,7 +2590,8 @@ static int bcmgenet_init_dma(struct bcmgenet_priv *priv) } /* Init tDma */ - bcmgenet_tdma_writel(priv, DMA_MAX_BURST_LENGTH, DMA_SCB_BURST_SIZE); + bcmgenet_tdma_writel(priv, priv->dma_max_burst_length, + DMA_SCB_BURST_SIZE); /* Initialize Tx queues */ bcmgenet_init_tx_queues(priv->dev); @@ -3420,12 +3422,48 @@ static void bcmgenet_set_hw_params(struct bcmgenet_priv *priv) params->words_per_bd); } +struct bcmgenet_plat_data { + enum bcmgenet_version version; + u32 dma_max_burst_length; +}; + +static const struct bcmgenet_plat_data v1_plat_data = { + .version = GENET_V1, + .dma_max_burst_length = DMA_MAX_BURST_LENGTH, +}; + +static const struct bcmgenet_plat_data v2_plat_data = { + .version = GENET_V2, + .dma_max_burst_length = DMA_MAX_BURST_LENGTH, +}; + +static const struct bcmgenet_plat_data v3_plat_data = { + .version = GENET_V3, + .dma_max_burst_length = DMA_MAX_BURST_LENGTH, +}; + +static const struct bcmgenet_plat_data v4_plat_data = { + .version = GENET_V4, + .dma_max_burst_length = DMA_MAX_BURST_LENGTH, +}; + +static const struct bcmgenet_plat_data v5_plat_data = { + .version = GENET_V5, + .dma_max_burst_length = DMA_MAX_BURST_LENGTH, +}; + +static const struct bcmgenet_plat_data bcm2711_plat_data = { + .version = GENET_V5, + .dma_max_burst_length = 0x08, +}; + static const struct of_device_id bcmgenet_match[] = { - { .compatible = "brcm,genet-v1", .data = (void *)GENET_V1 }, - { .compatible = "brcm,genet-v2", .data = (void *)GENET_V2 }, - { .compatible = "brcm,genet-v3", .data = (void *)GENET_V3 }, - { .compatible = "brcm,genet-v4", .data = (void *)GENET_V4 }, - { .compatible = "brcm,genet-v5", .data = (void *)GENET_V5 }, + { .compatible = "brcm,genet-v1", .data = &v1_plat_data }, + { .compatible = "brcm,genet-v2", .data = &v2_plat_data }, + { .compatible = "brcm,genet-v3", .data = &v3_plat_data }, + { .compatible = "brcm,genet-v4", .data = &v4_plat_data }, + { .compatible = "brcm,genet-v5", .data = &v5_plat_data }, + { .compatible = "brcm,bcm2711-genet-v5", .data = &bcm2711_plat_data }, { }, }; MODULE_DEVICE_TABLE(of, bcmgenet_match); @@ -3435,6 +3473,7 @@ static int bcmgenet_probe(struct platform_device *pdev) struct bcmgenet_platform_data *pd = pdev->dev.platform_data; struct device_node *dn = pdev->dev.of_node; const struct of_device_id *of_id = NULL; + const struct bcmgenet_plat_data *pdata; struct bcmgenet_priv *priv; struct net_device *dev; const void *macaddr; @@ -3516,10 +3555,14 @@ static int bcmgenet_probe(struct platform_device *pdev) priv->dev = dev; priv->pdev = pdev; - if (of_id) - priv->version = (enum bcmgenet_version)of_id->data; - else + if (of_id) { + pdata = of_id->data; + priv->version = pdata->version; + priv->dma_max_burst_length = pdata->dma_max_burst_length; + } else { priv->version = pd->genet_version; + priv->dma_max_burst_length = DMA_MAX_BURST_LENGTH; + } priv->clk = devm_clk_get(&priv->pdev->dev, "enet"); if (IS_ERR(priv->clk)) { diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h index dbc69d8..a565919 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h @@ -664,6 +664,7 @@ struct bcmgenet_priv { bool crc_fwd_en; unsigned int dma_rx_chk_bit; + u32 dma_max_burst_length; u32 msg_enable;