netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Stefan Roese <sr@denx.de>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	"David S . Miller" <davem@davemloft.net>
Subject: Re: [PATCH] net: phy: marvell: Add errata section 5.1 for Alaska PHY
Date: Thu, 17 Mar 2022 13:52:20 +0100	[thread overview]
Message-ID: <20220317135220.329610f7@dellmb> (raw)
In-Reply-To: <96f69525-53e1-f77e-e0f4-3146c2310551@denx.de>

On Thu, 17 Mar 2022 07:43:52 +0100
Stefan Roese <sr@denx.de> wrote:

> On 3/15/22 17:09, Marek Behún wrote:
> > On Tue, 15 Mar 2022 08:48:27 +0100
> > Stefan Roese <sr@denx.de> wrote:
> >   
> >> From: Leszek Polak <lpolak@arri.de>
> >>
> >> As per Errata Section 5.1, if EEE is intended to be used, some register
> >> writes must be done once after every hardware reset. This patch now adds
> >> the necessary register writes as listed in the Marvell errata.
> >>
> >> Without this fix we experience ethernet problems on some of our boards
> >> equipped with a new version of this ethernet PHY (different supplier).
> >>
> >> The fix applies to Marvell Alaska 88E1510/88E1518/88E1512/88E1514
> >> Rev. A0.
> >>
> >> Signed-off-by: Leszek Polak <lpolak@arri.de>
> >> Signed-off-by: Stefan Roese <sr@denx.de>
> >> Cc: Andrew Lunn <andrew@lunn.ch>
> >> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> >> Cc: Russell King <linux@armlinux.org.uk>
> >> Cc: David S. Miller <davem@davemloft.net>
> >> ---
> >>   drivers/net/phy/marvell.c | 42 +++++++++++++++++++++++++++++++++++++++
> >>   1 file changed, 42 insertions(+)
> >>
> >> diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> >> index 2429db614b59..0f4a3ab4a415 100644
> >> --- a/drivers/net/phy/marvell.c
> >> +++ b/drivers/net/phy/marvell.c
> >> @@ -1179,6 +1179,48 @@ static int m88e1510_config_init(struct phy_device *phydev)
> >>   {
> >>   	int err;
> >>   
> >> +	/* As per Marvell Release Notes - Alaska 88E1510/88E1518/88E1512/
> >> +	 * 88E1514 Rev A0, Errata Section 5.1:
> >> +	 * If EEE is intended to be used, the following register writes
> >> +	 * must be done once after every hardware reset.
> >> +	 */
> >> +	err = marvell_set_page(phydev, 0x00FF);
> >> +	if (err < 0)
> >> +		return err;
> >> +	err = phy_write(phydev, 17, 0x214B);
> >> +	if (err < 0)
> >> +		return err;
> >> +	err = phy_write(phydev, 16, 0x2144);
> >> +	if (err < 0)
> >> +		return err;
> >> +	err = phy_write(phydev, 17, 0x0C28);
> >> +	if (err < 0)
> >> +		return err;
> >> +	err = phy_write(phydev, 16, 0x2146);
> >> +	if (err < 0)
> >> +		return err;
> >> +	err = phy_write(phydev, 17, 0xB233);
> >> +	if (err < 0)
> >> +		return err;
> >> +	err = phy_write(phydev, 16, 0x214D);
> >> +	if (err < 0)
> >> +		return err;
> >> +	err = phy_write(phydev, 17, 0xCC0C);
> >> +	if (err < 0)
> >> +		return err;
> >> +	err = phy_write(phydev, 16, 0x2159);
> >> +	if (err < 0)
> >> +		return err;  
> > 
> > Can you please create a static const struct and then do this in a for
> > cycle? Somethign like this
> > 
> > static const struct { u16 reg17, reg16; } errata_vals = {
> >    { 0x214B, 0x2144 }, ...
> > };
> > 
> > for (i = 0; i < ARRAY_SIZE(errata_vals); ++i) {
> >    err = phy_write(phydev, 17, errata_vals[i].reg17);
> >    if (err)
> >      return err;
> >    err = phy_write(phydev, 16, errata_vals[i].reg16);
> >    if (err)
> >      return err;
> > }  
> 
> I could do this, sure. But frankly I'm not so sure, if this really
> improves the code much. This list will most likely never be extended.
> And in this current version, it's easier to compare the values written
> with the one described in the errata.
> 
> But again, I have no hard feeling here. If it's the general option to
> move to the "loop version", then I'll gladly send an updated patch
> version.

I always try to do something like that. Look for example at

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/dsa/mv88e6xxx/serdes.c?h=v5.17-rc8#n1417

Marek

      reply	other threads:[~2022-03-17 12:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15  7:48 [PATCH] net: phy: marvell: Add errata section 5.1 for Alaska PHY Stefan Roese
2022-03-15 14:39 ` Andrew Lunn
2022-03-15 16:09 ` Marek Behún
2022-03-17  6:43   ` Stefan Roese
2022-03-17 12:52     ` Marek Behún [this message]

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=20220317135220.329610f7@dellmb \
    --to=kabel@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=sr@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;
as well as URLs for NNTP newsgroup(s).