diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-09-01 10:52:44 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-09-03 09:49:06 +0200 |
commit | bfcd63fdc4287fd4a600df8812bbb09c4f0aff7a (patch) | |
tree | 9ba05de0bc204a3470094d300db49dd068a543ee /drivers | |
parent | da9ef6467871c8141cb13d094bbf10bc2df79065 (diff) | |
download | barebox-bfcd63fdc4287fd4a600df8812bbb09c4f0aff7a.tar.gz barebox-bfcd63fdc4287fd4a600df8812bbb09c4f0aff7a.tar.xz |
smc911x: check if the device is ready before using it
poll the READY bit in PMT_CTRL. Any other access to the device is
forbidden while this bit isn't set. Try for 100ms
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/smc911x.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 7639a92873..3ccb0efe96 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -420,7 +420,7 @@ static int smc911x_probe(struct device_d *dev) struct eth_device *edev; struct smc911x_priv *priv; uint32_t val; - int is_32bit; + int is_32bit, ret; struct smc911x_plat *pdata = dev->platform_data; priv = xzalloc(sizeof(*priv)); @@ -452,6 +452,16 @@ static int smc911x_probe(struct device_d *dev) } } + /* + * poll the READY bit in PMT_CTRL. Any other access to the device is + * forbidden while this bit isn't set. Try for 100ms + */ + ret = wait_on_timeout(100 * MSECOND, smc911x_reg_read(priv, PMT_CTRL) & PMT_CTRL_READY); + if (!ret) { + dev_err(dev, "Device not READY in 100ms aborting\n"); + return -ENODEV; + } + val = smc911x_reg_read(priv, BYTE_TEST); if (val == 0x43218765) { dev_dbg(dev, "BYTE_TEST looks swapped, " |