[PATCH 07/20] sfc: SFN4111T: Fix GPIO sharing between I2C and FLASH_CFG_1

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ben Hutchings
Date: Thursday, January 29, 2009 - 12:18 pm

Change sfn4111t_reset() to change only GPIO output enables so that it
doesn't break subsequent I2C operations.

Update comments to explain exactly what we're doing.

Add a short sleep to make sure the FLASH_CFG_1 value is latched before
any subsequent I2C operations.

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

diff --git a/drivers/net/sfc/sfe4001.c b/drivers/net/sfc/sfe4001.c
index 2e9b4b4..95bb935 100644
--- a/drivers/net/sfc/sfe4001.c
+++ b/drivers/net/sfc/sfe4001.c
@@ -186,19 +186,22 @@ static int sfn4111t_reset(struct efx_nic *efx)
 {
 	efx_oword_t reg;
 
-	/* GPIO pins are also used for I2C, so block that temporarily */
+	/* GPIO 3 and the GPIO register are shared with I2C, so block that */
 	mutex_lock(&efx->i2c_adap.bus_lock);
 
+	/* Pull RST_N (GPIO 2) low then let it up again, setting the
+	 * FLASH_CFG_1 strap (GPIO 3) appropriately.  Only change the
+	 * output enables; the output levels should always be 0 (low)
+	 * and we rely on external pull-ups. */
 	falcon_read(efx, &reg, GPIO_CTL_REG_KER);
 	EFX_SET_OWORD_FIELD(reg, GPIO2_OEN, true);
-	EFX_SET_OWORD_FIELD(reg, GPIO2_OUT, false);
 	falcon_write(efx, &reg, GPIO_CTL_REG_KER);
 	msleep(1000);
-	EFX_SET_OWORD_FIELD(reg, GPIO2_OUT, true);
-	EFX_SET_OWORD_FIELD(reg, GPIO3_OEN, true);
-	EFX_SET_OWORD_FIELD(reg, GPIO3_OUT,
-			    !(efx->phy_mode & PHY_MODE_SPECIAL));
+	EFX_SET_OWORD_FIELD(reg, GPIO2_OEN, false);
+	EFX_SET_OWORD_FIELD(reg, GPIO3_OEN,
+			    !!(efx->phy_mode & PHY_MODE_SPECIAL));
 	falcon_write(efx, &reg, GPIO_CTL_REG_KER);
+	msleep(1);
 
 	mutex_unlock(&efx->i2c_adap.bus_lock);
 

-- 
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/20] sfc: Fixes and new PHY support for 2.6.29, Ben Hutchings, (Thu Jan 29, 12:12 pm)
[PATCH 02/20] sfc: Fix test for MDIO read failure, Ben Hutchings, (Thu Jan 29, 12:16 pm)
[PATCH 03/20] sfc: SFT9001: Enable robust link training, Ben Hutchings, (Thu Jan 29, 12:17 pm)
[PATCH 07/20] sfc: SFN4111T: Fix GPIO sharing between I2C ..., Ben Hutchings, (Thu Jan 29, 12:18 pm)
[PATCH 08/20] sfc: Fix post-reset MAC selection, Ben Hutchings, (Thu Jan 29, 12:19 pm)
[PATCH 13/20] sfc: SFX7101/SFT9001: Fix AN advertisements, Ben Hutchings, (Thu Jan 29, 12:20 pm)
[PATCH 15/20] sfc: Fix reporting of PHY id, Ben Hutchings, (Thu Jan 29, 12:20 pm)
[PATCH 16/20] sfc: Add support for QT2025C PHY, Ben Hutchings, (Thu Jan 29, 12:21 pm)
[PATCH 18/20] sfc: Clean up LED control, Ben Hutchings, (Thu Jan 29, 12:21 pm)
[PATCH 01/11] sfc: SFT9001: Enable robust link training, Ben Hutchings, (Thu Jan 29, 8:48 pm)
[PATCH 05/11] sfc: Fix post-reset MAC selection, Ben Hutchings, (Thu Jan 29, 8:49 pm)
[PATCH 10/11] sfc: SFX7101/SFT9001: Fix AN advertisements, Ben Hutchings, (Thu Jan 29, 8:59 pm)