[PATCH 0/3] Pine64+ specific hacks for RTL8211E Ethernet PHY

64 views
Skip to first unread message

Icenowy Zheng

unread,
Oct 1, 2019, 4:30:23 AM10/1/19
to David S . Miller, Rob Herring, Mark Rutland, Maxime Ripard, Chen-Yu Tsai, Andrew Lunn, Florian Fainelli, Heiner Kallweit, net...@vger.kernel.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, linux...@googlegroups.com, 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

Icenowy Zheng

unread,
Oct 1, 2019, 4:31:04 AM10/1/19
to David S . Miller, Rob Herring, Mark Rutland, Maxime Ripard, Chen-Yu Tsai, Andrew Lunn, Florian Fainelli, Heiner Kallweit, net...@vger.kernel.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, linux...@googlegroups.com, Icenowy Zheng
From: Icenowy Zheng <ice...@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 <ice...@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

Icenowy Zheng

unread,
Oct 1, 2019, 4:32:18 AM10/1/19
to David S . Miller, Rob Herring, Mark Rutland, Maxime Ripard, Chen-Yu Tsai, Andrew Lunn, Florian Fainelli, Heiner Kallweit, net...@vger.kernel.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, linux...@googlegroups.com, 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 <ice...@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

Icenowy Zheng

unread,
Oct 1, 2019, 4:32:26 AM10/1/19
to David S . Miller, Rob Herring, Mark Rutland, Maxime Ripard, Chen-Yu Tsai, Andrew Lunn, Florian Fainelli, Heiner Kallweit, net...@vger.kernel.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, linux...@googlegroups.com, 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 <ice...@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

Icenowy Zheng

unread,
Oct 1, 2019, 12:08:57 PM10/1/19
to linux-ar...@lists.infradead.org, David Miller, mark.r...@arm.com, and...@lunn.ch, f.fai...@gmail.com, devic...@vger.kernel.org, net...@vger.kernel.org, linux...@googlegroups.com, linux-...@vger.kernel.org, mri...@kernel.org, we...@csie.org, rob...@kernel.org, hkall...@gmail.com


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

Icenowy Zheng

unread,
Oct 1, 2019, 12:32:54 PM10/1/19
to linux-ar...@lists.infradead.org, David Miller, mark.r...@arm.com, and...@lunn.ch, f.fai...@gmail.com, devic...@vger.kernel.org, net...@vger.kernel.org, linux-...@vger.kernel.org, mri...@kernel.org, linux...@googlegroups.com, rob...@kernel.org, we...@csie.org, hkall...@gmail.com


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

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

Florian Fainelli

unread,
Oct 1, 2019, 12:47:17 PM10/1/19
to Icenowy Zheng, David S . Miller, Rob Herring, Mark Rutland, Maxime Ripard, Chen-Yu Tsai, Andrew Lunn, Heiner Kallweit, net...@vger.kernel.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, linux...@googlegroups.com
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

Andrew Lunn

unread,
Oct 1, 2019, 12:52:59 PM10/1/19
to Florian Fainelli, Icenowy Zheng, David S . Miller, Rob Herring, Mark Rutland, Maxime Ripard, Chen-Yu Tsai, Heiner Kallweit, net...@vger.kernel.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, linux...@googlegroups.com
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
Reply all
Reply to author
Forward
0 new messages