devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Icenowy Zheng <icenowy-h8G6r0blFSE@public.gmane.org>,
	Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
	Icenowy Zheng <icenowy-ymACFijhrKM@public.gmane.org>
Subject: Re: [PATCH 3/4] net: phy: realtek: add disable RX delay hack for RTL8211E
Date: Fri, 21 Apr 2017 17:35:12 -0700	[thread overview]
Message-ID: <8ab72465-3605-c8b6-c9cd-581f6e341e01@gmail.com> (raw)
In-Reply-To: <20170421232436.10924-4-icenowy-h8G6r0blFSE@public.gmane.org>

On 04/21/2017 04:24 PM, Icenowy Zheng wrote:
> From: Icenowy Zheng <icenowy-ymACFijhrKM@public.gmane.org>
> 
> Some RTL8211E chips have broken GbE function, which needs a hack to
> fix. It's said that this fix will affect the performance on not-buggy
> PHYs, so it should only be enabled on boards with the broken PHY.
> Currently only some Pine64+ boards are known to have this issue.
> 
> This hack is said to disable RX relay for RTL8211E according to Realtek.
> 
> 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-ymACFijhrKM@public.gmane.org>
> ---
>  drivers/net/phy/realtek.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
> index d820d00addf6..880022160cd2 100644
> --- a/drivers/net/phy/realtek.c
> +++ b/drivers/net/phy/realtek.c
> @@ -13,6 +13,7 @@
>   * option) any later version.
>   *
>   */
> +#include <linux/of.h>
>  #include <linux/phy.h>
>  #include <linux/module.h>
>  
> @@ -26,6 +27,8 @@
>  #define RTL8211_PAGE_SELECT	0x1f
>  
>  #define RTL8211E_INER_LINK_STATUS 0x400
> +#define RTL8211E_EXT_PAGE_SELECT 0x1e
> +#define RTL8211E_EXT_PAGE	0x7
>  
>  #define RTL8211F_INER_LINK_STATUS 0x0010
>  #define RTL8211F_INSR		0x1d
> @@ -121,6 +124,38 @@ static int rtl8211f_config_init(struct phy_device *phydev)
>  	return 0;
>  }
>  
> +static int rtl8211e_config_init(struct phy_device *phydev)
> +{
> +	struct device *dev = &phydev->mdio.dev;
> +	struct device_node *of_node = dev->of_node;
> +	int ret;
> +
> +	ret = genphy_config_init(phydev);
> +	if (ret < 0)
> +		return ret;
> +
> +	if (of_node &&
> +	    of_property_read_bool(of_node, "realtek,disable-rx-delay")) {
> +		/* All these magic numbers are retrieved from Pine64, and
> +		 * they're said to be originated from Realtek.
> +		 *
> +		 * The datasheet of RTL8211E didn't cover this ext page.
> +		 *
> +		 * Select extension page 0xa4 here.
> +		 */
> +		phy_write(phydev, RTL8211_PAGE_SELECT, RTL8211E_EXT_PAGE)
> +		phy_write(phydev, RTL8211E_EXT_PAGE_SELECT, 0xa4);
> +
> +		/* Write the magic number */
> +		phy_write(phydev, 0x1c, 0xb591);
> +
> +		/* Restore to default page 0 */
> +		phy_write(phydev, RTL8211_PAGE_SELECT, 0);
> +	}

The code itself is probably fine, but the way you are checking whether
the RX delay should be disabled is not. As mentioned in patch 2, using
the correct "phy-mode" property would translate in the proper
phydev->interface value here (presumably PHY_INTERFACE_MODE_RGMII_TXID)
is that you want here that would allow you to check whether the RX delay
should, or should not be disabled.

Thank you
-- 
Florian

  parent reply	other threads:[~2017-04-22  0:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-21 23:24 [PATCH 0/4] RTL8211E-specified hacks Icenowy Zheng
     [not found] ` <20170421232436.10924-1-icenowy-h8G6r0blFSE@public.gmane.org>
2017-04-21 23:24   ` [PATCH 1/4] net: phy: realtek: change macro name for page select register Icenowy Zheng
2017-04-21 23:24   ` [PATCH 2/4] dt-bindings: add binding for RTL8211E Ethernet PHY Icenowy Zheng
     [not found]     ` <20170421232436.10924-3-icenowy-h8G6r0blFSE@public.gmane.org>
2017-04-22  0:22       ` Florian Fainelli
     [not found]         ` <c7aa9d7a-5e97-0e7f-2b1c-584a4de00837-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-04-22  1:12           ` icenowy-h8G6r0blFSE
2017-05-04 18:10           ` icenowy-h8G6r0blFSE
     [not found]             ` <edf26d7de605a93bfce258de0353df6d-h8G6r0blFSE@public.gmane.org>
2017-05-04 18:21               ` Florian Fainelli
     [not found]                 ` <a455c822-d5aa-3f66-03c5-4d1268f9104b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-05-04 18:26                   ` Icenowy Zheng
     [not found]                     ` <D714E47B-D6B2-4C9F-B9D7-FB9D170E0ADF-h8G6r0blFSE@public.gmane.org>
2017-05-04 18:29                       ` Florian Fainelli
     [not found]                         ` <068f1323-3864-620c-0deb-6c5e04a9e498-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-08-21 14:53                           ` icenowy-h8G6r0blFSE
     [not found]                             ` <19ad1316a74e344d3e1c783458eb4d59-h8G6r0blFSE@public.gmane.org>
2017-08-21 19:54                               ` Florian Fainelli
2017-04-21 23:24   ` [PATCH 3/4] net: phy: realtek: add disable RX delay hack for RTL8211E Icenowy Zheng
     [not found]     ` <20170421232436.10924-4-icenowy-h8G6r0blFSE@public.gmane.org>
2017-04-22  0:35       ` Florian Fainelli [this message]
2017-04-22  7:12       ` kbuild test robot
2017-04-21 23:24   ` [PATCH 4/4] [DO NOT MERGE] arm64: allwinner: a64: enable RTL8211E PHY workaround Icenowy Zheng
     [not found]     ` <20170421232436.10924-5-icenowy-h8G6r0blFSE@public.gmane.org>
2017-04-22 12:27       ` kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ab72465-3605-c8b6-c9cd-581f6e341e01@gmail.com \
    --to=f.fainelli-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=andrew-g2DYL2Zd6BY@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=icenowy-h8G6r0blFSE@public.gmane.org \
    --cc=icenowy-ymACFijhrKM@public.gmane.org \
    --cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).