From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AA+uWPyi7gISNnPHhXsITWAH0hQcvA+6TbZbYekFY8JOTdxVTocDcH0GHje3zZFIv1nZfoY17ZJYMA== 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 Cc: ard.biesheuvel@linaro.org, michael.d.kinney@intel.com, lersek@redhat.com, guoheyi@huawei.com, wanghuiqiang@huawei.com, huangming23@huawei.com, zhangjinsong2@huawei.com, huangdaode@hisilicon.com, john.garry@huawei.com, xinliang.liu@linaro.org, Ming Huang 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: [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: , X-List-Received-Date: Thu, 16 Aug 2018 12:13:59 -0000 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(-) 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; -- 2.17.0