From patchwork Wed Oct 19 01:03:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 78150 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp1156089qge; Tue, 18 Oct 2016 18:04:41 -0700 (PDT) X-Received: by 10.31.131.74 with SMTP id f71mr3590731vkd.7.1476839081390; Tue, 18 Oct 2016 18:04:41 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 192si19137757vkf.246.2016.10.18.18.04.40; Tue, 18 Oct 2016 18:04:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B5C80609F8; Wed, 19 Oct 2016 01:04:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2 autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 293F560E3B; Wed, 19 Oct 2016 01:04:36 +0000 (UTC) X-Original-To: linaro-uefi@lists.linaro.org Delivered-To: linaro-uefi@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 7811C61611; Wed, 19 Oct 2016 01:04:31 +0000 (UTC) Received: from mail-pf0-f174.google.com (mail-pf0-f174.google.com [209.85.192.174]) by lists.linaro.org (Postfix) with ESMTPS id 41E9B609F8 for ; Wed, 19 Oct 2016 01:04:30 +0000 (UTC) Received: by mail-pf0-f174.google.com with SMTP id e6so5519752pfk.3 for ; Tue, 18 Oct 2016 18:04:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HWpLyKxE/aswFtyKAIzITTfv6femSKkcIMguLkvjlbU=; b=lMmpamCn/Ywzk5T95g+TqRQ5IjptmhPupsczl44J3fmXQiPQOPe4SlmL+9I2XZIpAa nOhM/G6L+aAK9+e/UZUdAXgWojw+FhmW1P2V+nRTNgls+aYOE+QtiCvCURqUCUkFbbrS Xh5bREkZQlqFU/sn19hXwJZQWjNFbAbVMwHw0CeDLsKMY9Xkm/Lw+mr1aWu/5QjN3nU/ FIL0GtBwEKqPRansrCwroRgvFsDkTwyRh5k1TVPOsh97kexkSYL9p127w3lis7gPhFD4 fZRpKt11BvdnhB5KCtUteUT2jeiwO/5P8PnfYTuBW9rGjzwKqAc1zcfOHIlC04CMoN0A NKHw== X-Gm-Message-State: AA6/9RnQgrXoO8OTF4hC+gV75yYDnpN+pjmlJzqwK4jumX+zPSwgjyr8SSe5klRVTeOd83iHYyY= X-Received: by 10.98.71.86 with SMTP id u83mr5768006pfa.180.1476839069509; Tue, 18 Oct 2016 18:04:29 -0700 (PDT) Received: from localhost.localdomain ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id g21sm58616083pfb.43.2016.10.18.18.04.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Oct 2016 18:04:28 -0700 (PDT) From: Heyi Guo To: linaro-uefi@lists.linaro.org Date: Wed, 19 Oct 2016 09:03:59 +0800 Message-Id: <1476839040-94656-1-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 1.9.1 Cc: Peicong Li Subject: [Linaro-uefi] [PATCH v2 11/24] D03/D05: Change to access EEPROM data bytewise X-BeenThere: linaro-uefi@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-uefi-bounces@lists.linaro.org Sender: "Linaro-uefi" From: Peicong Li We would get incorrect data when accessing multiple bytes at one time and going across EEPROM page boundary, so we change to access EEPROM by single byte each time. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Peicong Li --- .../D03/Drivers/OemNicConfig2PHi1610/OemNicConfig2P.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Platforms/Hisilicon/D03/Drivers/OemNicConfig2PHi1610/OemNicConfig2P.c b/Platforms/Hisilicon/D03/Drivers/OemNicConfig2PHi1610/OemNicConfig2P.c index 994ed6a..31fd333 100644 --- a/Platforms/Hisilicon/D03/Drivers/OemNicConfig2PHi1610/OemNicConfig2P.c +++ b/Platforms/Hisilicon/D03/Drivers/OemNicConfig2PHi1610/OemNicConfig2P.c @@ -110,6 +110,7 @@ EFI_STATUS OemGetMacE2prom(IN UINT32 Port, OUT UINT8 *pucAddr) UINT16 I2cOffset; UINT16 crc16; NIC_MAC_ADDRESS stMacDesc = {0}; + UINT32 Index; Status = I2CInit(0, EEPROM_I2C_PORT, Normal); if (EFI_ERROR(Status)) @@ -124,9 +125,10 @@ EFI_STATUS OemGetMacE2prom(IN UINT32 Port, OUT UINT8 *pucAddr) stI2cDev.Port = EEPROM_I2C_PORT; stI2cDev.SlaveDeviceAddress = I2C_SLAVEADDR_EEPROM; stI2cDev.Socket = 0; - Status = I2CRead(&stI2cDev, I2cOffset, sizeof(NIC_MAC_ADDRESS), (UINT8 *)&stMacDesc); - if (EFI_ERROR(Status)) - { + for (Index = 0; Index < sizeof(NIC_MAC_ADDRESS); Index++) { + Status |= I2CRead(&stI2cDev, I2cOffset + Index, 1, (UINT8 *)&stMacDesc + Index); + } + if (EFI_ERROR(Status)) { DEBUG((EFI_D_ERROR, "[%a]:[%dL] Call I2cRead failed! p1=0x%x.\n", __FUNCTION__, __LINE__, Status)); return Status; } @@ -150,6 +152,7 @@ EFI_STATUS OemSetMacE2prom(IN UINT32 Port, IN UINT8 *pucAddr) EFI_STATUS Status; UINT16 I2cOffset; NIC_MAC_ADDRESS stMacDesc = {0}; + UINTN Index; stMacDesc.MacLen = MAC_ADDR_LEN; @@ -170,9 +173,11 @@ EFI_STATUS OemSetMacE2prom(IN UINT32 Port, IN UINT8 *pucAddr) stI2cDev.Port = EEPROM_I2C_PORT; stI2cDev.SlaveDeviceAddress = I2C_SLAVEADDR_EEPROM; stI2cDev.Socket = 0; - Status = I2CWrite(&stI2cDev, I2cOffset, sizeof(NIC_MAC_ADDRESS), (UINT8 *)&stMacDesc); - if (EFI_ERROR(Status)) - { + for (Index = 0; Index < sizeof(NIC_MAC_ADDRESS); Index++) { + Status |= I2CWrite(&stI2cDev, I2cOffset + Index, 1, (UINT8 *)&stMacDesc + Index); + } + + if (EFI_ERROR(Status)) { DEBUG((EFI_D_ERROR, "[%a]:[%dL] Call I2cWrite failed! p1=0x%x.\n", __FUNCTION__, __LINE__, Status)); return Status; }