From patchwork Tue Oct 18 13:09:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gary guo X-Patchwork-Id: 78021 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp880274qge; Tue, 18 Oct 2016 06:16:10 -0700 (PDT) X-Received: by 10.55.23.105 with SMTP id i102mr378527qkh.301.1476796570781; Tue, 18 Oct 2016 06:16:10 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z132si20900421qkb.227.2016.10.18.06.16.10; Tue, 18 Oct 2016 06:16:10 -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 78F4760862; Tue, 18 Oct 2016 13:16:10 +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 9379C60829; Tue, 18 Oct 2016 13:12:47 +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 D0B5760D64; Tue, 18 Oct 2016 13:12:14 +0000 (UTC) Received: from mail-pf0-f176.google.com (mail-pf0-f176.google.com [209.85.192.176]) by lists.linaro.org (Postfix) with ESMTPS id B847960D64 for ; Tue, 18 Oct 2016 13:11:44 +0000 (UTC) Received: by mail-pf0-f176.google.com with SMTP id e6so94375529pfk.3 for ; Tue, 18 Oct 2016 06:11:44 -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:in-reply-to :references; bh=HWpLyKxE/aswFtyKAIzITTfv6femSKkcIMguLkvjlbU=; b=OOI149lbCrtQAqhju2TuUBlT9oJF35+JRtWgttP57G5WVPbXhkJdRaTuueBhykYs/A gsPWbsqvAMLaEdBgKkOx6qbMlTWOrFzSsTEuFUloSYNpJLDeRfzsp9HQkpxA+NSTjQKU Klhe+gIHFe8+M0NcnY3LkAGObW1f7+EjNxtHGAAJHU8N2EqjstlhSOc2HOLg45DtPoVi KNBDT7qkJ7Kzd6wUYFOLJdXy6B7vzK1TSFZezGxTkHWslZXb8anHyyt861SFb9QvLEOY ZtPDMRxHcvoJXuNOLkBqwD2p9PQH890olN1alkcL6aUvxgeaB0jZdplyL9xHMsoL0iOI Eo0A== X-Gm-Message-State: AA6/9RkltjcwtRGHY8juX3IpKQDGuydM6aUod08MNoh9q9Q2rEzq7XwtlHpWv4AgwbzpL8I+lrs= X-Received: by 10.99.221.85 with SMTP id g21mr330611pgj.121.1476796303849; Tue, 18 Oct 2016 06:11:43 -0700 (PDT) Received: from localhost.localdomain ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id a88sm56088460pfe.21.2016.10.18.06.11.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Oct 2016 06:11:43 -0700 (PDT) From: Heyi Guo To: linaro-uefi@lists.linaro.org Date: Tue, 18 Oct 2016 21:09:55 +0800 Message-Id: <1476796207-94336-12-git-send-email-heyi.guo@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476796207-94336-1-git-send-email-heyi.guo@linaro.org> References: <1476796207-94336-1-git-send-email-heyi.guo@linaro.org> 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; }