From patchwork Mon Sep 13 15:52:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Moffett X-Patchwork-Id: 71846 Return-Path: X-Original-To: wd@gemini.denx.de Delivered-To: wd@gemini.denx.de Received: from diddl.denx.de (diddl.denx.de [10.0.0.6]) by gemini.denx.de (Postfix) with ESMTP id 3886715242D for ; Mon, 13 Sep 2010 17:54:20 +0200 (CEST) Received: from diddl.denx.de (localhost.localdomain [127.0.0.1]) by diddl.denx.de (Postfix) with ESMTP id 24FA631463C1 for ; Mon, 13 Sep 2010 17:54:20 +0200 (MEST) Received: from pop.mnet-online.de by diddl.denx.de with POP3 (fetchmail-6.3.17) for (single-drop); Mon, 13 Sep 2010 17:54:20 +0200 (MEST) Received: from murder ([192.168.8.180]) by backend2 (Cyrus v2.2.12) with LMTPA; Mon, 13 Sep 2010 17:54:09 +0200 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend1.mail.m-online.net (Cyrus v2.2.12) with LMTPA; Mon, 13 Sep 2010 17:54:09 +0200 Received: from scanner-3.m-online.net (unknown [192.168.6.168]) by mail.m-online.net (Postfix) with ESMTP id 219AA1C001BE; Mon, 13 Sep 2010 17:54:09 +0200 (CEST) Received: from mxin-3.m-online.net ([192.168.6.165]) by scanner-3.m-online.net (scanner-3.m-online.net [192.168.6.168]) (amavisd-new, port 10026) with ESMTP id 22624-01-5; Mon, 13 Sep 2010 17:54:07 +0200 (CEST) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-3.m-online.net (Postfix) with ESMTP id 390DB46C0B5; Mon, 13 Sep 2010 17:54:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0D6DE280F1; Mon, 13 Sep 2010 17:53:07 +0200 (CEST) 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 P0yepzB+WBZF; Mon, 13 Sep 2010 17:53:06 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C844D280F2; Mon, 13 Sep 2010 17:52:46 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 65908280B8 for ; Mon, 13 Sep 2010 17:52:43 +0200 (CEST) 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 8nia1YQMeiD2 for ; Mon, 13 Sep 2010 17:52:42 +0200 (CEST) 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 firewall1 (wsip-70-167-241-26.dc.dc.cox.net [70.167.241.26]) by theia.denx.de (Postfix) with ESMTP id 783AE280BF for ; Mon, 13 Sep 2010 17:52:33 +0200 (CEST) Received: from eternium.exmeritus.com (firewall2.exmeritus.com [10.13.38.2]) by firewall1 (Postfix) with ESMTP id AEFE7AC07E; Mon, 13 Sep 2010 11:52:32 -0400 (EDT) From: Kyle Moffett To: u-boot@lists.denx.de Date: Mon, 13 Sep 2010 11:52:24 -0400 Message-Id: <1284393146-22142-3-git-send-email-Kyle.D.Moffett@boeing.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1284393146-22142-1-git-send-email-Kyle.D.Moffett@boeing.com> References: <1284393146-22142-1-git-send-email-Kyle.D.Moffett@boeing.com> Cc: Kyle Moffett , Kyle Moffett , Ben Warren Subject: [U-Boot] [PATCH 3/5] e1000: Rewrite EEPROM checksum error to give more information 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: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Virus-Scanned: by amavisd-new at m-online.net As an aide to debugging, we should print out the expected value of the EEPROM checksum in addition to just saying that it is wrong. Signed-off-by: Kyle Moffett --- drivers/net/e1000.c | 48 ++++++++++++++++++++++++++++++------------------ 1 files changed, 30 insertions(+), 18 deletions(-) diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c index f6c9be5..43b25b2 100644 --- a/drivers/net/e1000.c +++ b/drivers/net/e1000.c @@ -873,29 +873,43 @@ e1000_read_eeprom(struct e1000_hw *hw, uint16_t offset, * If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is * valid. *****************************************************************************/ -static int -e1000_validate_eeprom_checksum(struct eth_device *nic) +static int e1000_validate_eeprom_checksum(struct e1000_hw *hw) { - struct e1000_hw *hw = nic->priv; - uint16_t checksum = 0; - uint16_t i, eeprom_data; + uint16_t i, checksum, checksum_reg, *buf; DEBUGFUNC(); - for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) { - if (e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) { - DEBUGOUT("EEPROM Read Error\n"); - return -E1000_ERR_EEPROM; - } - checksum += eeprom_data; + /* Allocate a temporary buffer */ + buf = malloc(sizeof(buf[0]) * (EEPROM_CHECKSUM_REG + 1)); + if (!buf) { + printf("%s: ERROR: Unable to allocate EEPROM buffer!\n", + hw->nic->name); + return -E1000_ERR_EEPROM; } - if (checksum == (uint16_t) EEPROM_SUM) { - return 0; - } else { - DEBUGOUT("EEPROM Checksum Invalid\n"); + /* Read the EEPROM */ + if (e1000_read_eeprom(hw, 0, EEPROM_CHECKSUM_REG + 1, buf) < 0) { + printf("%s: ERROR: Unable to read EEPROM!\n", + hw->nic->name); return -E1000_ERR_EEPROM; } + + /* Compute the checksum */ + for (i = 0; i < EEPROM_CHECKSUM_REG; i++) + checksum += buf[i]; + checksum = ((uint16_t)EEPROM_SUM) - checksum; + checksum_reg = buf[i]; + + /* Verify it! */ + if (checksum == checksum_reg) + return 0; + + /* Hrm, verification failed, print an error */ + printf("%s: ERROR: EEPROM checksum is incorrect!\n", hw->nic->name); + printf("%s: ERROR: ...register was 0x%04hx, calculated 0x%04hx\n", + hw->nic->name, checksum_reg, checksum); + + return -E1000_ERR_EEPROM; } /***************************************************************************** @@ -5221,10 +5235,8 @@ e1000_initialize(bd_t * bis) printf("%s: ERROR: EEPROM is invalid!\n", nic->name); continue; } - if (e1000_validate_eeprom_checksum(nic) < 0) { - printf("%s: ERROR: EEPROM checksum is bad!\n", nic->name); + if (e1000_validate_eeprom_checksum(hw)) continue; - } #endif e1000_read_mac_addr(nic); e1000_get_bus_type(hw);