0078-net-next-mediatek-fix-gigabit-and-flow-control-adver.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. From 09313f26999e2685e0b9434374e7308e1f447e55 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <john@phrozen.org>
  3. Date: Fri, 22 Apr 2016 11:05:23 +0200
  4. Subject: [PATCH 078/102] net-next: mediatek: fix gigabit and flow control
  5. advertisement
  6. The current code will not setup the PHYs advertisement features correctly.
  7. Fix this and properly advertise Gigabit features and properly handle
  8. asymmetric pause frames.
  9. Signed-off-by: Sean Wang <keyhaede@gmail.com>
  10. Signed-off-by: John Crispin <john@phrozen.org>
  11. ---
  12. drivers/net/ethernet/mediatek/mtk_eth_soc.c | 30 +++++++++++++++++++++++----
  13. 1 file changed, 26 insertions(+), 4 deletions(-)
  14. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  15. +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  16. @@ -133,6 +133,8 @@ static int mtk_mdio_read(struct mii_bus
  17. static void mtk_phy_link_adjust(struct net_device *dev)
  18. {
  19. struct mtk_mac *mac = netdev_priv(dev);
  20. + u16 lcl_adv = 0, rmt_adv = 0;
  21. + u8 flowctrl;
  22. u32 mcr = MAC_MCR_MAX_RX_1536 | MAC_MCR_IPG_CFG |
  23. MAC_MCR_FORCE_MODE | MAC_MCR_TX_EN |
  24. MAC_MCR_RX_EN | MAC_MCR_BACKOFF_EN |
  25. @@ -150,11 +152,30 @@ static void mtk_phy_link_adjust(struct n
  26. if (mac->phy_dev->link)
  27. mcr |= MAC_MCR_FORCE_LINK;
  28. - if (mac->phy_dev->duplex)
  29. + if (mac->phy_dev->duplex) {
  30. mcr |= MAC_MCR_FORCE_DPX;
  31. - if (mac->phy_dev->pause)
  32. - mcr |= MAC_MCR_FORCE_RX_FC | MAC_MCR_FORCE_TX_FC;
  33. + if (mac->phy_dev->pause)
  34. + rmt_adv = LPA_PAUSE_CAP;
  35. + if (mac->phy_dev->asym_pause)
  36. + rmt_adv |= LPA_PAUSE_ASYM;
  37. +
  38. + if (mac->phy_dev->advertising & ADVERTISED_Pause)
  39. + lcl_adv |= ADVERTISE_PAUSE_CAP;
  40. + if (mac->phy_dev->advertising & ADVERTISED_Asym_Pause)
  41. + lcl_adv |= ADVERTISE_PAUSE_ASYM;
  42. +
  43. + flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
  44. +
  45. + if (flowctrl & FLOW_CTRL_TX)
  46. + mcr |= MAC_MCR_FORCE_TX_FC;
  47. + if (flowctrl & FLOW_CTRL_RX)
  48. + mcr |= MAC_MCR_FORCE_RX_FC;
  49. +
  50. + netif_dbg(mac->hw, link, dev, "rx pause %s, tx pause %s\n",
  51. + flowctrl & FLOW_CTRL_RX ? "enabled" : "disabled",
  52. + flowctrl & FLOW_CTRL_TX ? "enabled" : "disabled");
  53. + }
  54. mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id));
  55. @@ -236,7 +257,8 @@ static int mtk_phy_connect(struct mtk_ma
  56. mac->phy_dev->autoneg = AUTONEG_ENABLE;
  57. mac->phy_dev->speed = 0;
  58. mac->phy_dev->duplex = 0;
  59. - mac->phy_dev->supported &= PHY_BASIC_FEATURES;
  60. + mac->phy_dev->supported &= PHY_GBIT_FEATURES | SUPPORTED_Pause |
  61. + SUPPORTED_Asym_Pause;
  62. mac->phy_dev->advertising = mac->phy_dev->supported |
  63. ADVERTISED_Autoneg;
  64. phy_start_aneg(mac->phy_dev);