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