From patchwork Sun Dec 26 02:43:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yanjun Yang X-Patchwork-Id: 76714 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id E12A4B70E2 for ; Sun, 26 Dec 2010 13:43:08 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6FA55280B8; Sun, 26 Dec 2010 03:43:07 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oQjf39l3GGhL; Sun, 26 Dec 2010 03:43:07 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E1DA2280AB; Sun, 26 Dec 2010 03:43:04 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5D581280AB for ; Sun, 26 Dec 2010 03:43:03 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bFdQWz7F4Lxl for ; Sun, 26 Dec 2010 03:43:01 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-qw0-f44.google.com (mail-qw0-f44.google.com [209.85.216.44]) by theia.denx.de (Postfix) with ESMTP id 7B8A4280A0 for ; Sun, 26 Dec 2010 03:43:01 +0100 (CET) Received: by qwg5 with SMTP id 5so7548435qwg.3 for ; Sat, 25 Dec 2010 18:43:00 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.81.206 with SMTP id y14mr9704366qck.127.1293331380046; Sat, 25 Dec 2010 18:43:00 -0800 (PST) Received: by 10.229.101.193 with HTTP; Sat, 25 Dec 2010 18:43:00 -0800 (PST) Date: Sun, 26 Dec 2010 10:43:00 +0800 Message-ID: From: Yanjun Yang To: u-boot@lists.denx.de Subject: [U-Boot] [RFC] Make sure the chip reset and init right X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de It seems that the chip can only be reset into a known state by using attribute space. The smc_reset and smc_enable function also need more lines to make the chip work. Signed-off-by: YanJun Yang --- drivers/net/lan91c96.c | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) /* This resets the registers mostly to defaults, but doesn't @@ -231,8 +233,11 @@ static void smc_reset(struct eth_device *dev) /* set the control register */ SMC_SELECT_BANK(dev, 1); - SMC_outw(dev, SMC_inw(dev, LAN91C96_CONTROL) | LAN91C96_CTR_BIT_8, - LAN91C96_CONTROL); + tmp = SMC_inw(dev, LAN91C96_CONFIG); + tmp |= LAN91C96_CR_SET_SQLCH | LAN91C96_CR_NO_WAIT | LAN91C96_CR_16BIT; + tmp &= ~(LAN91C96_CR_DIS_LINK | LAN91C96_CR_AUI_SELECT); + SMC_outw(dev, tmp, LAN91C96_CONFIG); + SMC_outw(dev, LAN91C96_CTR_TE_ENABLE | LAN91C96_CTR_BIT_8, LAN91C96_CONTROL); /* Disable all interrupts */ SMC_outb(dev, 0, LAN91C96_INT_MASK); @@ -256,7 +261,7 @@ static void smc_enable(struct eth_device *dev) SMC_outw(dev, LAN91C96_MCR_TRANSMIT_PAGES, LAN91C96_MCR); /* Initialize the Transmit Control Register */ - SMC_outw(dev, LAN91C96_TCR_TXENA, LAN91C96_TCR); + SMC_outw(dev, LAN91C96_TCR_TXENA | LAN91C96_TCR_PAD_EN | LAN91C96_TCR_FDSE, LAN91C96_TCR); /* Initialize the Receive Control Register * FIXME: * The promiscuous bit set because I could not receive ARP reply @@ -264,6 +269,7 @@ static void smc_enable(struct eth_device *dev) * when I set the promiscuous bit */ SMC_outw(dev, LAN91C96_RCR_RXEN | LAN91C96_RCR_PRMS, LAN91C96_RCR); + udelay( 750 ); } /* @@ -791,6 +797,7 @@ static int lan91c96_detect_chip(struct eth_device *dev) int lan91c96_initialize(u8 dev_num, int base_addr) { struct eth_device *dev; + volatile unsigned *attaddr = (unsigned *)CONFIG_LAN91C96_ATTR; int r = 0; dev = malloc(sizeof(*dev)); @@ -799,8 +806,19 @@ int lan91c96_initialize(u8 dev_num, int base_addr) } memset(dev, 0, sizeof(*dev)); - dev->iobase = base_addr; + /* first reset, then enable the device. Sequence is critical */ + attaddr[LAN91C96_ECOR] |= LAN91C96_ECOR_SRESET; + udelay( 750 ); + attaddr[LAN91C96_ECOR] &= ~LAN91C96_ECOR_SRESET; + udelay( 750 ); + attaddr[LAN91C96_ECOR] |= LAN91C96_ECOR_ENABLE; + udelay( 750 ); + /* force 16-bit mode */ + attaddr[LAN91C96_ECSR] &= ~LAN91C96_ECSR_IOIS8; + udelay( 750 ); + + dev->iobase = base_addr; /* Try to detect chip. Will fail if not present. */ r = lan91c96_detect_chip(dev); if (!r) { -- 1.5.6.5 diff --git a/drivers/net/lan91c96.c b/drivers/net/lan91c96.c index 2550aa2..0b3321f 100644 --- a/drivers/net/lan91c96.c +++ b/drivers/net/lan91c96.c @@ -216,6 +216,8 @@ static int poll4int (struct eth_device *dev, byte mask, int timeout) */ static void smc_reset(struct eth_device *dev) { + unsigned int tmp; + PRINTK2("%s:smc_reset\n", dev->name);