Skip to content

Commit

Permalink
[smsc75xx] Allow up to 100ms for reset to complete
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jun 20, 2016
1 parent 040aa98 commit c917687
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
23 changes: 14 additions & 9 deletions src/drivers/net/smsc75xx.c
Expand Up @@ -511,6 +511,7 @@ static int smsc75xx_dump_statistics ( struct smsc75xx_device *smsc75xx ) {
*/
static int smsc75xx_reset ( struct smsc75xx_device *smsc75xx ) {
uint32_t hw_cfg;
unsigned int i;
int rc;

/* Reset device */
Expand All @@ -519,18 +520,22 @@ static int smsc75xx_reset ( struct smsc75xx_device *smsc75xx ) {
return rc;

/* Wait for reset to complete */
udelay ( SMSC75XX_RESET_DELAY_US );
for ( i = 0 ; i < SMSC75XX_RESET_MAX_WAIT_MS ; i++ ) {

/* Check that reset has completed */
if ( ( rc = smsc75xx_readl ( smsc75xx, SMSC75XX_HW_CFG,
&hw_cfg ) ) != 0 )
return rc;
if ( hw_cfg & SMSC75XX_HW_CFG_LRST ) {
DBGC ( smsc75xx, "SMSC75XX %p failed to reset\n", smsc75xx );
return -ETIMEDOUT;
/* Check if reset has completed */
if ( ( rc = smsc75xx_readl ( smsc75xx, SMSC75XX_HW_CFG,
&hw_cfg ) ) != 0 )
return rc;
if ( ! ( hw_cfg & SMSC75XX_HW_CFG_LRST ) )
return 0;

/* Delay */
mdelay ( 1 );
}

return 0;
DBGC ( smsc75xx, "SMSC75XX %p timed out waiting for reset\n",
smsc75xx );
return -ETIMEDOUT;
}

/******************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/net/smsc75xx.h
Expand Up @@ -280,8 +280,8 @@ struct smsc75xx_device {
uint32_t int_sts;
};

/** Reset delay (in microseconds) */
#define SMSC75XX_RESET_DELAY_US 2
/** Maximum time to wait for reset (in milliseconds) */
#define SMSC75XX_RESET_MAX_WAIT_MS 100

/** Maximum time to wait for EEPROM (in milliseconds) */
#define SMSC75XX_EEPROM_MAX_WAIT_MS 100
Expand Down

0 comments on commit c917687

Please sign in to comment.