diff mbox series

[U-Boot,3/3] drivers: net: fsl_enetc_mdio: return with time-out if HW is stuck

Message ID 20191114165847.11725-3-alexandru.marginean@nxp.com
State Accepted
Commit 6c9644685940e1d98c2d38fb205e8da14f3690b5
Delegated to: Joe Hershberger
Headers show
Series [U-Boot,1/3] drivers: net: fsl_enetc: Add 2.5Gbps to supported link speeds | expand

Commit Message

Alexandru Marginean Nov. 14, 2019, 4:58 p.m. UTC
On some boards MDIO may get stuck if it detects echo on the line.  This is
a know hardware issue, there is a board fix for it.  In case we're running
on a board that doesn't have the fix, we don't want to loop here forever
and freeze U-Boot.

Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
---
 drivers/net/fsl_enetc_mdio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Joe Hershberger Nov. 30, 2019, 12:42 a.m. UTC | #1
On Thu, Nov 14, 2019 at 10:59 AM Alex Marginean
<alexandru.marginean@nxp.com> wrote:
>
> On some boards MDIO may get stuck if it detects echo on the line.  This is
> a know hardware issue, there is a board fix for it.  In case we're running
> on a board that doesn't have the fix, we don't want to loop here forever
> and freeze U-Boot.
>
> Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
diff mbox series

Patch

diff --git a/drivers/net/fsl_enetc_mdio.c b/drivers/net/fsl_enetc_mdio.c
index b4463a58a5..47257a6cf6 100644
--- a/drivers/net/fsl_enetc_mdio.c
+++ b/drivers/net/fsl_enetc_mdio.c
@@ -17,8 +17,13 @@ 
 
 static void enetc_mdio_wait_bsy(struct enetc_mdio_priv *priv)
 {
-	while (enetc_read(priv, ENETC_MDIO_CFG) & ENETC_EMDIO_CFG_BSY)
+	int to = 10000;
+
+	while ((enetc_read(priv, ENETC_MDIO_CFG) & ENETC_EMDIO_CFG_BSY) &&
+	       --to)
 		cpu_relax();
+	if (!to)
+		printf("T");
 }
 
 int enetc_mdio_read_priv(struct enetc_mdio_priv *priv, int addr, int devad,