From nobody Fri May 9 19:08:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1534234286588886.6249538483984; Tue, 14 Aug 2018 01:11:26 -0700 (PDT) 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) 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) 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) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.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 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-Google-Smtp-Source: AA+uWPzbhTrZ5Pi4smnVYxvM/f26fZbUu7iwlSsDat5JhZgke15wLoK/KQB/U7ZPvc6bMwz1iW6vhA== X-Received: by 2002:a62:6746:: with SMTP id b67-v6mr22269600pfc.243.1534234242194; Tue, 14 Aug 2018 01:10:42 -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 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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(-) 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 =3D I2C_READ_TIMEOUT; =20 UINTN Base =3D GetI2cBase (Socket, Port); =20 @@ -93,13 +94,18 @@ I2C_Enable ( I2cEnableReg.bits.enable =3D 1; I2C_REG_WRITE (Base + I2C_ENABLE_OFFSET, I2cEnableReg.Val32); =20 + do { + // This is a empirical value for I2C delay. MemoryFance is no need her= e. + I2C_Delay (10000); =20 - I2C_REG_READ (Base + I2C_ENABLE_STATUS_OFFSET, I2cEnableStatusReg.Val32); - if (I2cEnableStatusReg.bits.ic_en =3D=3D 1) { - return EFI_SUCCESS; - } else { - return EFI_DEVICE_ERROR; - } + TimeCnt--; + I2C_REG_READ (Base + I2C_ENABLE_STATUS_OFFSET, I2cEnableStatusReg.Val3= 2); + if (TimeCnt =3D=3D 0) { + return EFI_DEVICE_ERROR; + } + } while (I2cEnableStatusReg.bits.ic_en =3D=3D 0); + + return EFI_SUCCESS; } =20 VOID --=20 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel