linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY
@ 2019-10-01  8:29 Icenowy Zheng
  2019-10-01  8:29 ` [PATCH 1/3] dt-bindings: add binding " Icenowy Zheng
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Icenowy Zheng @ 2019-10-01  8:29 UTC (permalink / raw)
  To: David S . Miller, Rob Herring, Mark Rutland, Maxime Ripard,
	Chen-Yu Tsai, Andrew Lunn, Florian Fainelli, Heiner Kallweit
  Cc: netdev, devicetree, linux-kernel, linux-arm-kernel, linux-sunxi,
	Icenowy Zheng

There're some Pine64+ boards known to have broken RTL8211E chips, and
a hack is given by Pine64+, which is said to be from Realtek.

This patchset adds the hack.

The hack is taken from U-Boot, and it contains magic numbers without
any document.

Icenowy Zheng (3):
  dt-bindings: add binding for RTL8211E Ethernet PHY
  net: phy: realtek: add config hack for broken RTL8211E on Pine64+
    boards
  arm64: allwinner: a64: dts: apply hack for RTL8211E on Pine64+

 .../bindings/net/realtek,rtl8211e.yaml        | 23 +++++++++++++++++++
 .../dts/allwinner/sun50i-a64-pine64-plus.dts  |  1 +
 drivers/net/phy/realtek.c                     | 14 +++++++++++
 3 files changed, 38 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/realtek,rtl8211e.yaml

-- 
2.21.0


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

* [PATCH 1/3] dt-bindings: add binding for RTL8211E Ethernet PHY
  2019-10-01  8:29 [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY Icenowy Zheng
@ 2019-10-01  8:29 ` Icenowy Zheng
  2019-10-01  8:29 ` [PATCH 2/3] net: phy: realtek: add config hack for broken RTL8211E on Pine64+ boards Icenowy Zheng
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Icenowy Zheng @ 2019-10-01  8:29 UTC (permalink / raw)
  To: David S . Miller, Rob Herring, Mark Rutland, Maxime Ripard,
	Chen-Yu Tsai, Andrew Lunn, Florian Fainelli, Heiner Kallweit
  Cc: netdev, devicetree, linux-kernel, linux-arm-kernel, linux-sunxi,
	Icenowy Zheng

From: Icenowy Zheng <icenowy@aosc.xyz>

Some RTL8211E Ethernet PHY have an issue that needs a workaround, and a
way to indicate the need of the workaround should be added.

Add the binding for a DT property that indicates this workaround.

Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
---
 .../bindings/net/realtek,rtl8211e.yaml        | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/realtek,rtl8211e.yaml

diff --git a/Documentation/devicetree/bindings/net/realtek,rtl8211e.yaml b/Documentation/devicetree/bindings/net/realtek,rtl8211e.yaml
new file mode 100644
index 000000000000..264e93cafbec
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/realtek,rtl8211e.yaml
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/realtek,rtl8211e.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Realtek RTL8211E Ethernet PHY
+
+properties:
+  realtek,config-magic-for-pine64:
+    description:
+      Enabling specific hacks for some broken RTL8211E chips known to be
+      used by Pine64+ boards.
+
+examples:
+  - |
+    &mdio {
+        ext_phy: ethernet-phy@0 {
+            compatible = "ethernet-phy-ieee802.3-c22";
+            reg = <0>;
+            realtek,config-magic-for-pine64;
+        };
+    };
-- 
2.21.0


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

* [PATCH 2/3] net: phy: realtek: add config hack for broken RTL8211E on Pine64+ boards
  2019-10-01  8:29 [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY Icenowy Zheng
  2019-10-01  8:29 ` [PATCH 1/3] dt-bindings: add binding " Icenowy Zheng
@ 2019-10-01  8:29 ` Icenowy Zheng
  2019-10-01  8:29 ` [PATCH 3/3] arm64: allwinner: a64: dts: apply hack for RTL8211E on Pine64+ Icenowy Zheng
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Icenowy Zheng @ 2019-10-01  8:29 UTC (permalink / raw)
  To: David S . Miller, Rob Herring, Mark Rutland, Maxime Ripard,
	Chen-Yu Tsai, Andrew Lunn, Florian Fainelli, Heiner Kallweit
  Cc: netdev, devicetree, linux-kernel, linux-arm-kernel, linux-sunxi,
	Icenowy Zheng

Some RTL8211E chips have broken GbE function, which needs a hack to
fix.

Currently only some Pine64+ boards are known to used this broken batch
of RTL8211E chips.

Enable this hack when a certain device tree property is set.

As this hack is not documented on the datasheet at all, it contains
magic numbers, and could not be revealed. These magic numbers are
received from Realtek via Pine64.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
 drivers/net/phy/realtek.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 677c45985338..f696f2085368 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -9,6 +9,7 @@
  * Copyright (c) 2004 Freescale Semiconductor, Inc.
  */
 #include <linux/bitops.h>
+#include <linux/of.h>
 #include <linux/phy.h>
 #include <linux/module.h>
 
@@ -32,6 +33,12 @@
 #define RTL8211E_TX_DELAY			BIT(1)
 #define RTL8211E_RX_DELAY			BIT(2)
 #define RTL8211E_MODE_MII_GMII			BIT(3)
+/* The following number resides in the same register with
+ * the delay bits and mode bit above. However, no known
+ * document can explain this, and this value is directly
+ * received from Realtek via Pine64.
+ */
+#define RTL8211E_CONF_MAGIC_PINE64		0xb400
 
 #define RTL8201F_ISR				0x1e
 #define RTL8201F_IER				0x13
@@ -196,6 +203,7 @@ static int rtl8211e_config_init(struct phy_device *phydev)
 {
 	int ret = 0, oldpage;
 	u16 val;
+	struct device_node *of_node = phydev->mdio.dev.of_node;
 
 	/* enable TX/RX delay for rgmii-* modes, and disable them for rgmii. */
 	switch (phydev->interface) {
@@ -234,6 +242,12 @@ static int rtl8211e_config_init(struct phy_device *phydev)
 	ret = __phy_modify(phydev, 0x1c, RTL8211E_TX_DELAY | RTL8211E_RX_DELAY,
 			   val);
 
+	if (of_node &&
+	    of_property_read_bool(of_node, "realtek,config-magic-for-pine64")) {
+		ret = __phy_modify(phydev, 0x1c, GENMASK(15, 8),
+				   RTL8211E_CONF_MAGIC_PINE64);
+	}
+
 err_restore_page:
 	return phy_restore_page(phydev, oldpage, ret);
 }
-- 
2.21.0


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

* [PATCH 3/3] arm64: allwinner: a64: dts: apply hack for RTL8211E on Pine64+
  2019-10-01  8:29 [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY Icenowy Zheng
  2019-10-01  8:29 ` [PATCH 1/3] dt-bindings: add binding " Icenowy Zheng
  2019-10-01  8:29 ` [PATCH 2/3] net: phy: realtek: add config hack for broken RTL8211E on Pine64+ boards Icenowy Zheng
@ 2019-10-01  8:29 ` Icenowy Zheng
  2019-10-01 16:06 ` [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY David Miller
  2019-10-01 16:47 ` Florian Fainelli
  4 siblings, 0 replies; 11+ messages in thread
From: Icenowy Zheng @ 2019-10-01  8:29 UTC (permalink / raw)
  To: David S . Miller, Rob Herring, Mark Rutland, Maxime Ripard,
	Chen-Yu Tsai, Andrew Lunn, Florian Fainelli, Heiner Kallweit
  Cc: netdev, devicetree, linux-kernel, linux-arm-kernel, linux-sunxi,
	Icenowy Zheng

Some of the Pine64+ boards are known to use a batch of broken RTL8211E
PHYs. A magic number that is in an undocumented field of a register is
passed from Realtek via Pine64.

Add the property to apply the hack to the Pine64+ device tree.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
---
 arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts
index 24f1aac366d6..4d68f850d03a 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pine64-plus.dts
@@ -61,5 +61,6 @@
 	ext_rgmii_phy: ethernet-phy@1 {
 		compatible = "ethernet-phy-ieee802.3-c22";
 		reg = <1>;
+		realtek,config-magic-for-pine64;
 	};
 };
-- 
2.21.0


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

* Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY
  2019-10-01  8:29 [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY Icenowy Zheng
                   ` (2 preceding siblings ...)
  2019-10-01  8:29 ` [PATCH 3/3] arm64: allwinner: a64: dts: apply hack for RTL8211E on Pine64+ Icenowy Zheng
@ 2019-10-01 16:06 ` David Miller
  2019-10-01 16:08   ` Icenowy Zheng
  2019-10-01 16:47 ` Florian Fainelli
  4 siblings, 1 reply; 11+ messages in thread
From: David Miller @ 2019-10-01 16:06 UTC (permalink / raw)
  To: icenowy
  Cc: robh+dt, mark.rutland, mripard, wens, andrew, f.fainelli,
	hkallweit1, netdev, devicetree, linux-kernel, linux-arm-kernel,
	linux-sunxi

From: Icenowy Zheng <icenowy@aosc.io>
Date: Tue,  1 Oct 2019 16:29:09 +0800

> There're some Pine64+ boards known to have broken RTL8211E chips, and
> a hack is given by Pine64+, which is said to be from Realtek.
> 
> This patchset adds the hack.
> 
> The hack is taken from U-Boot, and it contains magic numbers without
> any document.

Please contact Realtek and try to get an explanation about this.

I understand that eventually we may not get a proper explanation
but I really want you to put forth real effort to nail down whats
going on here before I even consider these patches seriously.

Thank you.

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

* Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY
  2019-10-01 16:06 ` [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY David Miller
@ 2019-10-01 16:08   ` Icenowy Zheng
  2019-10-01 16:30     ` David Miller
  0 siblings, 1 reply; 11+ messages in thread
From: Icenowy Zheng @ 2019-10-01 16:08 UTC (permalink / raw)
  To: linux-arm-kernel, David Miller
  Cc: mark.rutland, andrew, f.fainelli, devicetree, netdev,
	linux-sunxi, linux-kernel, mripard, wens, robh+dt, hkallweit1



于 2019年10月2日 GMT+08:00 上午12:06:51, David Miller <davem@davemloft.net> 写到:
>From: Icenowy Zheng <icenowy@aosc.io>
>Date: Tue,  1 Oct 2019 16:29:09 +0800
>
>> There're some Pine64+ boards known to have broken RTL8211E chips, and
>> a hack is given by Pine64+, which is said to be from Realtek.
>> 
>> This patchset adds the hack.
>> 
>> The hack is taken from U-Boot, and it contains magic numbers without
>> any document.
>
>Please contact Realtek and try to get an explanation about this.

Sorry, but Realtek never shows any idea to add more infomation about this.

These hacks had existed and worked for years.

>
>I understand that eventually we may not get a proper explanation
>but I really want you to put forth real effort to nail down whats
>going on here before I even consider these patches seriously.
>
>Thank you.
>
>_______________________________________________
>linux-arm-kernel mailing list
>linux-arm-kernel@lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY
  2019-10-01 16:08   ` Icenowy Zheng
@ 2019-10-01 16:30     ` David Miller
  2019-10-01 16:31       ` Icenowy Zheng
  0 siblings, 1 reply; 11+ messages in thread
From: David Miller @ 2019-10-01 16:30 UTC (permalink / raw)
  To: icenowy
  Cc: linux-arm-kernel, mark.rutland, andrew, f.fainelli, devicetree,
	netdev, linux-sunxi, linux-kernel, mripard, wens, robh+dt,
	hkallweit1

From: Icenowy Zheng <icenowy@aosc.io>
Date: Wed, 02 Oct 2019 00:08:39 +0800

> 
> 
> 于 2019年10月2日 GMT+08:00 上午12:06:51, David Miller <davem@davemloft.net> 写到:
>>From: Icenowy Zheng <icenowy@aosc.io>
>>Date: Tue,  1 Oct 2019 16:29:09 +0800
>>
>>> There're some Pine64+ boards known to have broken RTL8211E chips, and
>>> a hack is given by Pine64+, which is said to be from Realtek.
>>> 
>>> This patchset adds the hack.
>>> 
>>> The hack is taken from U-Boot, and it contains magic numbers without
>>> any document.
>>
>>Please contact Realtek and try to get an explanation about this.
> 
> Sorry, but Realtek never shows any idea to add more infomation about this.
> 
> These hacks had existed and worked for years.

Have you actually tried to communicate with an appropriate contact yourself?

If not, I am asking you to do so.

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

* Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY
  2019-10-01 16:30     ` David Miller
@ 2019-10-01 16:31       ` Icenowy Zheng
  2019-10-01 16:41         ` David Miller
  0 siblings, 1 reply; 11+ messages in thread
From: Icenowy Zheng @ 2019-10-01 16:31 UTC (permalink / raw)
  To: linux-arm-kernel, David Miller
  Cc: mark.rutland, andrew, f.fainelli, devicetree, netdev,
	linux-kernel, mripard, linux-sunxi, robh+dt, wens, hkallweit1



于 2019年10月2日 GMT+08:00 上午12:30:00, David Miller <davem@davemloft.net> 写到:
>From: Icenowy Zheng <icenowy@aosc.io>
>Date: Wed, 02 Oct 2019 00:08:39 +0800
>
>> 
>> 
>> 于 2019年10月2日 GMT+08:00 上午12:06:51, David Miller <davem@davemloft.net>
>写到:
>>>From: Icenowy Zheng <icenowy@aosc.io>
>>>Date: Tue,  1 Oct 2019 16:29:09 +0800
>>>
>>>> There're some Pine64+ boards known to have broken RTL8211E chips,
>and
>>>> a hack is given by Pine64+, which is said to be from Realtek.
>>>> 
>>>> This patchset adds the hack.
>>>> 
>>>> The hack is taken from U-Boot, and it contains magic numbers
>without
>>>> any document.
>>>
>>>Please contact Realtek and try to get an explanation about this.
>> 
>> Sorry, but Realtek never shows any idea to add more infomation about
>this.
>> 
>> These hacks had existed and worked for years.
>
>Have you actually tried to communicate with an appropriate contact
>yourself?
>
>If not, I am asking you to do so.

I have tried to ask via TL Lim from Pine64, because I have no way
to communicate directly to Realtek. However TL cannot get anything
more from Realtek.

>
>_______________________________________________
>linux-arm-kernel mailing list
>linux-arm-kernel@lists.infradead.org
>http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

-- 
使用 K-9 Mail 发送自我的Android设备。

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

* Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY
  2019-10-01 16:31       ` Icenowy Zheng
@ 2019-10-01 16:41         ` David Miller
  0 siblings, 0 replies; 11+ messages in thread
From: David Miller @ 2019-10-01 16:41 UTC (permalink / raw)
  To: icenowy
  Cc: linux-arm-kernel, mark.rutland, andrew, f.fainelli, devicetree,
	netdev, linux-kernel, mripard, linux-sunxi, robh+dt, wens,
	hkallweit1

From: Icenowy Zheng <icenowy@aosc.io>
Date: Wed, 02 Oct 2019 00:31:25 +0800

> I have tried to ask via TL Lim from Pine64, because I have no way
> to communicate directly to Realtek. However TL cannot get anything
> more from Realtek.

We have several Realtek developers who post here as part of maintaining
the upstream copy of their drivers, and upstream developers of other
Realtek parts who sometimes interact with Realtek.

Be creative and work with these people to try to get to the right
people.

Please stop making excuses and do the right thing.

Thank you.

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

* Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY
  2019-10-01  8:29 [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY Icenowy Zheng
                   ` (3 preceding siblings ...)
  2019-10-01 16:06 ` [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY David Miller
@ 2019-10-01 16:47 ` Florian Fainelli
  2019-10-01 16:52   ` Andrew Lunn
  4 siblings, 1 reply; 11+ messages in thread
From: Florian Fainelli @ 2019-10-01 16:47 UTC (permalink / raw)
  To: Icenowy Zheng, David S . Miller, Rob Herring, Mark Rutland,
	Maxime Ripard, Chen-Yu Tsai, Andrew Lunn, Heiner Kallweit
  Cc: netdev, devicetree, linux-kernel, linux-arm-kernel, linux-sunxi

On 10/1/19 1:29 AM, Icenowy Zheng wrote:
> There're some Pine64+ boards known to have broken RTL8211E chips, and
> a hack is given by Pine64+, which is said to be from Realtek.
> 
> This patchset adds the hack.
> 
> The hack is taken from U-Boot, and it contains magic numbers without
> any document.

Such hacks are the very reason why PHY fixups exists, please investigate
working with Realtek first to understand how to make this hack less of a
hack so it is understood what it does and you can either add proper
infrastructure to the realtek PHY driver to perform that hack, or if
that is not an option, register a board specific fixup.

> 
> Icenowy Zheng (3):
>   dt-bindings: add binding for RTL8211E Ethernet PHY
>   net: phy: realtek: add config hack for broken RTL8211E on Pine64+
>     boards
>   arm64: allwinner: a64: dts: apply hack for RTL8211E on Pine64+
> 
>  .../bindings/net/realtek,rtl8211e.yaml        | 23 +++++++++++++++++++
>  .../dts/allwinner/sun50i-a64-pine64-plus.dts  |  1 +
>  drivers/net/phy/realtek.c                     | 14 +++++++++++
>  3 files changed, 38 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/net/realtek,rtl8211e.yaml
> 


-- 
Florian

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

* Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY
  2019-10-01 16:47 ` Florian Fainelli
@ 2019-10-01 16:52   ` Andrew Lunn
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2019-10-01 16:52 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Icenowy Zheng, David S . Miller, Rob Herring, Mark Rutland,
	Maxime Ripard, Chen-Yu Tsai, Heiner Kallweit, netdev, devicetree,
	linux-kernel, linux-arm-kernel, linux-sunxi

On Tue, Oct 01, 2019 at 09:47:08AM -0700, Florian Fainelli wrote:
> On 10/1/19 1:29 AM, Icenowy Zheng wrote:
> > There're some Pine64+ boards known to have broken RTL8211E chips, and
> > a hack is given by Pine64+, which is said to be from Realtek.
> > 
> > This patchset adds the hack.
> > 
> > The hack is taken from U-Boot, and it contains magic numbers without
> > any document.
> 
> Such hacks are the very reason why PHY fixups exists, please investigate
> working with Realtek first to understand how to make this hack less of a
> hack so it is understood what it does and you can either add proper
> infrastructure to the realtek PHY driver to perform that hack, or if
> that is not an option, register a board specific fixup.

Hi Icenowy

It would also be nice to know if only Pine64 has these bad PHYs, or if
they were in the general distribution chain and other boards might
have them as well.

     Andrew

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

end of thread, other threads:[~2019-10-01 16:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-01  8:29 [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY Icenowy Zheng
2019-10-01  8:29 ` [PATCH 1/3] dt-bindings: add binding " Icenowy Zheng
2019-10-01  8:29 ` [PATCH 2/3] net: phy: realtek: add config hack for broken RTL8211E on Pine64+ boards Icenowy Zheng
2019-10-01  8:29 ` [PATCH 3/3] arm64: allwinner: a64: dts: apply hack for RTL8211E on Pine64+ Icenowy Zheng
2019-10-01 16:06 ` [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY David Miller
2019-10-01 16:08   ` Icenowy Zheng
2019-10-01 16:30     ` David Miller
2019-10-01 16:31       ` Icenowy Zheng
2019-10-01 16:41         ` David Miller
2019-10-01 16:47 ` Florian Fainelli
2019-10-01 16:52   ` Andrew Lunn

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).