diff mbox series

net: phy: micrel: ksz9131 led errata workaround

Message ID 20211006073755.429469-1-francesco.dolcini@toradex.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series 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 Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
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, 33 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. 6, 2021, 7:37 a.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
(http://ww1.microchip.com/downloads/en/DeviceDoc/80000863A.pdf) and
according to that it will not be corrected in a future silicon revision.

Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
---
 drivers/net/phy/micrel.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Francesco Dolcini Oct. 6, 2021, 9:39 a.m. UTC | #1
Hello,
the link to the errata in the commit message is wrong, the correct
one is https://ww1.microchip.com/downloads/en/DeviceDoc/KSZ9131RNX-Silicon-Errata-and-Data-Sheet-Clarification-80000863B.pdf, I will fix it in the next patch version.

Francesco


On Wed, Oct 06, 2021 at 09:37:55AM +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
> (http://ww1.microchip.com/downloads/en/DeviceDoc/80000863A.pdf) and
> according to that it will not be corrected in a future silicon revision.
> 
> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
> ---
>  drivers/net/phy/micrel.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index c330a5a9f665..661dedec84c4 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -1003,6 +1003,23 @@ 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 ret = 0;
> +
> +	if (phy_read_mmd(phydev, 2, 0) & BIT(4))
> +		ret = phy_set_bits(phydev, 0x1e, BIT(9));
> +
> +	return ret;
> +}
> +
>  static int ksz9131_config_init(struct phy_device *phydev)
>  {
>  	struct device_node *of_node;
> @@ -1058,6 +1075,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;
>  }
>  
> -- 
> 2.25.1
>
Andrew Lunn Oct. 6, 2021, 9:57 p.m. UTC | #2
On Wed, Oct 06, 2021 at 09:37:55AM +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
> (http://ww1.microchip.com/downloads/en/DeviceDoc/80000863A.pdf) and
> according to that it will not be corrected in a future silicon revision.
> 
> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
> ---
>  drivers/net/phy/micrel.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index c330a5a9f665..661dedec84c4 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -1003,6 +1003,23 @@ 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 ret = 0;
> +
> +	if (phy_read_mmd(phydev, 2, 0) & BIT(4))

It would be good to check the return code here. If there is an error,
you are going to set bit 9.

Otherwise this looks O.K.

	  Andrew
diff mbox series

Patch

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index c330a5a9f665..661dedec84c4 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -1003,6 +1003,23 @@  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 ret = 0;
+
+	if (phy_read_mmd(phydev, 2, 0) & BIT(4))
+		ret = phy_set_bits(phydev, 0x1e, BIT(9));
+
+	return ret;
+}
+
 static int ksz9131_config_init(struct phy_device *phydev)
 {
 	struct device_node *of_node;
@@ -1058,6 +1075,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;
 }