* [PATCH V4 0/4] net-next: mediatek: improve phy support
@ 2016-06-03 8:17 John Crispin
2016-06-03 8:17 ` [PATCH V4 1/4] net-next: mediatek: use mdiobus_free() in favour of kfree() John Crispin
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: John Crispin @ 2016-06-03 8:17 UTC (permalink / raw)
To: David S. Miller
Cc: Felix Fietkau, Sean Wang, netdev, linux-mediatek, linux-kernel,
John Crispin
The current driver did not handle the RGMII delay modes and asymmetric flow
control properly. The mii_bus is not freed properly. Also add support for
fixed-phy allowing the driver to work on SoCs that have an internal gigabit
switch.
John Crispin (4):
net-next: mediatek: use mdiobus_free() in favour of kfree()
net-next: mediatek: fix gigabit and flow control advertisement
net-next: mediatek: add fixed-phy support
net-next: mediatek: properly handle RGMII modes
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 40 +++++++++++++++++++++++----
1 file changed, 34 insertions(+), 6 deletions(-)
--
1.7.10.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH V4 1/4] net-next: mediatek: use mdiobus_free() in favour of kfree()
2016-06-03 8:17 [PATCH V4 0/4] net-next: mediatek: improve phy support John Crispin
@ 2016-06-03 8:17 ` John Crispin
2016-06-03 8:17 ` [PATCH V4 2/4] net-next: mediatek: fix gigabit and flow control advertisement John Crispin
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: John Crispin @ 2016-06-03 8:17 UTC (permalink / raw)
To: David S. Miller
Cc: Felix Fietkau, Sean Wang, netdev, linux-mediatek, linux-kernel,
John Crispin
The driver currently uses kfree() to clear the mii_bus. This is not the
correct way to clear the memory and mdiobus_free() should be used instead.
This patch fixes the two instances where this happens in the driver.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: John Crispin <john@phrozen.org>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index c984462..28f169f 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -280,7 +280,7 @@ static int mtk_mdio_init(struct mtk_eth *eth)
return 0;
err_free_bus:
- kfree(eth->mii_bus);
+ mdiobus_free(eth->mii_bus);
err_put_node:
of_node_put(mii_np);
@@ -295,7 +295,7 @@ static void mtk_mdio_cleanup(struct mtk_eth *eth)
mdiobus_unregister(eth->mii_bus);
of_node_put(eth->mii_bus->dev.of_node);
- kfree(eth->mii_bus);
+ mdiobus_free(eth->mii_bus);
}
static inline void mtk_irq_disable(struct mtk_eth *eth, u32 mask)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH V4 2/4] net-next: mediatek: fix gigabit and flow control advertisement
2016-06-03 8:17 [PATCH V4 0/4] net-next: mediatek: improve phy support John Crispin
2016-06-03 8:17 ` [PATCH V4 1/4] net-next: mediatek: use mdiobus_free() in favour of kfree() John Crispin
@ 2016-06-03 8:17 ` John Crispin
2016-06-03 8:17 ` [PATCH V4 3/4] net-next: mediatek: add fixed-phy support John Crispin
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: John Crispin @ 2016-06-03 8:17 UTC (permalink / raw)
To: David S. Miller
Cc: Felix Fietkau, Sean Wang, netdev, linux-mediatek, linux-kernel,
John Crispin
The current code will not setup the PHYs advertisement features correctly.
Fix this and properly advertise Gigabit features and properly handle
asymmetric pause frames.
Signed-off-by: Sean Wang <keyhaede@gmail.com>
Signed-off-by: John Crispin <john@phrozen.org>
---
Changes in V4
* set SUPPORTED_Asym_Pause rather than clearing it
* add debug code
* only setup asym if we are in full duplex
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 30 +++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 28f169f..b0652f6 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -133,6 +133,8 @@ static int mtk_mdio_read(struct mii_bus *bus, int phy_addr, int phy_reg)
static void mtk_phy_link_adjust(struct net_device *dev)
{
struct mtk_mac *mac = netdev_priv(dev);
+ u16 lcl_adv = 0, rmt_adv = 0;
+ u8 flowctrl;
u32 mcr = MAC_MCR_MAX_RX_1536 | MAC_MCR_IPG_CFG |
MAC_MCR_FORCE_MODE | MAC_MCR_TX_EN |
MAC_MCR_RX_EN | MAC_MCR_BACKOFF_EN |
@@ -150,11 +152,30 @@ static void mtk_phy_link_adjust(struct net_device *dev)
if (mac->phy_dev->link)
mcr |= MAC_MCR_FORCE_LINK;
- if (mac->phy_dev->duplex)
+ if (mac->phy_dev->duplex) {
mcr |= MAC_MCR_FORCE_DPX;
- if (mac->phy_dev->pause)
- mcr |= MAC_MCR_FORCE_RX_FC | MAC_MCR_FORCE_TX_FC;
+ if (mac->phy_dev->pause)
+ rmt_adv = LPA_PAUSE_CAP;
+ if (mac->phy_dev->asym_pause)
+ rmt_adv |= LPA_PAUSE_ASYM;
+
+ if (mac->phy_dev->advertising & ADVERTISED_Pause)
+ lcl_adv |= ADVERTISE_PAUSE_CAP;
+ if (mac->phy_dev->advertising & ADVERTISED_Asym_Pause)
+ lcl_adv |= ADVERTISE_PAUSE_ASYM;
+
+ flowctrl = mii_resolve_flowctrl_fdx(lcl_adv, rmt_adv);
+
+ if (flowctrl & FLOW_CTRL_TX)
+ mcr |= MAC_MCR_FORCE_TX_FC;
+ if (flowctrl & FLOW_CTRL_RX)
+ mcr |= MAC_MCR_FORCE_RX_FC;
+
+ netif_dbg(mac->hw, link, dev, "rx pause %s, tx pause %s\n",
+ flowctrl & FLOW_CTRL_RX ? "enabled" : "disabled",
+ flowctrl & FLOW_CTRL_TX ? "enabled" : "disabled");
+ }
mtk_w32(mac->hw, mcr, MTK_MAC_MCR(mac->id));
@@ -236,7 +257,8 @@ static int mtk_phy_connect(struct mtk_mac *mac)
mac->phy_dev->autoneg = AUTONEG_ENABLE;
mac->phy_dev->speed = 0;
mac->phy_dev->duplex = 0;
- mac->phy_dev->supported &= PHY_BASIC_FEATURES;
+ mac->phy_dev->supported &= PHY_GBIT_FEATURES | SUPPORTED_Pause |
+ SUPPORTED_Asym_Pause;
mac->phy_dev->advertising = mac->phy_dev->supported |
ADVERTISED_Autoneg;
phy_start_aneg(mac->phy_dev);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH V4 3/4] net-next: mediatek: add fixed-phy support
2016-06-03 8:17 [PATCH V4 0/4] net-next: mediatek: improve phy support John Crispin
2016-06-03 8:17 ` [PATCH V4 1/4] net-next: mediatek: use mdiobus_free() in favour of kfree() John Crispin
2016-06-03 8:17 ` [PATCH V4 2/4] net-next: mediatek: fix gigabit and flow control advertisement John Crispin
@ 2016-06-03 8:17 ` John Crispin
2016-06-03 8:17 ` [PATCH V4 4/4] net-next: mediatek: properly handle RGMII modes John Crispin
2016-06-03 23:54 ` [PATCH V4 0/4] net-next: mediatek: improve phy support David Miller
4 siblings, 0 replies; 6+ messages in thread
From: John Crispin @ 2016-06-03 8:17 UTC (permalink / raw)
To: David S. Miller
Cc: Felix Fietkau, Sean Wang, netdev, linux-mediatek, linux-kernel,
John Crispin
The MT7623 SoC has a builtin gigabit switch. If we want to use it, GMAC1
needs to be configured using a fixed link speed and flow control settings.
The easiest way to do this is to used the fixed-phy driver, allowing us to
reuse the existing mdio polling code to setup the MAC.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: John Crispin <john@phrozen.org>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index b0652f6..231d284 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -229,6 +229,9 @@ static int mtk_phy_connect(struct mtk_mac *mac)
u32 val, ge_mode;
np = of_parse_phandle(mac->of_node, "phy-handle", 0);
+ if (!np && of_phy_is_fixed_link(mac->of_node))
+ if (!of_phy_register_fixed_link(mac->of_node))
+ np = of_node_get(mac->of_node);
if (!np)
return -ENODEV;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH V4 4/4] net-next: mediatek: properly handle RGMII modes
2016-06-03 8:17 [PATCH V4 0/4] net-next: mediatek: improve phy support John Crispin
` (2 preceding siblings ...)
2016-06-03 8:17 ` [PATCH V4 3/4] net-next: mediatek: add fixed-phy support John Crispin
@ 2016-06-03 8:17 ` John Crispin
2016-06-03 23:54 ` [PATCH V4 0/4] net-next: mediatek: improve phy support David Miller
4 siblings, 0 replies; 6+ messages in thread
From: John Crispin @ 2016-06-03 8:17 UTC (permalink / raw)
To: David S. Miller
Cc: Felix Fietkau, Sean Wang, netdev, linux-mediatek, linux-kernel,
John Crispin
If an external Gigabit PHY is connected to either of the MACs we need to
be able to tell the PHY to use a delay. Not doing so will result in heavy
packet loss and/or data corruption when using PHYs such as the IC+ IP1001.
We tell the PHY which MII delay mode to use via the devictree.
The ethernet driver needs to be adapted to handle all 3 rgmii-*id modes
in the same way as normal rgmii when setting up the MAC.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: John Crispin <john@phrozen.org>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 231d284..4763252 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -236,6 +236,9 @@ static int mtk_phy_connect(struct mtk_mac *mac)
return -ENODEV;
switch (of_get_phy_mode(np)) {
+ case PHY_INTERFACE_MODE_RGMII_TXID:
+ case PHY_INTERFACE_MODE_RGMII_RXID:
+ case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII:
ge_mode = 0;
break;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH V4 0/4] net-next: mediatek: improve phy support
2016-06-03 8:17 [PATCH V4 0/4] net-next: mediatek: improve phy support John Crispin
` (3 preceding siblings ...)
2016-06-03 8:17 ` [PATCH V4 4/4] net-next: mediatek: properly handle RGMII modes John Crispin
@ 2016-06-03 23:54 ` David Miller
4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2016-06-03 23:54 UTC (permalink / raw)
To: john; +Cc: nbd, keyhaede, netdev, linux-mediatek, linux-kernel
From: John Crispin <john@phrozen.org>
Date: Fri, 3 Jun 2016 10:17:05 +0200
> The current driver did not handle the RGMII delay modes and asymmetric flow
> control properly. The mii_bus is not freed properly. Also add support for
> fixed-phy allowing the driver to work on SoCs that have an internal gigabit
> switch.
Series applied, thanks John.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-06-03 23:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-03 8:17 [PATCH V4 0/4] net-next: mediatek: improve phy support John Crispin
2016-06-03 8:17 ` [PATCH V4 1/4] net-next: mediatek: use mdiobus_free() in favour of kfree() John Crispin
2016-06-03 8:17 ` [PATCH V4 2/4] net-next: mediatek: fix gigabit and flow control advertisement John Crispin
2016-06-03 8:17 ` [PATCH V4 3/4] net-next: mediatek: add fixed-phy support John Crispin
2016-06-03 8:17 ` [PATCH V4 4/4] net-next: mediatek: properly handle RGMII modes John Crispin
2016-06-03 23:54 ` [PATCH V4 0/4] net-next: mediatek: improve phy support David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).