[PATCH 06/52] sfc: Reduce delays in SFE4001 initialisation

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ben Hutchings
Date: Monday, September 1, 2008 - 4:45 am

Currently the board initialisation includes 2 delays of 1 second each.
Usually it is unnecessary to wait that long, so check before doing so.

Correct some of the comments and log messages while we're here.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 drivers/net/sfc/sfe4001.c |   57 +++++++++++++++++++++++++++-----------------
 1 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/drivers/net/sfc/sfe4001.c b/drivers/net/sfc/sfe4001.c
index b278495..f927281 100644
--- a/drivers/net/sfc/sfe4001.c
+++ b/drivers/net/sfc/sfe4001.c
@@ -145,7 +145,7 @@ MODULE_PARM_DESC(phy_flash_cfg,
 int sfe4001_init(struct efx_nic *efx)
 {
 	struct i2c_client *hwmon_client, *ioexp_client;
-	unsigned int count;
+	unsigned int i, j;
 	int rc;
 	u8 out;
 	efx_dword_t reg;
@@ -209,17 +209,24 @@ int sfe4001_init(struct efx_nic *efx)
 	if (rc)
 		goto fail_on;
 
-	/* Turn all power off then wait 1 sec. This ensures PHY is reset */
+	/* If PHY power is on, turn it all off and wait 1 second to
+	 * ensure a full reset.
+	 */
+	rc = i2c_smbus_read_byte_data(ioexp_client, P0_OUT);
+	if (rc < 0)
+		goto fail_on;
 	out = 0xff & ~((0 << P0_EN_1V2_LBN) | (0 << P0_EN_2V5_LBN) |
 		       (0 << P0_EN_3V3X_LBN) | (0 << P0_EN_5V_LBN) |
 		       (0 << P0_EN_1V0X_LBN));
-	rc = i2c_smbus_write_byte_data(ioexp_client, P0_OUT, out);
-	if (rc)
-		goto fail_on;
+	if (rc != out) {
+		EFX_INFO(efx, "power-cycling PHY\n");
+		rc = i2c_smbus_write_byte_data(ioexp_client, P0_OUT, out);
+		if (rc)
+			goto fail_on;
+		schedule_timeout_uninterruptible(HZ);
+	}
 
-	schedule_timeout_uninterruptible(HZ);
-	count = 0;
-	do {
+	for (i = 0; i < 20; ++i) {
 		/* Turn on 1.2V, 2.5V, 3.3V and 5V power rails */
 		out = 0xff & ~((1 << P0_EN_1V2_LBN) | (1 << P0_EN_2V5_LBN) |
 			       (1 << P0_EN_3V3X_LBN) | (1 << P0_EN_5V_LBN) |
@@ -238,23 +245,29 @@ int sfe4001_init(struct efx_nic *efx)
 		if (rc)
 			goto fail_on;
 
-		EFX_INFO(efx, "waiting for power (attempt %d)...\n", count);
-
-		schedule_timeout_uninterruptible(HZ);
-
-		/* Check DSP is powered */
-		rc = i2c_smbus_read_byte_data(ioexp_client, P1_IN);
-		if (rc < 0)
-			goto fail_on;
-		if (rc & (1 << P1_AFE_PWD_LBN))
-			goto done;
+		EFX_INFO(efx, "waiting for DSP boot (attempt %d)...\n", i);
 
-		/* DSP doesn't look powered in flash config mode */
-		if (sfe4001_phy_flash_cfg)
+		/* In flash config mode, DSP does not turn on AFE, so
+		 * just wait 1 second.
+		 */
+		if (sfe4001_phy_flash_cfg) {
+			schedule_timeout_uninterruptible(HZ);
 			goto done;
-	} while (++count < 20);
+		}
+
+		for (j = 0; j < 10; ++j) {
+			msleep(100);
+
+			/* Check DSP has asserted AFE power line */
+			rc = i2c_smbus_read_byte_data(ioexp_client, P1_IN);
+			if (rc < 0)
+				goto fail_on;
+			if (rc & (1 << P1_AFE_PWD_LBN))
+				goto done;
+		}
+	}
 
-	EFX_INFO(efx, "timed out waiting for power\n");
+	EFX_INFO(efx, "timed out waiting for DSP boot\n");
 	rc = -ETIMEDOUT;
 	goto fail_on;
 
-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/52] sfc: Changes for 2.6.28, Ben Hutchings, (Mon Sep 1, 4:16 am)
[PATCH 06/52] sfc: Reduce delays in SFE4001 initialisation, Ben Hutchings, (Mon Sep 1, 4:45 am)
[PATCH 07/52] sfc: Remove mistaken hardware workaround, Ben Hutchings, (Mon Sep 1, 4:46 am)
[PATCH 08/52] sfc: XMAC statistics fix-ups, Ben Hutchings, (Mon Sep 1, 4:46 am)
[PATCH 12/52] sfc: Self-test reporting cleanup, Ben Hutchings, (Mon Sep 1, 4:46 am)
[PATCH 13/52] sfc: Speed up loopback self-test, Ben Hutchings, (Mon Sep 1, 4:46 am)
[PATCH 19/52] sfc: Cleaned up struct tso_state fields, Ben Hutchings, (Mon Sep 1, 4:47 am)
[PATCH 23/52] sfc: Remove efx_channel::has_interrupt, Ben Hutchings, (Mon Sep 1, 4:47 am)
[PATCH 24/52] sfc: Cleanup RX queue information, Ben Hutchings, (Mon Sep 1, 4:47 am)
[PATCH 27/52] sfc: Remove efx_channel::evqnum field, Ben Hutchings, (Mon Sep 1, 4:48 am)
[PATCH 28/52] sfc: Cleanup RX event processing, Ben Hutchings, (Mon Sep 1, 4:48 am)
[PATCH 32/52] sfc: Enable TSO for 802.1q VLAN devices, Ben Hutchings, (Mon Sep 1, 4:48 am)
[PATCH 35/52] sfc: Remove some unreachable error paths, Ben Hutchings, (Mon Sep 1, 4:48 am)
[PATCH 36/52] sfc: Cleanup reset code, Ben Hutchings, (Mon Sep 1, 4:48 am)
[PATCH 38/52] sfc: Extend self-tests, Ben Hutchings, (Mon Sep 1, 4:49 am)
[PATCH 39/52] sfc: Remove the STATE_RESETTING flag, Ben Hutchings, (Mon Sep 1, 4:49 am)
[PATCH 40/52] sfc: Rework efx_set_multicast_hash(), Ben Hutchings, (Mon Sep 1, 4:49 am)
[PATCH 46/52] sfc: Make queue flushes more reliable, Ben Hutchings, (Mon Sep 1, 4:49 am)