diff mbox series

[net-next,v2] net: phy: micrel: ksz9131 led errata workaround

Message ID 20211007164535.657245-1-francesco.dolcini@toradex.com (mailing list archive)
State Accepted
Commit 0316c7e66bbd16cf2d01a4e2f5afa6afb01278f2
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] net: phy: micrel: ksz9131 led errata workaround | expand

Checks

Context Check Description
netdev/cover_letter success Single patches do not need cover letters
netdev/fixes_present success Fixes tag not required for -next series
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success No Fixes tag
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 36 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success No static functions without inline keyword in header files

Commit Message

Francesco Dolcini Oct. 7, 2021, 4:45 p.m. UTC
Micrel KSZ9131 PHY LED behavior is not correct when configured in
Individual Mode, LED1 (Activity LED) is in the ON state when there is
no-link.

Workaround this by setting bit 9 of register 0x1e after verifying that
the LED configuration is Individual Mode.

This issue is described in KSZ9131RNX Silicon Errata DS80000693B [*]
and according to that it will not be corrected in a future silicon
revision.

[*] https://ww1.microchip.com/downloads/en/DeviceDoc/KSZ9131RNX-Silicon-Errata-and-Data-Sheet-Clarification-80000863B.pdf

Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
---
Changes v1 => v2:
 1. corrected errata URL in commit message
 2. check phy_read_mmd return value
---
 drivers/net/phy/micrel.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Philippe Schenker Oct. 7, 2021, 5:08 p.m. UTC | #1
On Thu, 2021-10-07 at 18:45 +0200, Francesco Dolcini wrote:
> Micrel KSZ9131 PHY LED behavior is not correct when configured in
> Individual Mode, LED1 (Activity LED) is in the ON state when there is
> no-link.
> 
> Workaround this by setting bit 9 of register 0x1e after verifying that
> the LED configuration is Individual Mode.
> 
> This issue is described in KSZ9131RNX Silicon Errata DS80000693B [*]
> and according to that it will not be corrected in a future silicon
> revision.
> 
> [*]
> https://ww1.microchip.com/downloads/en/DeviceDoc/KSZ9131RNX-Silicon-Errata-and-Data-Sheet-Clarification-80000863B.pdf
> 
> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>

This patch looks good to me, functionality wise it will work. I would
still do some defines for the raw values you used that are described in
the datasheet and maybe change the strange defines I introduced some
while ago, but I don't see this as a blocker.

Reviewed-by: Philippe Schenker <philippe.schenker@toradex.com>

> ---
> Changes v1 => v2:
>  1. corrected errata URL in commit message
>  2. check phy_read_mmd return value
> ---
>  drivers/net/phy/micrel.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index c330a5a9f665..b70f62efdbc3 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -1003,6 +1003,26 @@ static int ksz9131_config_rgmii_delay(struct
> phy_device *phydev)
>                               txcdll_val);
>  }
>  
> +/* Silicon Errata DS80000693B
> + *
> + * When LEDs are configured in Individual Mode, LED1 is ON in a no-
> link
> + * condition. Workaround is to set register 0x1e, bit 9, this way
> LED1 behaves
> + * according to the datasheet (off if there is no link).
> + */
> +static int ksz9131_led_errata(struct phy_device *phydev)
> +{
> +       int reg;
> +
> +       reg = phy_read_mmd(phydev, 2, 0);
> +       if (reg < 0)
> +               return reg;
> +
> +       if (!(reg & BIT(4)))
> +               return 0;
> +
> +       return phy_set_bits(phydev, 0x1e, BIT(9));
> +}
> +
>  static int ksz9131_config_init(struct phy_device *phydev)
>  {
>         struct device_node *of_node;
> @@ -1058,6 +1078,10 @@ static int ksz9131_config_init(struct
> phy_device *phydev)
>         if (ret < 0)
>                 return ret;
>  
> +       ret = ksz9131_led_errata(phydev);
> +       if (ret < 0)
> +               return ret;
> +
>         return 0;
>  }
>
Andrew Lunn Oct. 7, 2021, 5:50 p.m. UTC | #2
On Thu, Oct 07, 2021 at 06:45:35PM +0200, Francesco Dolcini wrote:
> Micrel KSZ9131 PHY LED behavior is not correct when configured in
> Individual Mode, LED1 (Activity LED) is in the ON state when there is
> no-link.
> 
> Workaround this by setting bit 9 of register 0x1e after verifying that
> the LED configuration is Individual Mode.
> 
> This issue is described in KSZ9131RNX Silicon Errata DS80000693B [*]
> and according to that it will not be corrected in a future silicon
> revision.
> 
> [*] https://ww1.microchip.com/downloads/en/DeviceDoc/KSZ9131RNX-Silicon-Errata-and-Data-Sheet-Clarification-80000863B.pdf
> 
> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>

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

    Andrew
patchwork-bot+netdevbpf@kernel.org Oct. 8, 2021, 4:30 p.m. UTC | #3
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu,  7 Oct 2021 18:45:35 +0200 you wrote:
> Micrel KSZ9131 PHY LED behavior is not correct when configured in
> Individual Mode, LED1 (Activity LED) is in the ON state when there is
> no-link.
> 
> Workaround this by setting bit 9 of register 0x1e after verifying that
> the LED configuration is Individual Mode.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net: phy: micrel: ksz9131 led errata workaround
    https://git.kernel.org/netdev/net-next/c/0316c7e66bbd

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index c330a5a9f665..b70f62efdbc3 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -1003,6 +1003,26 @@  static int ksz9131_config_rgmii_delay(struct phy_device *phydev)
 			      txcdll_val);
 }
 
+/* Silicon Errata DS80000693B
+ *
+ * When LEDs are configured in Individual Mode, LED1 is ON in a no-link
+ * condition. Workaround is to set register 0x1e, bit 9, this way LED1 behaves
+ * according to the datasheet (off if there is no link).
+ */
+static int ksz9131_led_errata(struct phy_device *phydev)
+{
+	int reg;
+
+	reg = phy_read_mmd(phydev, 2, 0);
+	if (reg < 0)
+		return reg;
+
+	if (!(reg & BIT(4)))
+		return 0;
+
+	return phy_set_bits(phydev, 0x1e, BIT(9));
+}
+
 static int ksz9131_config_init(struct phy_device *phydev)
 {
 	struct device_node *of_node;
@@ -1058,6 +1078,10 @@  static int ksz9131_config_init(struct phy_device *phydev)
 	if (ret < 0)
 		return ret;
 
+	ret = ksz9131_led_errata(phydev);
+	if (ret < 0)
+		return ret;
+
 	return 0;
 }