From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EEAB5210C1234 for ; Tue, 24 Jul 2018 00:15:46 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id p23-v6so2211624pgv.13 for ; Tue, 24 Jul 2018 00:15:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NsFsPiwqccnnvfWT/FouJV1SJoYad+yMslSalkm6CuI=; b=AkUe8rhioIsnYOcFqjt4OCDN3MsBzPiXXc5QXkxP9TN3RGLXV4572Tx1iyRgxkTfF8 R8dWnI0vjKhgSKRX7A56jdA5Q6IdSxv68A4lQrBDXrTKU1sbRHiVBd01yXJ4hz2EiR29 sKs436a0MYtbGMa/5kJN2og97DdkN0MBUDip4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NsFsPiwqccnnvfWT/FouJV1SJoYad+yMslSalkm6CuI=; b=nvViDCU6liVxBszlO1l2PpRVwr5dcM+pHQhTe3MLVRDU0oZqg2kIl9Y69ubhxkxlB8 IqM8anxm7WbscDnLfVh+x0DDXAiwZD4o6ntI+ZxYc5y949fvwGb+2PIf21nKFgRBd2+F pAfbSpC3EhP210O0oxxaOGUHDajhgAepoBzuQYC3HpiPmSb5PSj6ms8NTZ3TDeZD7elN daay19dy+Xex8zAduhDCTjmFOV+YwaoDpytG0cDbnfg1a0gtGwY/fR88h50Yg1cveyXH Baklt4GYqK0Pg8Vw5nR1nBMUqNIdBDpNsfwuec6Pz3k8RL+E8DDTH/nEtbqZ3LKV9n4l rhUA== X-Gm-Message-State: AOUpUlHrNeavxZPF7WFNJZqDM07EKJsY//Nh4he1W+E8XXWtWtc8QXta bPzOxrUI7WifiHuhNZZmyjShEg== X-Google-Smtp-Source: AAOMgpc3cTwugfLTqZJeHuKb+MnDMvEtdJAMCX0efIpCeuQ5LYvwOgw2RDbZoa7eO6METEazIiH9wA== X-Received: by 2002:a62:da07:: with SMTP id c7-v6mr16458613pfh.106.1532416546710; Tue, 24 Jul 2018 00:15:46 -0700 (PDT) Received: from localhost.localdomain ([120.31.149.194]) by smtp.gmail.com with ESMTPSA id t14-v6sm11449788pgu.0.2018.07.24.00.15.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Jul 2018 00:15:46 -0700 (PDT) From: Ming Huang To: leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org, graeme.gregory@linaro.org Cc: ard.biesheuvel@linaro.org, guoheyi@huawei.com, wanghuiqiang@huawei.com, huangming23@huawei.com, zhangjinsong2@huawei.com, huangdaode@hisilicon.com, john.garry@huawei.com, xinliang.liu@linaro.org, shaochangliang , Ming Huang , Heyi Guo Date: Tue, 24 Jul 2018 15:08:58 +0800 Message-Id: <20180724070922.63362-15-ming.huang@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180724070922.63362-1-ming.huang@linaro.org> References: <20180724070922.63362-1-ming.huang@linaro.org> Subject: [PATCH edk2-platforms v1 14/38] Silicon/Hisilicon/D06: Fix I2C enable fail issue for D06 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jul 2018 07:15:47 -0000 From: shaochangliang I2C may enable failed in D06, so retry I2C enable while enable failed. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: shaochangliang Signed-off-by: Ming Huang Signed-off-by: Heyi Guo --- Silicon/Hisilicon/Library/I2CLib/I2CLib.c | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Silicon/Hisilicon/Library/I2CLib/I2CLib.c b/Silicon/Hisilicon/Library/I2CLib/I2CLib.c index b5b388d756..ecd2f07c4d 100644 --- a/Silicon/Hisilicon/Library/I2CLib/I2CLib.c +++ b/Silicon/Hisilicon/Library/I2CLib/I2CLib.c @@ -83,6 +83,7 @@ I2C_Enable(UINT32 Socket,UINT8 Port) { I2C0_ENABLE_U I2cEnableReg; I2C0_ENABLE_STATUS_U I2cEnableStatusReg; + UINT32 ulTimeCnt = I2C_READ_TIMEOUT; UINTN Base = GetI2cBase(Socket, Port); @@ -91,16 +92,19 @@ I2C_Enable(UINT32 Socket,UINT8 Port) I2cEnableReg.bits.enable = 1; I2C_REG_WRITE(Base + I2C_ENABLE_OFFSET, I2cEnableReg.Val32); - - I2C_REG_READ(Base + I2C_ENABLE_STATUS_OFFSET, I2cEnableStatusReg.Val32); - if (1 == I2cEnableStatusReg.bits.ic_en) + do { - return EFI_SUCCESS; - } - else - { - return EFI_DEVICE_ERROR; - } + I2C_Delay(10000); + + ulTimeCnt--; + I2C_REG_READ(Base + I2C_ENABLE_STATUS_OFFSET, I2cEnableStatusReg.Val32); + if (0 == ulTimeCnt) + { + return EFI_DEVICE_ERROR; + } + }while (0 == I2cEnableStatusReg.bits.ic_en); + + return EFI_SUCCESS; } void I2C_SetTarget(UINT32 Socket,UINT8 Port,UINT32 I2cDeviceAddr) -- 2.17.0