From patchwork Thu Aug 23 16:07:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Huang X-Patchwork-Id: 144942 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp313465ljw; Thu, 23 Aug 2018 09:08:19 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyw0rhYvFeBOJ6MInyMPNbzcs1P5LYh2i40mHXsUB71CZo0F8MG7A4EdXbYOn+5eUxrPoH2 X-Received: by 2002:a17:902:49:: with SMTP id 67-v6mr15314638pla.206.1535040499716; Thu, 23 Aug 2018 09:08:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535040499; cv=none; d=google.com; s=arc-20160816; b=OZJGg9pYRupXh2IyYkmEpctimALZn0r665v7xrR/Zpq2OgiRHydxahqg/amu2D5OG3 GWbEkEdSwuwXVCUT5gKKnBX+MyBQAeaSHdo2+73N7PGQ9nmF+5VoNC9VSZ62CndHxOhQ Fcr2eb0xie2jXLg/RR7WNB3ATSFmJ+3TIDsA+lPi4+2OSQ8UXLxMg6CS6Y9mG5mBh/k5 rqgVeUCF9nLrDWQwJBDVD5WPd81vy4sPueyCgrRZsUfmVjSQDUoDlOx9O+YZ8avV4glh GwiX+x+5uIp4SUhwf9SHDdyYcoOXFku1vfUJZpxk/wYkj05+Qm7Xb7n6Zyrvgd07Ru2M cKTA== 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=BrDaVdXuP7uiDzUZfX9MZxRfIbrUjZXyaSO/pf6EEbk=; b=eq4nVz7IAn5dHf6LS+WM/RPmQrHR1nvOPqMjoE0l3jAZgguznfDxd6wg2eSzK3V+LP grydeBPgA48jmoPCs9T1+jptD/rbOZ+IS/cud8KRcGWkZqdZxD1yIm3tFEXSLI4CxtHP OdDzHf4B5+Qx76P5FFu5joxH4WoWLilm3msusc5kkQL7GosSyfZzBeNwkmLUYhpZxrfG gC45xeEOq1YMtiMH1DTP+RuTy6/PjYI3J2HUNNiSVkx+ueDJoKJazswA4H9A6wyrpHUY zSIDV9JKLyILSJbNqvAT2y4ykayi0GHVUkjGrnjxr8/zt0H+IutqorQU780FEbqyEn8M PAnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bkHgi0Jg; 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 x32-v6si4526970pld.356.2018.08.23.09.08.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 09:08:19 -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=bkHgi0Jg; 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 4942E21103DCD; Thu, 23 Aug 2018 09:08:19 -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::42a; helo=mail-pf1-x42a.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) (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 0C3D921103DC3 for ; Thu, 23 Aug 2018 09:08:17 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id h69-v6so2983063pfd.4 for ; Thu, 23 Aug 2018 09:08:17 -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=/1FcguXqv7iWtTHBYGS+T48in6J9qw8wZemsJRcsXdk=; b=bkHgi0JgKAzYSbDXGDQlfS9QJTCvOIK1+YwWrTwEo9e1rpuotI20EZbe2p6JenOjh+ ziMV96R51L69NzMjMJ+GfU2MvopxTgoY2dn414nBBg+1GWyvBTh6UQQJR4lg+2rPosOH Hm0ZWtT8ug+qP32BatSDLgRJE7zlA+X5q5xtw= 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=/1FcguXqv7iWtTHBYGS+T48in6J9qw8wZemsJRcsXdk=; b=pM0nkinV/ufxDw5D+IpVW3XL839uTsRJZe9/HhiyKkeM6AonJ+A6OGMSd1b7sGacz8 i/GwALxG7rDGTof6dcW/xzYrYhrw/qfnmIxCzByyxjp9d6HMwOoI7LxobtZWq5jVuFir fDoVb837vKHC40X/7kQcxoYwDkuyIbEfhmeP/uaLnCW0GjvTXlNG2BP3Dio52PfGaJSy ahvgE2n2JjzMHqbJ8sIj1o94d43akRljKdFlTnsLbG6FYLt6PEUxxBNVop/uMywPf34c bpmFShWlHdCuv9nB1TsRQQ8p4Ug1ZGGgeOKvw4+/yPPlu0aMutyjEG8XzBomqtrTKsBN mHMA== X-Gm-Message-State: AOUpUlGf0RW9VQ6J5oanW9mDOpN9k5JGhmCS32tQzi7hsbgHQor7vpVQ lmdlrOLCg1Xyh2aIxSsg+cciwA== X-Received: by 2002:a17:902:7896:: with SMTP id q22-v6mr58461698pll.47.1535040497606; Thu, 23 Aug 2018 09:08:17 -0700 (PDT) Received: from localhost.localdomain ([120.31.149.194]) by smtp.gmail.com with ESMTPSA id d19-v6sm5788083pgv.61.2018.08.23.09.08.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Aug 2018 09:08:17 -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: Fri, 24 Aug 2018 00:07:16 +0800 Message-Id: <20180823160743.45638-5-ming.huang@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180823160743.45638-1-ming.huang@linaro.org> References: <20180823160743.45638-1-ming.huang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 04/31] Silicon/Hisilicon: Add I2CLib delay for HNS auto config X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 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" Because I2C Port5 salve device connect under I2C extender (9545 device), it will cost more time to access I2C slave device, so add delay time for HNS auto config. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ming Huang Reviewed-by: Leif Lindholm --- Silicon/Hisilicon/Library/I2CLib/I2CHw.h | 3 +++ Silicon/Hisilicon/Library/I2CLib/I2CLib.c | 21 +++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) -- 2.18.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/I2CHw.h b/Silicon/Hisilicon/Library/I2CLib/I2CHw.h index 083545448b..6fd7b8183e 100644 --- a/Silicon/Hisilicon/Library/I2CLib/I2CHw.h +++ b/Silicon/Hisilicon/Library/I2CLib/I2CHw.h @@ -19,6 +19,9 @@ #include #include +// The HNS I2C port 5 is under I2C extender +#define I2C_EXTENDER_PORT_HNS 5 + #define I2C_READ_TIMEOUT 500 #define I2C_DRV_ONCE_WRITE_BYTES_NUM 8 #define I2C_DRV_ONCE_READ_BYTES_NUM 8 diff --git a/Silicon/Hisilicon/Library/I2CLib/I2CLib.c b/Silicon/Hisilicon/Library/I2CLib/I2CLib.c index e3d9906135..b8c92fa8ea 100644 --- a/Silicon/Hisilicon/Library/I2CLib/I2CLib.c +++ b/Silicon/Hisilicon/Library/I2CLib/I2CLib.c @@ -258,8 +258,13 @@ CheckI2CTimeOut ( if (Transfer == I2CTx) { Fifo = I2C_GetTxStatus (Socket, Port); while (Fifo != 0) { - // This is a empirical value for I2C delay. MemoryFence is no need here. - I2C_Delay (2); + if (Port == I2C_EXTENDER_PORT_HNS) { + // This is a empirical value for I2C delay. MemoryFence is no need here. + I2C_Delay (1000); + } else { + // This is a empirical value for I2C delay. MemoryFence is no need here. + I2C_Delay (2); + } if (++Times > I2C_READ_TIMEOUT) { (VOID)I2C_Disable (Socket, Port); return EFI_TIMEOUT; @@ -269,8 +274,13 @@ CheckI2CTimeOut ( } else { Fifo = I2C_GetRxStatus (Socket, Port); while (Fifo == 0) { - // This is a empirical value for I2C delay. MemoryFence is no need here. - I2C_Delay (2); + if (Port == I2C_EXTENDER_PORT_HNS) { + // This is a empirical value for I2C delay. MemoryFence is no need here. + I2C_Delay (1000); + } else { + // This is a empirical value for I2C delay. MemoryFence is no need here. + I2C_Delay (2); + } if (++Times > I2C_READ_TIMEOUT) { (VOID)I2C_Disable (Socket, Port); return EFI_TIMEOUT; @@ -369,7 +379,8 @@ I2CWrite( Times = 0; Fifo = I2C_GetTxStatus (I2cInfo->Socket, I2cInfo->Port); while (Fifo > I2C_TXRX_THRESHOLD) { - I2C_Delay (2); + // This is a empirical value for I2C delay. MemoryFence is no need here. + I2C_Delay (1000); if (++Times > I2C_READ_TIMEOUT) { (VOID)I2C_Disable (I2cInfo->Socket, I2cInfo->Port); return EFI_TIMEOUT;