From patchwork Tue Aug 14 08:08:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Huang X-Patchwork-Id: 144130 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4049736ljj; Tue, 14 Aug 2018 01:11:25 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyh15jg0134y1UH73YLKYPH8gpDcUMoI7l1eXCTGWJNVtNjgsfYbzWRGkLt/At2TxBjPLk6 X-Received: by 2002:a62:4f5b:: with SMTP id d88-v6mr22446579pfb.225.1534234285568; Tue, 14 Aug 2018 01:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534234285; cv=none; d=google.com; s=arc-20160816; b=FEZSfls8Ukszeb6yKm6fK2d3LYQANVZ8yPTUyq1BTvzKUzSFgwmYajUGpT5CVt9EYK 71ZfkRt8LVPUzEo1z5v4gGuXlrS2EkP4a+aEr8obWUZP1Wzk7usgOwBhr3cTVkQOVA8/ ddDCHMUyVmZiM/8JPJMac1rr0/PzeMc7+wqeeNOaTRxnHzjH827N2DTkg4yNcxuKa08K HIeUPE3g8K1X5oTr1G5RgD3zBePIRULNeMGouvGMILUv5cat2K56KSRsgy8QxjBt/df2 Yzq0nKvkZD04sfZXhmlEXCvwMinPpHxRassy9grE+DmcUYQlvl4lliNv8kSY3hJNrGXX 4iig== 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=oPDmCvKsNQopZ6u8581nItyC3+FJd7mt0uuX+5LIaCw=; b=vDLRd1S2tVavYGgcQ8qa7PqcrlmRuPH/2kKYtWYHgUlRCwDDMWP+FWc66MMvtzaJEn 0IfkXMiienb1VE83luIbr172baORZszlY8eca7tRRbS2zD48IgSGckOH21T7cfdAzZav HiRIKArpMJ2FEpsNtlLKfi4D6cnGcNz5ishTPBCINhlK+edDRy3OXlDMu2F/e+AfhvBF NBpPYu1DMYnSmYeL0JL5VVChtYe273mbbTW4IU805esLTdE8wDaMn7y38Ai33cs04L/E wSNRq5vJ8c6QEvSW64Q5ThWNpXrdXdDW6Ib/lzUo48i4EvWUoFU60ea1o2zLkvyuqWCm OjgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aJdvkUug; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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. [198.145.21.10]) by mx.google.com with ESMTPS id d190-v6si22718687pfd.113.2018.08.14.01.11.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Aug 2018 01:11:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=aJdvkUug; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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 A2B14210F16CE; Tue, 14 Aug 2018 01:10:43 -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::544; helo=mail-pg1-x544.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (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 757DE210F16CC for ; Tue, 14 Aug 2018 01:10:42 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id r1-v6so8778695pgp.11 for ; Tue, 14 Aug 2018 01:10:42 -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=ne7UD5d46U3RJ9EVF2uqubhT3FmUwsR/vgU37WDXFUM=; b=aJdvkUugVXDJcEGEhyiS37DSxBwzfUhVGYnCniRnHFLL6PCz3PikQjnc3wKy2W+s54 +AjFDY2nepIqcfoFm65LNZOa8kMIS/ZjGJL3TBmPUHrrP/AMya1Dihxh5najqfvkMahj YCkomKv9zJA5wXFGCERujzVPwS166dTRnbdMw= 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=ne7UD5d46U3RJ9EVF2uqubhT3FmUwsR/vgU37WDXFUM=; b=ncRZ9KXxmpHyPcMV4YHsrJGQ5IHdDracEHP44Tkd+1ZLy3TBz8aXZScgNpVahghvt+ RvmjR4H+fIDq7Kk9Dhj1F/34rDirurNdU6Px5XLha44M7Va4qfUg9foEb4J2ztIT8dQC v2X7enfljwCIRJYNHW9qgpKdmLgAOxHnEttyLPVrDDmj8JlO1mG7k6j/eNf0x7KlWh99 w8yO22WWPXmaQ7W77i9ad6AcgBN17QY3SuPtxVC+2FziFYt7cMCMkF/C9+2XDneNWVAf 2fIAk/WimkiC0xpNh5x2zwubw2+DjuMCXm5a3K7J6ZXbMiwt7Uclkurc/4dMNDbucEpz D1OQ== X-Gm-Message-State: AOUpUlFxyoSNwVhuVaZhhL0BDmYf69SxyK495lQV7mXlum1YXJeVbge0 6ondENbuD5hoAE36/7RbCqyqCg== X-Received: by 2002:a62:6746:: with SMTP id b67-v6mr22269600pfc.243.1534234242194; Tue, 14 Aug 2018 01:10:42 -0700 (PDT) Received: from localhost.localdomain ([120.31.149.194]) by smtp.gmail.com with ESMTPSA id h130-v6sm72905670pgc.88.2018.08.14.01.10.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Aug 2018 01:10:41 -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, 14 Aug 2018 16:08:42 +0800 Message-Id: <20180814080903.50466-23-ming.huang@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180814080903.50466-1-ming.huang@linaro.org> References: <20180814080903.50466-1-ming.huang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v2 22/43] 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, guoheyi@huawei.com, huangdaode@hisilicon.com, michael.d.kinney@intel.com, lersek@redhat.com, wanghuiqiang@huawei.com MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" I2C may enable failed in D06, so retry I2C enable while enable failed. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ming Huang --- Silicon/Hisilicon/Library/I2CLib/I2CLib.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm diff --git a/Silicon/Hisilicon/Library/I2CLib/I2CLib.c b/Silicon/Hisilicon/Library/I2CLib/I2CLib.c index 9174e50dd4..d67ddc7f9b 100644 --- a/Silicon/Hisilicon/Library/I2CLib/I2CLib.c +++ b/Silicon/Hisilicon/Library/I2CLib/I2CLib.c @@ -86,6 +86,7 @@ I2C_Enable ( { I2C0_ENABLE_U I2cEnableReg; I2C0_ENABLE_STATUS_U I2cEnableStatusReg; + UINT32 TimeCnt = I2C_READ_TIMEOUT; UINTN Base = GetI2cBase (Socket, Port); @@ -93,13 +94,18 @@ I2C_Enable ( I2cEnableReg.bits.enable = 1; I2C_REG_WRITE (Base + I2C_ENABLE_OFFSET, I2cEnableReg.Val32); + do { + // This is a empirical value for I2C delay. MemoryFance is no need here. + I2C_Delay (10000); - I2C_REG_READ (Base + I2C_ENABLE_STATUS_OFFSET, I2cEnableStatusReg.Val32); - if (I2cEnableStatusReg.bits.ic_en == 1) { - return EFI_SUCCESS; - } else { - return EFI_DEVICE_ERROR; - } + TimeCnt--; + I2C_REG_READ (Base + I2C_ENABLE_STATUS_OFFSET, I2cEnableStatusReg.Val32); + if (TimeCnt == 0) { + return EFI_DEVICE_ERROR; + } + } while (I2cEnableStatusReg.bits.ic_en == 0); + + return EFI_SUCCESS; } VOID