From patchwork Wed Oct 19 01:31:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 78156 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp4433qge; Tue, 18 Oct 2016 18:32:03 -0700 (PDT) X-Received: by 10.31.78.69 with SMTP id c66mr3208553vkb.25.1476840723885; Tue, 18 Oct 2016 18:32:03 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q200si19189055vkd.178.2016.10.18.18.31.59; Tue, 18 Oct 2016 18:32:03 -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 B866F61636; Wed, 19 Oct 2016 01:31:59 +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 D74E361625; Wed, 19 Oct 2016 01:31:55 +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 E05556162D; Wed, 19 Oct 2016 01:31:53 +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 A5AE561620 for ; Wed, 19 Oct 2016 01:31:52 +0000 (UTC) Received: by mail-pf0-f174.google.com with SMTP id 128so5935679pfz.0 for ; Tue, 18 Oct 2016 18:31:52 -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=3p72EjolwkyZv4HQT3s3bMx1hNap5gsjIQt0hlgahjU=; b=jm266+5/fE16AizVaMrpGf74ZIftX2GuLkiv5nf+6ZfScnTEuPMOEaM+muubjyo5x+ coc9Ub2n0qdD3+vO+iYPUnL6WQRcMyiyeWr55PnMZ9lePEeuZffoMKyff4m2uD77KKdN PEl9garEYRHRxCFgoVb4a3hbg7sshJtBEU7WLSnPHpwq8Ad9VO8Uv+6Sb5JiqmbWXk7m ymstV4q8CmID2E5+GPyGV179pr0mblUYYDPdOVVOWweCBq5yyrPrhIfBqsf1vnbBhUZI hyCNQYruCRrRGvFO9if23MwlNOeehIeveiEqkEY9eKqEnpBJ9nEtI/8jf9itxLtxKG9o +7dQ== X-Gm-Message-State: AA6/9RlF4xhujhj7DUjd8IQ4rr3YJXfks8QOeefv2sGkTb00M5pkFiyh6mkjGbnOK0nSiJtcUAo= X-Received: by 10.98.89.73 with SMTP id n70mr5990365pfb.82.1476840711630; Tue, 18 Oct 2016 18:31:51 -0700 (PDT) Received: from localhost.localdomain ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id ad15sm58858808pac.33.2016.10.18.18.31.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Oct 2016 18:31:50 -0700 (PDT) From: Heyi Guo To: linaro-uefi@lists.linaro.org Date: Wed, 19 Oct 2016 09:31:25 +0800 Message-Id: <1476840686-94794-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" 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; }