diff options
author | Olof Johansson <olof@lixom.net> | 2009-09-29 10:21:29 -0400 |
---|---|---|
committer | Tom Rix <Tom.Rix@windriver.com> | 2009-10-13 06:17:37 -0500 |
commit | 2a6cc97b91997ae485312ac91ffbcea6a89b663a (patch) | |
tree | f17675c5af12eb4dad8b93249bb3bdda59bfe322 /drivers/net/smc911x.c | |
parent | 0297ec7e2a4039b8a28346f52f3ccca4db1ddc62 (diff) | |
download | u-boot-imx-2a6cc97b91997ae485312ac91ffbcea6a89b663a.zip u-boot-imx-2a6cc97b91997ae485312ac91ffbcea6a89b663a.tar.gz u-boot-imx-2a6cc97b91997ae485312ac91ffbcea6a89b663a.tar.bz2 |
SMC911X: Add chip auto detection
Refactor the smc911x driver to allow for detecting when the chip is missing.
I.e. the detect_chip() function is called earlier and will abort gracefully
when the Chip ID read returns all 1's.
Signed-off-by: Olof Johansson <olof@lixom.net>
Acked-by: Dirk Behme <dirk.behme@googlemail.com>
Acked-by: Ben Warren <biggerbadderben@gmail.com>
Diffstat (limited to 'drivers/net/smc911x.c')
-rw-r--r-- | drivers/net/smc911x.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 18a729c..b106ec9 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c @@ -146,10 +146,9 @@ static void smc911x_enable(struct eth_device *dev) static int smc911x_init(struct eth_device *dev, bd_t * bd) { - printf(DRIVERNAME ": initializing\n"); + struct chip_id *id = dev->priv; - if (smc911x_detect_chip(dev)) - goto err_out; + printf(DRIVERNAME ": detected %s controller\n", id->name); smc911x_reset(dev); @@ -162,9 +161,6 @@ static int smc911x_init(struct eth_device *dev, bd_t * bd) smc911x_enable(dev); return 0; - -err_out: - return -1; } static int smc911x_send(struct eth_device *dev, @@ -268,6 +264,12 @@ int smc911x_initialize(u8 dev_num, int base_addr) dev->recv = smc911x_rx; sprintf(dev->name, "%s-%hu", DRIVERNAME, dev_num); + /* Try to detect chip. Will fail if not present. */ + if (smc911x_detect_chip(dev)) { + free(dev); + return 0; + } + eth_register(dev); return 0; } |