[U-Boot] [PATCH 6/6] net: macb: apply sane DMA configuration
DMA configuration was heavily dependent on the HW defaults, add function to properly set the required fields, including the new dma_burst_length. Signed-off-by: Ramon Fried Reviewed-by: Anup Patel Tested-by: Anup Patel Acked-by: Joe Hershberger --- v2: nothing. drivers/net/macb.c | 28 1 file changed, 28 insertions(+) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index dc6aa6deda..035109dc43 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -47,6 +47,7 @@ DECLARE_GLOBAL_DATA_PTR; #define MACB_RX_BUFFER_SIZE4096 #define MACB_RX_RING_SIZE (MACB_RX_BUFFER_SIZE / 128) +#define RX_BUFFER_MULTIPLE 64 #define MACB_TX_RING_SIZE 16 #define MACB_TX_TIMEOUT1000 #define MACB_AUTONEG_TIMEOUT 500 @@ -697,6 +698,31 @@ static int gmac_init_multi_queues(struct macb_device *macb) return 0; } +static void gmac_configure_dma(struct macb_device *macb) +{ + u32 buffer_size; + u32 dmacfg; + + buffer_size = 128 / RX_BUFFER_MULTIPLE; + dmacfg = gem_readl(macb, DMACFG) & ~GEM_BF(RXBS, -1L); + dmacfg |= GEM_BF(RXBS, buffer_size); + + if (macb->dma_burst_length) + dmacfg = GEM_BFINS(FBLDO, macb->dma_burst_length, dmacfg); + + dmacfg |= GEM_BIT(TXPBMS) | GEM_BF(RXBMS, -1L); + dmacfg &= ~GEM_BIT(ENDIA_PKT); + +#ifdef CONFIG_SYS_LITTLE_ENDIAN + dmacfg &= ~GEM_BIT(ENDIA_DESC); +#else + dmacfg |= GEM_BIT(ENDIA_DESC); /* CPU in big endian */ +#endif + + dmacfg &= ~GEM_BIT(ADDR64); + gem_writel(macb, DMACFG, dmacfg); +} + #ifdef CONFIG_DM_ETH static int _macb_init(struct udevice *dev, const char *name) #else @@ -750,6 +776,8 @@ static int _macb_init(struct macb_device *macb, const char *name) macb_writel(macb, TBQP, macb->tx_ring_dma); if (macb_is_gem(macb)) { + /* Initialize DMA properties */ + gmac_configure_dma(macb); /* Check the multi queue and initialize the queue for tx */ gmac_init_multi_queues(macb); -- 2.22.0 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 6/6] net: macb: apply sane DMA configuration
On Tue, Jun 11, 2019 at 10:51 AM Ramon Fried wrote: > > DMA configuration was heavily dependent on the HW > defaults, add function to properly set the required > fields, including the new dma_burst_length. > > Signed-off-by: Ramon Fried Acked-by: Joe Hershberger ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH 6/6] net: macb: apply sane DMA configuration
> -Original Message- > From: U-Boot On Behalf Of Ramon Fried > Sent: Tuesday, June 11, 2019 8:50 PM > To: u-boot@lists.denx.de > Cc: Joe Hershberger > Subject: [U-Boot] [PATCH 6/6] net: macb: apply sane DMA configuration > > DMA configuration was heavily dependent on the HW defaults, add function > to properly set the required fields, including the new dma_burst_length. > > Signed-off-by: Ramon Fried > --- > > drivers/net/macb.c | 28 > 1 file changed, 28 insertions(+) > > diff --git a/drivers/net/macb.c b/drivers/net/macb.c index > fb42172520..c072f99d8f 100644 > --- a/drivers/net/macb.c > +++ b/drivers/net/macb.c > @@ -47,6 +47,7 @@ DECLARE_GLOBAL_DATA_PTR; > > #define MACB_RX_BUFFER_SIZE 4096 > #define MACB_RX_RING_SIZE(MACB_RX_BUFFER_SIZE / 128) > +#define RX_BUFFER_MULTIPLE 64 > #define MACB_TX_RING_SIZE16 > #define MACB_TX_TIMEOUT 1000 > #define MACB_AUTONEG_TIMEOUT 500 > @@ -695,6 +696,31 @@ static int gmac_init_multi_queues(struct > macb_device *macb) > return 0; > } > > +static void gmac_configure_dma(struct macb_device *macb) { > + u32 buffer_size; > + u32 dmacfg; > + > + buffer_size = 128 / RX_BUFFER_MULTIPLE; > + dmacfg = gem_readl(macb, DMACFG) & ~GEM_BF(RXBS, -1L); > + dmacfg |= GEM_BF(RXBS, buffer_size); > + > + if (macb->dma_burst_length) > + dmacfg = GEM_BFINS(FBLDO, macb->dma_burst_length, > dmacfg); > + > + dmacfg |= GEM_BIT(TXPBMS) | GEM_BF(RXBMS, -1L); > + dmacfg &= ~GEM_BIT(ENDIA_PKT); > + > +#ifdef CONFIG_SYS_LITTLE_ENDIAN > + dmacfg &= ~GEM_BIT(ENDIA_DESC); > +#else > + dmacfg |= GEM_BIT(ENDIA_DESC); /* CPU in big endian */ > #endif > + > + dmacfg &= ~GEM_BIT(ADDR64); > + gem_writel(macb, DMACFG, dmacfg); > +} > + > #ifdef CONFIG_DM_ETH > static int _macb_init(struct udevice *dev, const char *name) #else @@ - > 748,6 +774,8 @@ static int _macb_init(struct macb_device *macb, const char > *name) > macb_writel(macb, TBQP, macb->tx_ring_dma); > > if (macb_is_gem(macb)) { > + /* Initialize DMA properties */ > + gmac_configure_dma(macb); > /* Check the multi queue and initialize the queue for tx */ > gmac_init_multi_queues(macb); > > -- > 2.21.0 > > ___ > U-Boot mailing list > U-Boot@lists.denx.de > https://lists.denx.de/listinfo/u-boot Reviewed-by: Anup Patel Tested-by: Anup Patel Regards, Anup ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
[U-Boot] [PATCH 6/6] net: macb: apply sane DMA configuration
DMA configuration was heavily dependent on the HW defaults, add function to properly set the required fields, including the new dma_burst_length. Signed-off-by: Ramon Fried --- drivers/net/macb.c | 28 1 file changed, 28 insertions(+) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index fb42172520..c072f99d8f 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -47,6 +47,7 @@ DECLARE_GLOBAL_DATA_PTR; #define MACB_RX_BUFFER_SIZE4096 #define MACB_RX_RING_SIZE (MACB_RX_BUFFER_SIZE / 128) +#define RX_BUFFER_MULTIPLE 64 #define MACB_TX_RING_SIZE 16 #define MACB_TX_TIMEOUT1000 #define MACB_AUTONEG_TIMEOUT 500 @@ -695,6 +696,31 @@ static int gmac_init_multi_queues(struct macb_device *macb) return 0; } +static void gmac_configure_dma(struct macb_device *macb) +{ + u32 buffer_size; + u32 dmacfg; + + buffer_size = 128 / RX_BUFFER_MULTIPLE; + dmacfg = gem_readl(macb, DMACFG) & ~GEM_BF(RXBS, -1L); + dmacfg |= GEM_BF(RXBS, buffer_size); + + if (macb->dma_burst_length) + dmacfg = GEM_BFINS(FBLDO, macb->dma_burst_length, dmacfg); + + dmacfg |= GEM_BIT(TXPBMS) | GEM_BF(RXBMS, -1L); + dmacfg &= ~GEM_BIT(ENDIA_PKT); + +#ifdef CONFIG_SYS_LITTLE_ENDIAN + dmacfg &= ~GEM_BIT(ENDIA_DESC); +#else + dmacfg |= GEM_BIT(ENDIA_DESC); /* CPU in big endian */ +#endif + + dmacfg &= ~GEM_BIT(ADDR64); + gem_writel(macb, DMACFG, dmacfg); +} + #ifdef CONFIG_DM_ETH static int _macb_init(struct udevice *dev, const char *name) #else @@ -748,6 +774,8 @@ static int _macb_init(struct macb_device *macb, const char *name) macb_writel(macb, TBQP, macb->tx_ring_dma); if (macb_is_gem(macb)) { + /* Initialize DMA properties */ + gmac_configure_dma(macb); /* Check the multi queue and initialize the queue for tx */ gmac_init_multi_queues(macb); -- 2.21.0 ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot