From patchwork Tue Jul 24 07:08:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Huang X-Patchwork-Id: 142718 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp6933738ljj; Tue, 24 Jul 2018 00:15:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpem56qgTTj1toaI4D5vPsJuN/DLyGIYHyIguesgNpFPL83BpwTQQPK4gRf4jpW7VsVrzw0C X-Received: by 2002:a62:8d16:: with SMTP id z22-v6mr16534940pfd.181.1532416548616; Tue, 24 Jul 2018 00:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532416548; cv=none; d=google.com; s=arc-20160816; b=0IOlj1mzMu6YYFvRmw0JhlvyD1v5nj6YdPCzEGOtH9M+khRGxnRJr8+ylGQLSrkKgg jY9zLCTZqLtfUfnslpvePCO06r4qvGNFN2AwiyAhhjHfMdwMATZUVUKMQKxPM5aN50Wq NC6ZlcyafIx8CTxBOMJO02CNKnB1yc3v7/RQCbD6Rs83MXfOncOoB3Al1RgR2j9ZDw4N FA6blG3A8S+/j/8KSEhtluwuRrgsH2mDkDeDFgJG/zAJFGSdV9MU/Ln+WTdsP0kV6D8L 6ECl/S5fwKw1pCt+fE2xuwUpbnNtx3AQ6ZC1lqDWFimPMZ7J52jqYIHQnEvGU0vNeGR1 OWqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=ah9HOJfl843A+bIjxDnC/koRwmCCNPkjnrBkQwgdZ9g=; b=aVmoYbWr0GTSUVYw0hP8ACSklIq1ZSPGTDNrgxHAdz+1anpk9dqbe40zTgOcR3t7zo zkMwHRyYe/yVh+zxYEjF0Dp9shwq+SMge1RnEuP1hpIvYeV4XaQLzoHKl3pxQ4qHJUYo BMg/j7afX/xwfJYSD8cBCX78EkTtPnA3oGjdeAmgUST64g3pqX5+0WXCG8aqLyhx2LzR 5+lfMd275opqhmJWoNfNVBZ4kgk4J+BDzZIrPtrp6vxbQNGaLUXJ3U1jHXJbkVwlVNU6 XnqrM6bwgLeEXw+ncsBGea+/PQvhpJCNx3JaAzBG4IKRg1PbOLOxw5YiKIdaKr2dLLyR jxdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AkUe8rhi; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id z62-v6si9738157pgz.640.2018.07.24.00.15.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jul 2018 00:15:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AkUe8rhi; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 40C0E210C123B; Tue, 24 Jul 2018 00:15:48 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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-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 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: [edk2] [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: , Cc: huangming23@huawei.com, xinliang.liu@linaro.org, john.garry@huawei.com, zhangjinsong2@huawei.com, shaochangliang , huangdaode@hisilicon.com, guoheyi@huawei.com, wanghuiqiang@huawei.com MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel 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)