From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AA+uWPwUHcg2x2Gphy/2Y+vwXj5x7ju/+hIsFCJprmae7CupIE3Pufb6LkllrEQt0lw6awU2L7vH2Q== 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 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: 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: [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: , X-List-Received-Date: Thu, 23 Aug 2018 16:08:18 -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 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(-) 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; -- 2.18.0