From patchwork Thu Aug 16 12:12:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Huang X-Patchwork-Id: 144366 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2000445ljj; Thu, 16 Aug 2018 05:14:16 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwZwROIWIYZ/i3wHAXUVp4C0kYcjo8InxoApKPY1I8gZI913EBuH0nAwYryXj+6n5y1pFrt X-Received: by 2002:a63:1d22:: with SMTP id d34-v6mr28660179pgd.133.1534421655918; Thu, 16 Aug 2018 05:14:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534421655; cv=none; d=google.com; s=arc-20160816; b=rL50qpSwfWzcZxX7jJkG6jK2emcCG4YQggjMyQUK2npSuKQxvsw+pj89wQ3wieokl0 9BRxWHxxudJjDFyVsfwiEVIEZiB0WO50SabM7OgPVd2BWqnE68SWY/3l1cB4nJLM6OhK pgLAp/4WGG70AliW4PJiUBoD6dPm7mX9YNeCKFO864mc+QoIC7aWHGAc3LbTQkZXLfhe ZJP+6Fq7l4YUuIHjhDxcUIOXfMbU0hlGKDj5JXKDtO5ZiaeC34Hwqh4QXCsUHT14jOES 5kn6JM8P7wpbJLBamTDd3yUiqY/NuhkzRZvbiiA9MBnSb1PP0YuRQFy5MRh8bbruSC1a WCLQ== 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=GBge2I07ujngdyr0InwAXRI85y7I/qWaslrpClOMOu4=; b=i3avpWgwmV/oYjLnXhsCcTs6JvVaUi6SvsHxyNxDsANFkTtspVB2t2H0Xwc4IjK8AM 8adPYn4ZREIgoSLHHHneGSl0vACStj+BAyPCAtgbqUzUMIRZst7s8QUkaW2pTmvGjII8 MsGmDjkMhGqGGeUpGjd32uFOylz7N2NBnan5pBbzkFmuQdKtE8xYRZFzOSr7pNxyUS2r 5Pa1svvOiRI+hFcggOdz8E/SZc9LzILqCkdVYzyXGHFHW65DDzPpP3AAq8oc8KGMP3jz kdZSUP0NTf8k2OS4BudtsniU9LYX1cEkO4pJqrtrGv248tBtb9DYqP5eFmgMJQI0Yb7I 28fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OV5yikWv; 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 h126-v6si25365320pgc.429.2018.08.16.05.14.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Aug 2018 05:14:15 -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=OV5yikWv; 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 D4457210F3775; Thu, 16 Aug 2018 05:14:00 -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:400e:c01::232; helo=mail-pl0-x232.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pl0-x232.google.com (mail-pl0-x232.google.com [IPv6:2607:f8b0:400e:c01::232]) (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 B3228210F3775 for ; Thu, 16 Aug 2018 05:13:59 -0700 (PDT) Received: by mail-pl0-x232.google.com with SMTP id b90-v6so2025169plb.0 for ; Thu, 16 Aug 2018 05:13:59 -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=nb2lHWdGG4YFVsPmiI2pdHv67gASNQbcGb8j0MRoPj8=; b=OV5yikWvXsPaDUAXziMhjGDEULkoKyQAcUS2etmFaig7GCtB+A1Av8XiVQ9uqZOm4+ v3deCgM8LRUqX0mSXXZcrHlF68hmjWvhmIXjKRHYVW+W8pSGPVwiv229rFB1szd4abLM h+/KEsQ9ZPJvZOMrF67ZKRh4vNm+H2s1+P060= 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=nb2lHWdGG4YFVsPmiI2pdHv67gASNQbcGb8j0MRoPj8=; b=TK1U2HtN+7YJefyUqBDct6Y/YQDQTl8hXX5bStkPFyMgUjc433ZU0WmciBlvp9d0l4 QmmWIFzPI1Wpbi5BWpupI4v9sBTrFAcSfHXyzhlzOynJcK4s/ju8D1XOiw0OEVX9zRMR b00UeIEXzx/j8/3+4ppZqtCrlMBeNPbIsG0r3UvXgJgp/70YXu0cKS2W40XVsvNozvCI vO6uFQO5fVJb1m+4gbaZhPz1TOSkT6t8KoNg3SYNsJjx/838CRVYbwILpbryriqSZDZW Zu5Z5dls9iAL8zDrHuo7cA5LWQzuGlR+wRWHClnIwg0u7ElH4TPyXE94Yd2pGjdJ2YTE IyjA== X-Gm-Message-State: AOUpUlGB7xQgHhbA0dmBjsK1zUf3LIjLt0EVt9Wl4eGncTNcED2wPYPh LVNBUFKzj1gvI37bLUS6n4zqRw== X-Received: by 2002:a17:902:528a:: with SMTP id a10-v6mr28987228pli.199.1534421639384; Thu, 16 Aug 2018 05:13:59 -0700 (PDT) Received: from localhost.localdomain ([120.31.149.194]) by smtp.gmail.com with ESMTPSA id j27-v6sm46736311pfj.91.2018.08.16.05.13.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 16 Aug 2018 05:13:58 -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: Thu, 16 Aug 2018 20:12:19 +0800 Message-Id: <20180816121239.44129-17-ming.huang@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180816121239.44129-1-ming.huang@linaro.org> References: <20180816121239.44129-1-ming.huang@linaro.org> Subject: [edk2] [PATCH edk2-platforms v3 16/36] Silicon/Hisilicon/D06: Add I2C delay for HNS auto config 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" 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 --- Silicon/Hisilicon/Library/I2CLib/I2CHw.h | 3 +++ Silicon/Hisilicon/Library/I2CLib/I2CLib.c | 21 +++++++++++++++----- 2 files changed, 19 insertions(+), 5 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/I2CHw.h b/Silicon/Hisilicon/Library/I2CLib/I2CHw.h index fa954c7937..d77aea509e 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 d67ddc7f9b..59633106ce 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. MemoryFance is no need here. - I2C_Delay (2); + if (Port == I2C_EXTENDER_PORT_HNS) { + // This is a empirical value for I2C delay. MemoryFance is no need here. + I2C_Delay (1000); + } else { + // This is a empirical value for I2C delay. MemoryFance 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. MemoryFance is no need here. - I2C_Delay (2); + if (Port == I2C_EXTENDER_PORT_HNS) { + // This is a empirical value for I2C delay. MemoryFance is no need here. + I2C_Delay (1000); + } else { + // This is a empirical value for I2C delay. MemoryFance 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. MemoryFance is no need here. + I2C_Delay (1000); if (++Times > I2C_READ_TIMEOUT) { (VOID)I2C_Disable (I2cInfo->Socket, I2cInfo->Port); return EFI_TIMEOUT;