mirror of https://lore.kernel.org/linux-amlogic/
 help / color / mirror / Atom feed
* [PATCH 0/2] net: phy: realtek: fix RTL8211F TX-delay handling
@ 2016-11-25 13:11 Martin Blumenstingl
  2016-11-25 13:12 ` [PATCH 1/2] Documentation: devicetree: clarify usage of the RGMII phy-modes Martin Blumenstingl
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Martin Blumenstingl @ 2016-11-25 13:11 UTC (permalink / raw)
  To: linus-amlogic

The RTL8211F PHY driver currently enables the TX-delay only when the
phy-mode is PHY_INTERFACE_MODE_RGMII. This is incorrect, because there
are three RGMII variations of the phy-mode which explicitly request the
PHY to enable the RX and/or TX delay, while PHY_INTERFACE_MODE_RGMII
specifies that the PHY should disable the RX and/or TX delays.

Additionally to the RTL8211F PHY driver change this contains a small
update to the phy-mode documentation to clarify the purpose of the
RGMII phy-modes.
While this may not be perfect yet it's at least a start. Please feel
free to drop this patch from this series and send an improved version
yourself.

These patches are the results of recent discussions, see [0]

[0] http://lists.infradead.org/pipermail/linux-amlogic/2016-November/001688.html

Martin Blumenstingl (2):
  Documentation: devicetree: clarify usage of the RGMII phy-modes
  net: phy: realtek: fix enabling of the TX-delay for RTL8211F

 Documentation/devicetree/bindings/net/ethernet.txt | 24 ++++++++++++++++++----
 drivers/net/phy/realtek.c                          | 20 ++++++++++--------
 2 files changed, 32 insertions(+), 12 deletions(-)

-- 
2.10.2

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] Documentation: devicetree: clarify usage of the RGMII phy-modes
  2016-11-25 13:11 [PATCH 0/2] net: phy: realtek: fix RTL8211F TX-delay handling Martin Blumenstingl
@ 2016-11-25 13:12 ` Martin Blumenstingl
  2016-11-27  5:53   ` Florian Fainelli
  2016-11-25 13:12 ` [PATCH 2/2] net: phy: realtek: fix enabling of the TX-delay for RTL8211F Martin Blumenstingl
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Martin Blumenstingl @ 2016-11-25 13:12 UTC (permalink / raw)
  To: linus-amlogic

RGMII requires special RX and/or TX delays depending on the actual
hardware circuit/wiring. These delays can be added by the MAC, the PHY
or the designer of the circuit (the latter means that no delay has to
be added by PHY or MAC).
There are 4 RGMII phy-modes used describe where a delay should be
applied:
- rgmii: the RX and TX delays are either added by the MAC (where the
  exact delay is typically configurable, and can be turned off when no
  extra delay is needed) or not needed at all (because the hardware
  wiring adds the delay already). The PHY should neither add the RX nor
  TX delay in this case.
- rgmii-rxid: configures the PHY to enable the RX delay. The MAC should
  not add the RX delay in this case.
- rgmii-txid: configures the PHY to enable the TX delay. The MAC should
  not add the TX delay in this case.
- rgmii-id: combines rgmii-rxid and rgmii-txid and thus configures the
  PHY to enable the RX and TX delays. The MAC should neither add the RX
  nor TX delay in this case.

Document these cases in the ethernet.txt documentation to make it clear
when to use each mode.
If applied incorrectly one might end up with MAC and PHY both enabling
for example the TX delay, which breaks ethernet TX traffic on 1000Mbit/s
links.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 Documentation/devicetree/bindings/net/ethernet.txt | 24 ++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/ethernet.txt b/Documentation/devicetree/bindings/net/ethernet.txt
index e1d7681..0515095 100644
--- a/Documentation/devicetree/bindings/net/ethernet.txt
+++ b/Documentation/devicetree/bindings/net/ethernet.txt
@@ -9,10 +9,26 @@ The following properties are common to the Ethernet controllers:
 - max-speed: number, specifies maximum speed in Mbit/s supported by the device;
 - max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than
   the maximum frame size (there's contradiction in ePAPR).
-- phy-mode: string, operation mode of the PHY interface; supported values are
-  "mii", "gmii", "sgmii", "qsgmii", "tbi", "rev-mii", "rmii", "rgmii", "rgmii-id",
-  "rgmii-rxid", "rgmii-txid", "rtbi", "smii", "xgmii", "trgmii"; this is now a
-  de-facto standard property;
+- phy-mode: string, operation mode of the PHY interface. This is now a de-facto
+  standard property; supported values are:
+  * "mii"
+  * "gmii"
+  * "sgmii"
+  * "qsgmii"
+  * "tbi"
+  * "rev-mii"
+  * "rmii"
+  * "rgmii" (RX and TX delays are added by the MAC when required)
+  * "rgmii-id" (RGMII with internal RX and TX delays provided by the PHY, the
+     MAC should not add the RX or TX delays in this case)
+  * "rgmii-rxid" (RGMII with internal RX delay provided by the PHY, the MAC
+     should not add an RX delay in this case)
+  * "rgmii-txid" (RGMII with internal TX delay provided by the PHY, the MAC
+     should not add an TX delay in this case)
+  * "rtbi"
+  * "smii"
+  * "xgmii"
+  * "trgmii"
 - phy-connection-type: the same as "phy-mode" property but described in ePAPR;
 - phy-handle: phandle, specifies a reference to a node representing a PHY
   device; this property is described in ePAPR and so preferred;
-- 
2.10.2

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/2] net: phy: realtek: fix enabling of the TX-delay for RTL8211F
  2016-11-25 13:11 [PATCH 0/2] net: phy: realtek: fix RTL8211F TX-delay handling Martin Blumenstingl
  2016-11-25 13:12 ` [PATCH 1/2] Documentation: devicetree: clarify usage of the RGMII phy-modes Martin Blumenstingl
@ 2016-11-25 13:12 ` Martin Blumenstingl
  2016-11-27  5:55   ` Florian Fainelli
  2016-11-28 13:25 ` [PATCH 0/2] net: phy: realtek: fix RTL8211F TX-delay handling Neil Armstrong
  2016-11-28 17:07 ` David Miller
  3 siblings, 1 reply; 7+ messages in thread
From: Martin Blumenstingl @ 2016-11-25 13:12 UTC (permalink / raw)
  To: linus-amlogic

The old logic always enabled the TX-delay when the phy-mode was set to
PHY_INTERFACE_MODE_RGMII. There are dedicated phy-modes which tell the
PHY driver to enable the RX and/or TX delays:
- PHY_INTERFACE_MODE_RGMII should disable the RX and TX delay in the
  PHY (if required, the MAC should add the delays in this case)
- PHY_INTERFACE_MODE_RGMII_ID should enable RX and TX delay in the PHY
- PHY_INTERFACE_MODE_RGMII_TXID should enable the TX delay in the PHY
- PHY_INTERFACE_MODE_RGMII_RXID should enable the RX delay in the PHY
  (currently not supported by RTL8211F)

With this patch we enable the TX delay for PHY_INTERFACE_MODE_RGMII_ID
and PHY_INTERFACE_MODE_RGMII_TXID.
Additionally we now explicity disable the TX-delay, which seems to be
enabled automatically after a hard-reset of the PHY (by triggering it's
reset pin) to get a consistent state (as defined by the phy-mode).

This fixes a compatibility problem with some SoCs where the TX-delay was
also added by the MAC. With the TX-delay being applied twice the TX
clock was off and TX traffic was broken or very slow (<10Mbit/s) on
1000Mbit/s links.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/net/phy/realtek.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index aadd6e9..9cbe645 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -102,15 +102,19 @@ static int rtl8211f_config_init(struct phy_device *phydev)
 	if (ret < 0)
 		return ret;
 
-	if (phydev->interface == PHY_INTERFACE_MODE_RGMII) {
-		/* enable TXDLY */
-		phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08);
-		reg = phy_read(phydev, 0x11);
+	phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08);
+	reg = phy_read(phydev, 0x11);
+
+	/* enable TX-delay for rgmii-id and rgmii-txid, otherwise disable it */
+	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+	    phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
 		reg |= RTL8211F_TX_DELAY;
-		phy_write(phydev, 0x11, reg);
-		/* restore to default page 0 */
-		phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0);
-	}
+	else
+		reg &= ~RTL8211F_TX_DELAY;
+
+	phy_write(phydev, 0x11, reg);
+	/* restore to default page 0 */
+	phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0);
 
 	return 0;
 }
-- 
2.10.2

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] Documentation: devicetree: clarify usage of the RGMII phy-modes
  2016-11-25 13:12 ` [PATCH 1/2] Documentation: devicetree: clarify usage of the RGMII phy-modes Martin Blumenstingl
@ 2016-11-27  5:53   ` Florian Fainelli
  0 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2016-11-27  5:53 UTC (permalink / raw)
  To: linus-amlogic



On 11/25/2016 05:12 AM, Martin Blumenstingl wrote:
> RGMII requires special RX and/or TX delays depending on the actual
> hardware circuit/wiring. These delays can be added by the MAC, the PHY
> or the designer of the circuit (the latter means that no delay has to
> be added by PHY or MAC).
> There are 4 RGMII phy-modes used describe where a delay should be
> applied:
> - rgmii: the RX and TX delays are either added by the MAC (where the
>   exact delay is typically configurable, and can be turned off when no
>   extra delay is needed) or not needed at all (because the hardware
>   wiring adds the delay already). The PHY should neither add the RX nor
>   TX delay in this case.
> - rgmii-rxid: configures the PHY to enable the RX delay. The MAC should
>   not add the RX delay in this case.
> - rgmii-txid: configures the PHY to enable the TX delay. The MAC should
>   not add the TX delay in this case.
> - rgmii-id: combines rgmii-rxid and rgmii-txid and thus configures the
>   PHY to enable the RX and TX delays. The MAC should neither add the RX
>   nor TX delay in this case.
> 
> Document these cases in the ethernet.txt documentation to make it clear
> when to use each mode.
> If applied incorrectly one might end up with MAC and PHY both enabling
> for example the TX delay, which breaks ethernet TX traffic on 1000Mbit/s
> links.
> 
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/2] net: phy: realtek: fix enabling of the TX-delay for RTL8211F
  2016-11-25 13:12 ` [PATCH 2/2] net: phy: realtek: fix enabling of the TX-delay for RTL8211F Martin Blumenstingl
@ 2016-11-27  5:55   ` Florian Fainelli
  0 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2016-11-27  5:55 UTC (permalink / raw)
  To: linus-amlogic



On 11/25/2016 05:12 AM, Martin Blumenstingl wrote:
> The old logic always enabled the TX-delay when the phy-mode was set to
> PHY_INTERFACE_MODE_RGMII. There are dedicated phy-modes which tell the
> PHY driver to enable the RX and/or TX delays:
> - PHY_INTERFACE_MODE_RGMII should disable the RX and TX delay in the
>   PHY (if required, the MAC should add the delays in this case)
> - PHY_INTERFACE_MODE_RGMII_ID should enable RX and TX delay in the PHY
> - PHY_INTERFACE_MODE_RGMII_TXID should enable the TX delay in the PHY
> - PHY_INTERFACE_MODE_RGMII_RXID should enable the RX delay in the PHY
>   (currently not supported by RTL8211F)
> 
> With this patch we enable the TX delay for PHY_INTERFACE_MODE_RGMII_ID
> and PHY_INTERFACE_MODE_RGMII_TXID.
> Additionally we now explicity disable the TX-delay, which seems to be
> enabled automatically after a hard-reset of the PHY (by triggering it's
> reset pin) to get a consistent state (as defined by the phy-mode).
> 
> This fixes a compatibility problem with some SoCs where the TX-delay was
> also added by the MAC. With the TX-delay being applied twice the TX
> clock was off and TX traffic was broken or very slow (<10Mbit/s) on
> 1000Mbit/s links.
> 
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 0/2] net: phy: realtek: fix RTL8211F TX-delay handling
  2016-11-25 13:11 [PATCH 0/2] net: phy: realtek: fix RTL8211F TX-delay handling Martin Blumenstingl
  2016-11-25 13:12 ` [PATCH 1/2] Documentation: devicetree: clarify usage of the RGMII phy-modes Martin Blumenstingl
  2016-11-25 13:12 ` [PATCH 2/2] net: phy: realtek: fix enabling of the TX-delay for RTL8211F Martin Blumenstingl
@ 2016-11-28 13:25 ` Neil Armstrong
  2016-11-28 17:07 ` David Miller
  3 siblings, 0 replies; 7+ messages in thread
From: Neil Armstrong @ 2016-11-28 13:25 UTC (permalink / raw)
  To: linus-amlogic

On 11/25/2016 02:11 PM, Martin Blumenstingl wrote:
> The RTL8211F PHY driver currently enables the TX-delay only when the
> phy-mode is PHY_INTERFACE_MODE_RGMII. This is incorrect, because there
> are three RGMII variations of the phy-mode which explicitly request the
> PHY to enable the RX and/or TX delay, while PHY_INTERFACE_MODE_RGMII
> specifies that the PHY should disable the RX and/or TX delays.
> 
> Additionally to the RTL8211F PHY driver change this contains a small
> update to the phy-mode documentation to clarify the purpose of the
> RGMII phy-modes.
> While this may not be perfect yet it's at least a start. Please feel
> free to drop this patch from this series and send an improved version
> yourself.
> 
> These patches are the results of recent discussions, see [0]
> 
> [0] http://lists.infradead.org/pipermail/linux-amlogic/2016-November/001688.html
> 
> Martin Blumenstingl (2):
>   Documentation: devicetree: clarify usage of the RGMII phy-modes
>   net: phy: realtek: fix enabling of the TX-delay for RTL8211F
> 
>  Documentation/devicetree/bindings/net/ethernet.txt | 24 ++++++++++++++++++----
>  drivers/net/phy/realtek.c                          | 20 ++++++++++--------
>  2 files changed, 32 insertions(+), 12 deletions(-)
> 

Along the "stmmac: dwmac-meson8b: configurable RGMII TX delay" v2 patchset,
fixes the link issue on my Nexbox A1 board and does not break my Amlogic P230 board.

Tested-by: Neil Armstrong <narmstrong@baylibre.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 0/2] net: phy: realtek: fix RTL8211F TX-delay handling
  2016-11-25 13:11 [PATCH 0/2] net: phy: realtek: fix RTL8211F TX-delay handling Martin Blumenstingl
                   ` (2 preceding siblings ...)
  2016-11-28 13:25 ` [PATCH 0/2] net: phy: realtek: fix RTL8211F TX-delay handling Neil Armstrong
@ 2016-11-28 17:07 ` David Miller
  3 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2016-11-28 17:07 UTC (permalink / raw)
  To: linus-amlogic

From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Date: Fri, 25 Nov 2016 14:11:59 +0100

> The RTL8211F PHY driver currently enables the TX-delay only when the
> phy-mode is PHY_INTERFACE_MODE_RGMII. This is incorrect, because there
> are three RGMII variations of the phy-mode which explicitly request the
> PHY to enable the RX and/or TX delay, while PHY_INTERFACE_MODE_RGMII
> specifies that the PHY should disable the RX and/or TX delays.
> 
> Additionally to the RTL8211F PHY driver change this contains a small
> update to the phy-mode documentation to clarify the purpose of the
> RGMII phy-modes.
> While this may not be perfect yet it's at least a start. Please feel
> free to drop this patch from this series and send an improved version
> yourself.
> 
> These patches are the results of recent discussions, see [0]
> 
> [0] http://lists.infradead.org/pipermail/linux-amlogic/2016-November/001688.html

Series applied, thanks Martin.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-11-28 17:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-25 13:11 [PATCH 0/2] net: phy: realtek: fix RTL8211F TX-delay handling Martin Blumenstingl
2016-11-25 13:12 ` [PATCH 1/2] Documentation: devicetree: clarify usage of the RGMII phy-modes Martin Blumenstingl
2016-11-27  5:53   ` Florian Fainelli
2016-11-25 13:12 ` [PATCH 2/2] net: phy: realtek: fix enabling of the TX-delay for RTL8211F Martin Blumenstingl
2016-11-27  5:55   ` Florian Fainelli
2016-11-28 13:25 ` [PATCH 0/2] net: phy: realtek: fix RTL8211F TX-delay handling Neil Armstrong
2016-11-28 17:07 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®