Browse Source

[smsc75xx] Allow up to 100ms for reset to complete

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
c9176878ef
2 changed files with 16 additions and 11 deletions
  1. 14
    9
      src/drivers/net/smsc75xx.c
  2. 2
    2
      src/drivers/net/smsc75xx.h

+ 14
- 9
src/drivers/net/smsc75xx.c View File

@@ -511,6 +511,7 @@ static int smsc75xx_dump_statistics ( struct smsc75xx_device *smsc75xx ) {
511 511
  */
512 512
 static int smsc75xx_reset ( struct smsc75xx_device *smsc75xx ) {
513 513
 	uint32_t hw_cfg;
514
+	unsigned int i;
514 515
 	int rc;
515 516
 
516 517
 	/* Reset device */
@@ -519,18 +520,22 @@ static int smsc75xx_reset ( struct smsc75xx_device *smsc75xx ) {
519 520
 		return rc;
520 521
 
521 522
 	/* Wait for reset to complete */
522
-	udelay ( SMSC75XX_RESET_DELAY_US );
523
+	for ( i = 0 ; i < SMSC75XX_RESET_MAX_WAIT_MS ; i++ ) {
523 524
 
524
-	/* Check that reset has completed */
525
-	if ( ( rc = smsc75xx_readl ( smsc75xx, SMSC75XX_HW_CFG,
526
-				     &hw_cfg ) ) != 0 )
527
-		return rc;
528
-	if ( hw_cfg & SMSC75XX_HW_CFG_LRST ) {
529
-		DBGC ( smsc75xx, "SMSC75XX %p failed to reset\n", smsc75xx );
530
-		return -ETIMEDOUT;
525
+		/* Check if reset has completed */
526
+		if ( ( rc = smsc75xx_readl ( smsc75xx, SMSC75XX_HW_CFG,
527
+					     &hw_cfg ) ) != 0 )
528
+			return rc;
529
+		if ( ! ( hw_cfg & SMSC75XX_HW_CFG_LRST ) )
530
+			return 0;
531
+
532
+		/* Delay */
533
+		mdelay ( 1 );
531 534
 	}
532 535
 
533
-	return 0;
536
+	DBGC ( smsc75xx, "SMSC75XX %p timed out waiting for reset\n",
537
+	       smsc75xx );
538
+	return -ETIMEDOUT;
534 539
 }
535 540
 
536 541
 /******************************************************************************

+ 2
- 2
src/drivers/net/smsc75xx.h View File

@@ -280,8 +280,8 @@ struct smsc75xx_device {
280 280
 	uint32_t int_sts;
281 281
 };
282 282
 
283
-/** Reset delay (in microseconds) */
284
-#define SMSC75XX_RESET_DELAY_US 2
283
+/** Maximum time to wait for reset (in milliseconds) */
284
+#define SMSC75XX_RESET_MAX_WAIT_MS 100
285 285
 
286 286
 /** Maximum time to wait for EEPROM (in milliseconds) */
287 287
 #define SMSC75XX_EEPROM_MAX_WAIT_MS 100

Loading…
Cancel
Save