Skip to content

Commit bf8bfc4

Browse files
ffainellikuba-moo
authored andcommitted
net: phy: broadcom: Fix brcm_fet_config_init()
A Broadcom AC201 PHY (same entry as 5241) would be flagged by the Broadcom UniMAC MDIO controller as not completing the turn around properly since the PHY expects 65 MDC clock cycles to complete a write cycle, and the MDIO controller was only sending 64 MDC clock cycles as determined by looking at a scope shot. This would make the subsequent read fail with the UniMAC MDIO controller command field having MDIO_READ_FAIL set and we would abort the brcm_fet_config_init() function and thus not probe the PHY at all. After issuing a software reset, wait for at least 1ms which is well above the 1us reset delay advertised by the datasheet and issue a dummy read to let the PHY turn around the line properly. This read specifically ignores -EIO which would be returned by MDIO controllers checking for the line being turned around. If we have a genuine reaad failure, the next read of the interrupt status register would pick it up anyway. Fixes: d7a2ed9 ("broadcom: Add AC131 phy support") Signed-off-by: Florian Fainelli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2d327a7 commit bf8bfc4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

drivers/net/phy/broadcom.c

+21
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212

1313
#include "bcm-phy-lib.h"
14+
#include <linux/delay.h>
1415
#include <linux/module.h>
1516
#include <linux/phy.h>
1617
#include <linux/brcmphy.h>
@@ -602,6 +603,26 @@ static int brcm_fet_config_init(struct phy_device *phydev)
602603
if (err < 0)
603604
return err;
604605

606+
/* The datasheet indicates the PHY needs up to 1us to complete a reset,
607+
* build some slack here.
608+
*/
609+
usleep_range(1000, 2000);
610+
611+
/* The PHY requires 65 MDC clock cycles to complete a write operation
612+
* and turnaround the line properly.
613+
*
614+
* We ignore -EIO here as the MDIO controller (e.g.: mdio-bcm-unimac)
615+
* may flag the lack of turn-around as a read failure. This is
616+
* particularly true with this combination since the MDIO controller
617+
* only used 64 MDC cycles. This is not a critical failure in this
618+
* specific case and it has no functional impact otherwise, so we let
619+
* that one go through. If there is a genuine bus error, the next read
620+
* of MII_BRCM_FET_INTREG will error out.
621+
*/
622+
err = phy_read(phydev, MII_BMCR);
623+
if (err < 0 && err != -EIO)
624+
return err;
625+
605626
reg = phy_read(phydev, MII_BRCM_FET_INTREG);
606627
if (reg < 0)
607628
return reg;

0 commit comments

Comments
 (0)