From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olof Johansson Date: Thu, 8 Oct 2009 01:59:02 -0500 Subject: [U-Boot] [PATCH v3] TI: OMAP3: Overo Tobi ethernet support In-Reply-To: <4ACD730E.1020107@googlemail.com> References: <20090911204750.GA22246@lixom.net> <20090923145556.GA28659@lixom.net> <20090926211434.GB21538@lixom.net> <5e088bd90910050656l265d6fav32fe3bd86fd06250@mail.gmail.com> <4ACD6FA9.3070905@googlemail.com> <5e088bd90910072156t25c15421h6a5b058b7ee548e0@mail.gmail.com> <4ACD730E.1020107@googlemail.com> Message-ID: <20091008065902.GA12935@lixom.net> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Thu, Oct 08, 2009 at 07:05:18AM +0200, Dirk Behme wrote: > Steve Sakoman wrote: >> On Wed, Oct 7, 2009 at 9:50 PM, Dirk Behme wrote: >>> Olof Johansson wrote: >>>> On Oct 5, 2009, at 8:56 AM, Steve Sakoman wrote: >>>> >>>>> On Sat, Sep 26, 2009 at 2:14 PM, Olof Johansson wrote: >>>>>> Add setup for ethernet on Tobi, allowing kernel/ramdisk to be loaded >>>>>> over tftp. >>>>>> >>>>>> This also refactors 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. >>>>>> >>>>> Hmm . . . I just tried this on a board without smc911x chip and it >>>>> seems to hang after printing "Net". >>>>> >>>>> Did it work for you in this case? Haven't had time to debug yet, but >>>>> will try to look later today. >>>> The only hardware I have is tobi, which is why I thought I cc:d you as >>>> well as asked others to test with other carriers if they had them. >>>> >>>> I guess first thing to find out is if it's the first read that hangs or >>>> what. >>> Any idea how to go on with this? I have no Tobi, so unfortunately I can't >>> help here. >> >> I've been testing the patch below, which seems to work with all boards >> I've tried. It simply moves the test a bit earlier. > > Great, thanks! > > Olof: Could you test this? If it works for you, too, we should apply it > on top of u-boot-ti (and u-boot-arm/next) then (or modify initial [1] ?). > > Most probably we need a Signed-off-by then ;) Take your pick. Either a: Acked-by: Olof Johansson Or apply the below revised patch instead. 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. Based on testing from Steve Sakoman, the test has been moved up in the function to not hang on systems without ethernet. Signed-off-by: Olof Johansson Acked-by: Dirk Behme Acked-by: Ben Warren --- drivers/net/smc911x.c | 14 ++++++++------ drivers/net/smc911x.h | 7 +++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index 18a729c..df73478 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, @@ -253,6 +249,12 @@ int smc911x_initialize(u8 dev_num, int base_addr) dev->iobase = base_addr; + /* Try to detect chip. Will fail if not present. */ + if (smc911x_detect_chip(dev)) { + free(dev); + return 0; + } + addrh = smc911x_get_mac_csr(dev, ADDRH); addrl = smc911x_get_mac_csr(dev, ADDRL); dev->enetaddr[0] = addrl; diff --git a/drivers/net/smc911x.h b/drivers/net/smc911x.h index 053e330..d5bca63 100644 --- a/drivers/net/smc911x.h +++ b/drivers/net/smc911x.h @@ -441,7 +441,10 @@ static int smc911x_detect_chip(struct eth_device *dev) unsigned long val, i; val = smc911x_reg_read(dev, BYTE_TEST); - if (val != 0x87654321) { + if (val == 0xffffffff) { + /* Special case -- no chip present */ + return -1; + } else if (val != 0x87654321) { printf(DRIVERNAME ": Invalid chip endian 0x%08lx\n", val); return -1; } @@ -455,7 +458,7 @@ static int smc911x_detect_chip(struct eth_device *dev) return -1; } - printf(DRIVERNAME ": detected %s controller\n", chip_ids[i].name); + dev->priv = (void *)&chip_ids[i]; return 0; } -- 1.6.3.3