0007-net-macb-apply-sane-DMA-configuration.patch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. From a9a63c1e906eecd9864ce016cdfcf0b867ae451d Mon Sep 17 00:00:00 2001
  2. From: Ramon Fried <rfried.dev@gmail.com>
  3. Date: Tue, 11 Jun 2019 18:19:30 +0300
  4. Subject: [PATCH 07/21] net: macb: apply sane DMA configuration
  5. DMA configuration was heavily dependent on the HW
  6. defaults, add function to properly set the required
  7. fields, including the new dma_burst_length.
  8. Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
  9. Upstream-Status: Submitted
  10. ---
  11. drivers/net/macb.c | 28 ++++++++++++++++++++++++++++
  12. 1 file changed, 28 insertions(+)
  13. diff --git a/drivers/net/macb.c b/drivers/net/macb.c
  14. index fb42172520..c072f99d8f 100644
  15. --- a/drivers/net/macb.c
  16. +++ b/drivers/net/macb.c
  17. @@ -47,6 +47,7 @@ DECLARE_GLOBAL_DATA_PTR;
  18. #define MACB_RX_BUFFER_SIZE 4096
  19. #define MACB_RX_RING_SIZE (MACB_RX_BUFFER_SIZE / 128)
  20. +#define RX_BUFFER_MULTIPLE 64
  21. #define MACB_TX_RING_SIZE 16
  22. #define MACB_TX_TIMEOUT 1000
  23. #define MACB_AUTONEG_TIMEOUT 5000000
  24. @@ -695,6 +696,31 @@ static int gmac_init_multi_queues(struct macb_device *macb)
  25. return 0;
  26. }
  27. +static void gmac_configure_dma(struct macb_device *macb)
  28. +{
  29. + u32 buffer_size;
  30. + u32 dmacfg;
  31. +
  32. + buffer_size = 128 / RX_BUFFER_MULTIPLE;
  33. + dmacfg = gem_readl(macb, DMACFG) & ~GEM_BF(RXBS, -1L);
  34. + dmacfg |= GEM_BF(RXBS, buffer_size);
  35. +
  36. + if (macb->dma_burst_length)
  37. + dmacfg = GEM_BFINS(FBLDO, macb->dma_burst_length, dmacfg);
  38. +
  39. + dmacfg |= GEM_BIT(TXPBMS) | GEM_BF(RXBMS, -1L);
  40. + dmacfg &= ~GEM_BIT(ENDIA_PKT);
  41. +
  42. +#ifdef CONFIG_SYS_LITTLE_ENDIAN
  43. + dmacfg &= ~GEM_BIT(ENDIA_DESC);
  44. +#else
  45. + dmacfg |= GEM_BIT(ENDIA_DESC); /* CPU in big endian */
  46. +#endif
  47. +
  48. + dmacfg &= ~GEM_BIT(ADDR64);
  49. + gem_writel(macb, DMACFG, dmacfg);
  50. +}
  51. +
  52. #ifdef CONFIG_DM_ETH
  53. static int _macb_init(struct udevice *dev, const char *name)
  54. #else
  55. @@ -748,6 +774,8 @@ static int _macb_init(struct macb_device *macb, const char *name)
  56. macb_writel(macb, TBQP, macb->tx_ring_dma);
  57. if (macb_is_gem(macb)) {
  58. + /* Initialize DMA properties */
  59. + gmac_configure_dma(macb);
  60. /* Check the multi queue and initialize the queue for tx */
  61. gmac_init_multi_queues(macb);
  62. --
  63. 2.22.0