Patchwork [1/2] net/smsc911x: Always wait for the chip to be ready

login
register
mail settings
Submitter Linus Walleij
Date Oct. 26, 2011, 8:05 a.m.
Message ID <1319616343-6357-1-git-send-email-linus.walleij@stericsson.com>
Download mbox | patch
Permalink /patch/121852/
State Accepted
Delegated to: David Miller
Headers show

Comments

Linus Walleij - Oct. 26, 2011, 8:05 a.m.
From: Robert Marklund <robert.marklund@stericsson.com>

Wait for the chip to be ready before any access to it. On the
Snowball platform we need to enable an external regulator before
the chip comes online, and then it happens that the device is
not yet ready at probe time, so let's wait for it.

Signed-off-by: Robert Marklund <robert.marklund@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/net/ethernet/smsc/smsc911x.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
Linus Walleij - Nov. 8, 2011, 10:34 a.m.
2011/10/26 Linus Walleij <linus.walleij@stericsson.com>:

> From: Robert Marklund <robert.marklund@stericsson.com>
>
> Wait for the chip to be ready before any access to it. On the
> Snowball platform we need to enable an external regulator before
> the chip comes online, and then it happens that the device is
> not yet ready at probe time, so let's wait for it.
>
> Signed-off-by: Robert Marklund <robert.marklund@stericsson.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Since there doesn't seem to be any consternation concerning
this first patch, can it be applied?

Yours,
Linus Walleij
--
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
David Miller - Nov. 14, 2011, 5:41 a.m.
From: Linus Walleij <linus.walleij@linaro.org>
Date: Tue, 8 Nov 2011 11:34:01 +0100

> 2011/10/26 Linus Walleij <linus.walleij@stericsson.com>:
> 
>> From: Robert Marklund <robert.marklund@stericsson.com>
>>
>> Wait for the chip to be ready before any access to it. On the
>> Snowball platform we need to enable an external regulator before
>> the chip comes online, and then it happens that the device is
>> not yet ready at probe time, so let's wait for it.
>>
>> Signed-off-by: Robert Marklund <robert.marklund@stericsson.com>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> 
> Since there doesn't seem to be any consternation concerning
> this first patch, can it be applied?

Applied, thanks.
--
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

Patch

diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index d2be42a..8843071 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -1937,6 +1937,7 @@  static int __devinit smsc911x_init(struct net_device *dev)
 {
 	struct smsc911x_data *pdata = netdev_priv(dev);
 	unsigned int byte_test;
+	unsigned int to = 100;
 
 	SMSC_TRACE(pdata, probe, "Driver Parameters:");
 	SMSC_TRACE(pdata, probe, "LAN base: 0x%08lX",
@@ -1952,6 +1953,17 @@  static int __devinit smsc911x_init(struct net_device *dev)
 		return -ENODEV;
 	}
 
+	/*
+	 * poll the READY bit in PMT_CTRL. Any other access to the device is
+	 * forbidden while this bit isn't set. Try for 100ms
+	 */
+	while (!(smsc911x_reg_read(pdata, PMT_CTRL) & PMT_CTRL_READY_) && --to)
+		udelay(1000);
+	if (to == 0) {
+		pr_err("Device not READY in 100ms aborting\n");
+		return -ENODEV;
+	}
+
 	/* Check byte ordering */
 	byte_test = smsc911x_reg_read(pdata, BYTE_TEST);
 	SMSC_TRACE(pdata, probe, "BYTE_TEST: 0x%08X", byte_test);