public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq@kernel.org>
To: Ken Sloat <ken.s@variscite.com>,
	"u-boot@lists.denx.de" <u-boot@lists.denx.de>,
	"mripard@kernel.org" <mripard@kernel.org>,
	"dannenberg@ti.com" <dannenberg@ti.com>,
	"sjg@chromium.org" <sjg@chromium.org>,
	"s-anna@ti.com" <s-anna@ti.com>, "nm@ti.co" <nm@ti.co>,
	"s-vadapalli@ti.com" <s-vadapalli@ti.com>,
	"rfried.dev@gmail.com" <rfried.dev@gmail.com>,
	"joe.hershberger@ni.com" <joe.hershberger@ni.com>
Cc: Nate Drude <Nate.D@variscite.com>, Eran Matityahu <eran.m@variscite.com>
Subject: Re: [PATCH v1 1/1] net: ti: am65-cpsw-nuss: Remove incorrect RGMII_ID bit functionality
Date: Thu, 18 Jan 2024 14:15:06 +0200	[thread overview]
Message-ID: <bd06e456-643f-4a49-a342-00a008045b41@kernel.org> (raw)
In-Reply-To: <AS8PR08MB7991CFB38C65A76484AD971CEC732@AS8PR08MB7991.eurprd08.prod.outlook.com>

Hi Ken,

On 16/01/2024 22:01, Ken Sloat wrote:
> The CPSW implementations on the AM6x platforms do not support the
> selectable RGMII TX clk delay functionality via the RGMII_ID_MODE bit as
> the earlier platforms did. According to various TI datasheets, reference
> manuals, hardware design guides and TI forum posts from TI, this bit is
> "not timed, tested, or characterized. RGMII_ID is enabled by default and
> the register bit reserved."
> 
> The driver implementation today however, will incorrectly set this bit
> whenever the interface mode is in RGMII_ID or RGMII_TXID.
> 
> To fix this, remove any statement setting this bit, and moreover, mask
> bits 31:4 as these are all reserved.
> 
> See:
> https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1211306/am625-enet1_ctrl_rgmii_id-_mode
> https://www.ti.com/lit/pdf/spruiv7 (Rev. B Figure 14-1717> https://www.ti.com/lit/gpn/am625 (Rev. B Figure 7-31 Note A)
> https://www.ti.com/lit/an/sprad05b/sprad05b.pdf (Rev. B Section 7.4)
> 

Thanks for the patch. Some comments below.

> Signed-off-by: Ken Sloat <ken.s@variscite.com>
> ---
>  drivers/net/ti/am65-cpsw-nuss.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ti/am65-cpsw-nuss.c b/drivers/net/ti/am65-cpsw-nuss.c
> index 18a33c4c0e..51c432408f 100644
> --- a/drivers/net/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ti/am65-cpsw-nuss.c
> @@ -256,7 +256,6 @@ static int am65_cpsw_gmii_sel_k3(struct am65_cpsw_priv *priv,
>  {
>  	struct udevice *dev = priv->dev;
>  	u32 offset, reg, phandle;
> -	bool rgmii_id = false;
>  	fdt_addr_t gmii_sel;
>  	u32 mode = 0;
>  	ofnode node;
> @@ -296,7 +295,6 @@ static int am65_cpsw_gmii_sel_k3(struct am65_cpsw_priv *priv,
>  	case PHY_INTERFACE_MODE_RGMII_ID:
>  	case PHY_INTERFACE_MODE_RGMII_TXID:
>  		mode = AM65_GMII_SEL_MODE_RGMII;
> -		rgmii_id = true;
>  		break;
>  
>  	case PHY_INTERFACE_MODE_SGMII:
> @@ -313,15 +311,13 @@ static int am65_cpsw_gmii_sel_k3(struct am65_cpsw_priv *priv,
>  		break;
>  	};
>  
> -	if (rgmii_id)
> -		mode |= AM65_GMII_SEL_RGMII_IDMODE;
> -
> -	reg = mode;
> +	/* bits 31:4 are reserved */

Updated documentation is still wrong. Reserved bits should be Read only and should
always read 0. In updated TRM it doesn't show reserved bits as read-only and states
read value is 1.

Bit 4 is clearly read/write so it cannot be treated as reserved. But setting it
to 1 is not supported. 
If bootROM or some other software set it to 1 then it will remain 1 and we cannot
rely on it to be always 0. That's why it shouldn't be treated as reserved.

On AM65 bits 31:5 and 3:2 are reserved (read only 0).
Bit 4 is still r/w but setting 1 is not supported.

> +	reg = (GENMASK(31, 4) & reg) | mode;

As reserved bits will always read 0 this mask is not required.
What we do need to do is always clear bit 4.

So
	#define AM6X_GMII_SEL_MODE_SEL_MASK	GENMASK(2:0)

	/* RGMII_ID_MODE = 1 is not supported */
	reg &= ~AM65_GMII_SEL_RGMII_IDMODE;
	reg &= ~AM6X_GMII_SEL_MODE_SEL_MASK;
	reg |= mode;

Or simply this would have worked as we don't really set bit 4 in mode.

	reg = mode;


>  	dev_dbg(dev, "gmii_sel PHY mode: %u, new gmii_sel: %08x\n",
>  		phy_mode, reg);
>  	writel(reg, gmii_sel);
>  
> -	reg = readl(gmii_sel);
> +	reg = GENMASK(3, 0) & readl(gmii_sel);

should be GENMASK(2, 0);

but now we can use AM6X_GMII_SEL_MODE_SEL_MASK here instead.

>  	if (reg != mode) {
>  		dev_err(dev,
>  			"gmii_sel PHY mode NOT SET!: requested: %08x, gmii_sel: %08x\n",

-- 
cheers,
-roger

  reply	other threads:[~2024-01-18 12:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16 20:01 [PATCH v1 1/1] net: ti: am65-cpsw-nuss: Remove incorrect RGMII_ID bit functionality Ken Sloat
2024-01-18 12:15 ` Roger Quadros [this message]
2024-01-24 17:11   ` Ken Sloat

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=bd06e456-643f-4a49-a342-00a008045b41@kernel.org \
    --to=rogerq@kernel.org \
    --cc=Nate.D@variscite.com \
    --cc=dannenberg@ti.com \
    --cc=eran.m@variscite.com \
    --cc=joe.hershberger@ni.com \
    --cc=ken.s@variscite.com \
    --cc=mripard@kernel.org \
    --cc=nm@ti.co \
    --cc=rfried.dev@gmail.com \
    --cc=s-anna@ti.com \
    --cc=s-vadapalli@ti.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /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