0016-net-macb-Fix-check-for-little-endian-system-in.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From a30c65f4d5478eb53f267d71623ff2721c6f4c3d Mon Sep 17 00:00:00 2001
  2. From: Anup Patel <anup.patel@wdc.com>
  3. Date: Tue, 25 Jun 2019 11:50:05 +0530
  4. Subject: [PATCH 16/21] net: macb: Fix check for little-endian system in
  5. gmac_configure_dma()
  6. Instead of depending on CONFIG_SYS_LITTLE_ENDIAN, we check at runtime
  7. whether underlying system is little-endian or big-endian. This way
  8. we are not dependent on any U-Boot specific OR compiler specific macro
  9. to check system endianness.
  10. Signed-off-by: Anup Patel <anup.patel@wdc.com>
  11. Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
  12. Reviewed-By: Ramon Fried <rfried.dev@gmail.com>
  13. Upstream-Status: Submitted
  14. ---
  15. drivers/net/macb.c | 12 ++++++++----
  16. 1 file changed, 8 insertions(+), 4 deletions(-)
  17. diff --git a/drivers/net/macb.c b/drivers/net/macb.c
  18. index 322302762a..a4015e9bd5 100644
  19. --- a/drivers/net/macb.c
  20. +++ b/drivers/net/macb.c
  21. @@ -84,6 +84,8 @@ struct macb_dma_desc {
  22. struct macb_device {
  23. void *regs;
  24. + bool is_big_endian;
  25. +
  26. const struct macb_config*config;
  27. unsigned int rx_tail;
  28. @@ -743,11 +745,10 @@ static void gmac_configure_dma(struct macb_device *macb)
  29. dmacfg |= GEM_BIT(TXPBMS) | GEM_BF(RXBMS, -1L);
  30. dmacfg &= ~GEM_BIT(ENDIA_PKT);
  31. -#ifdef CONFIG_SYS_LITTLE_ENDIAN
  32. - dmacfg &= ~GEM_BIT(ENDIA_DESC);
  33. -#else
  34. + if (macb->is_big_endian)
  35. dmacfg |= GEM_BIT(ENDIA_DESC); /* CPU in big endian */
  36. -#endif
  37. + else
  38. + dmacfg &= ~GEM_BIT(ENDIA_DESC);
  39. dmacfg &= ~GEM_BIT(ADDR64);
  40. gem_writel(macb, DMACFG, dmacfg);
  41. @@ -1221,6 +1222,9 @@ static int macb_eth_probe(struct udevice *dev)
  42. macb->regs = (void *)pdata->iobase;
  43. + macb->is_big_endian = (cpu_to_be32(0x12345678) == 0x12345678) ?
  44. + true : false;
  45. +
  46. macb->config = (struct macb_config *)dev_get_driver_data(dev);
  47. if (!macb->config)
  48. macb->config = &default_gem_config;
  49. --
  50. 2.22.0