2019-10-01 08:31:59

by Icenowy Zheng

[permalink] [raw]
Subject: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY

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


2019-10-01 08:33:12

by Icenowy Zheng

[permalink] [raw]
Subject: [PATCH 2/3] net: phy: realtek: add config hack for broken RTL8211E on Pine64+ boards

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 <[email protected]>
---
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

2019-10-01 08:34:06

by Icenowy Zheng

[permalink] [raw]
Subject: [PATCH 3/3] arm64: allwinner: a64: dts: apply hack for RTL8211E on Pine64+

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 <[email protected]>
---
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

2019-10-01 08:34:14

by Icenowy Zheng

[permalink] [raw]
Subject: [PATCH 1/3] dt-bindings: add binding for RTL8211E Ethernet PHY

From: Icenowy Zheng <[email protected]>

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 <[email protected]>
---
.../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

2019-10-01 16:50:52

by Icenowy Zheng

[permalink] [raw]
Subject: Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY



于 2019年10月2日 GMT+08:00 上午12:06:51, David Miller <[email protected]> 写到:
>From: Icenowy Zheng <[email protected]>
>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
>[email protected]
>http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

2019-10-01 16:52:04

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY

From: Icenowy Zheng <[email protected]>
Date: Wed, 02 Oct 2019 00:08:39 +0800

>
>
> $BP2(B 2019$BG/(B10$B7n(B2$BF|(B GMT+08:00 $B>e8a(B12:06:51, David Miller <[email protected]> $B<LE~(B:
>>From: Icenowy Zheng <[email protected]>
>>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.

2019-10-01 16:52:29

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY

From: Icenowy Zheng <[email protected]>
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.

2019-10-01 16:54:16

by Icenowy Zheng

[permalink] [raw]
Subject: Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY



于 2019年10月2日 GMT+08:00 上午12:30:00, David Miller <[email protected]> 写到:
>From: Icenowy Zheng <[email protected]>
>Date: Wed, 02 Oct 2019 00:08:39 +0800
>
>>
>>
>> 于 2019年10月2日 GMT+08:00 上午12:06:51, David Miller <[email protected]>
>写到:
>>>From: Icenowy Zheng <[email protected]>
>>>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
>[email protected]
>http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

2019-10-01 16:55:59

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY

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

2019-10-01 16:58:00

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY

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

2019-10-01 17:00:04

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY

From: Icenowy Zheng <[email protected]>
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.