diff mbox series

net: phy: marvell: Add errata section 5.1 for Alaska PHY

Message ID 20220315074827.1439941-1-sr@denx.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: phy: marvell: Add errata section 5.1 for Alaska PHY | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: kuba@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 48 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Stefan Roese March 15, 2022, 7:48 a.m. UTC
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(+)

Comments

Andrew Lunn March 15, 2022, 2:39 p.m. UTC | #1
On Tue, Mar 15, 2022 at 08:48:27AM +0100, Stefan Roese 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>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Marek Behún March 15, 2022, 4:09 p.m. UTC | #2
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;
}
Stefan Roese March 17, 2022, 6:43 a.m. UTC | #3
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.

Thanks,
Stefan
Marek Behún March 17, 2022, 12:52 p.m. UTC | #4
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
diff mbox series

Patch

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;
+	err = marvell_set_page(phydev, 0x00FB);
+	if (err < 0)
+		return err;
+	err = phy_write(phydev, 07, 0xC00D);
+	if (err < 0)
+		return err;
+	err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE);
+	if (err < 0)
+		return err;
+
 	/* SGMII-to-Copper mode initialization */
 	if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
 		/* Select page 18 */