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::533; helo=mail-pg1-x533.google.com; envelope-from=ming.huang@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) (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 68FE6210DF5EE for ; Wed, 8 Aug 2018 07:33:26 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id f14-v6so1166052pgv.13 for ; Wed, 08 Aug 2018 07:33:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=yQ6sX5KqY6cuYNS2oWKb4kJQsY7d13Ojpf0wiAzR948=; b=Pi3d1kB+xy4l/hUt2qGGKRVdcUx/p1A7Mci2ZcZGVmAYs7WUeKWnPr7Uek2W5cDRGe bnEshl2eirbnBtkMkfNz0RvwhUVPLgwcu42YIHOpiPVBonvUp5nqeKtzpcf1Of+N+lGC mbzCfhSM1jhXS41TY/qlQr1BnkqTU8s6Zbx0U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=yQ6sX5KqY6cuYNS2oWKb4kJQsY7d13Ojpf0wiAzR948=; b=PXhZWkQtxE126lbeTy/wDi1ziMBC94KbstUDvaq8r5G7kbtGoWQV4VWlfU8Nvz4Rjd /sCYFQqKbg7ZIXG5B+whdrtl5gtMr1Z/h6wsy0+W2mwjLc+faFck37D9LaEVDNC7SwWV ddPTeoSI/iGCfWAdm2RmQCzE6h9+3y/nPjF/5waFSDBMlNAJdkV2ycGieIJrwWwS2sx2 TNJwNcwXl1t6GWIlPpbdRVkd8GSR8lFhn70CAAvzSLJdmcsKwvwhPiWNNbMOkZaZGyeo Oy6Pw+zF+7pVTTc4YRWD6ZTmQ4G5OXiWKEQoaDSmsgxNHSDBuhhuVkmVLO6+QmbKLXf8 5O9w== X-Gm-Message-State: AOUpUlHb2Tjoec9OS0ntIktkiCw3LKVzowtgOonvLTySvD0sdTQvIwN9 XLweNc/cRMJcd49cZpyCKhE+aA== X-Google-Smtp-Source: AA+uWPxatxZFGSjWnSZfH5m0+Mvb9fpExeAtkrzAuurOBAgX2bhmUZrTTVUQJfhYLsbmxlPAPR7l1Q== X-Received: by 2002:a62:c98e:: with SMTP id l14-v6mr3270074pfk.10.1533738806516; Wed, 08 Aug 2018 07:33:26 -0700 (PDT) Received: from [10.199.0.182] ([64.64.108.224]) by smtp.gmail.com with ESMTPSA id t76-v6sm7190547pfe.109.2018.08.08.07.33.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 07:33:25 -0700 (PDT) To: Leif Lindholm Cc: linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org, graeme.gregory@linaro.org, ard.biesheuvel@linaro.org, guoheyi@huawei.com, wanghuiqiang@huawei.com, huangming23@huawei.com, zhangjinsong2@huawei.com, huangdaode@hisilicon.com, john.garry@huawei.com, xinliang.liu@linaro.org, shaochangliang , Heyi Guo References: <20180724070922.63362-1-ming.huang@linaro.org> <20180724070922.63362-15-ming.huang@linaro.org> <20180803104026.24akijoykt2xjwhq@bivouac.eciton.net> From: Ming Message-ID: <0884d206-7923-3bc6-ea02-1e99a49de217@linaro.org> Date: Wed, 8 Aug 2018 22:33:11 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180803104026.24akijoykt2xjwhq@bivouac.eciton.net> Subject: Re: [PATCH edk2-platforms v1 14/38] 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: , X-List-Received-Date: Wed, 08 Aug 2018 14:33:27 -0000 Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 8bit ÔÚ 8/3/2018 6:40 PM, Leif Lindholm дµÀ: > On Tue, Jul 24, 2018 at 03:08:58PM +0800, Ming Huang wrote: >> From: shaochangliang >> >> I2C may enable failed in D06, so retry I2C enable while >> enable failed. >> >> Contributed-under: TianoCore Contribution Agreement 1.1 >> Signed-off-by: shaochangliang >> Signed-off-by: Ming Huang >> Signed-off-by: Heyi Guo >> --- >> Silicon/Hisilicon/Library/I2CLib/I2CLib.c | 22 ++++++++++++-------- >> 1 file changed, 13 insertions(+), 9 deletions(-) >> >> diff --git a/Silicon/Hisilicon/Library/I2CLib/I2CLib.c b/Silicon/Hisilicon/Library/I2CLib/I2CLib.c >> index b5b388d756..ecd2f07c4d 100644 >> --- a/Silicon/Hisilicon/Library/I2CLib/I2CLib.c >> +++ b/Silicon/Hisilicon/Library/I2CLib/I2CLib.c >> @@ -83,6 +83,7 @@ I2C_Enable(UINT32 Socket,UINT8 Port) >> { >> I2C0_ENABLE_U I2cEnableReg; > > Ugh, indentation is incorrect in the original. > Can you correct that in a patch preceding this one? > OK, I will correct it in v2. >> I2C0_ENABLE_STATUS_U I2cEnableStatusReg; >> + UINT32 ulTimeCnt = I2C_READ_TIMEOUT; > > What is ul? > It is wrong name and will be corrected in v2. >> >> UINTN Base = GetI2cBase(Socket, Port); >> >> @@ -91,16 +92,19 @@ I2C_Enable(UINT32 Socket,UINT8 Port) >> I2cEnableReg.bits.enable = 1; >> I2C_REG_WRITE(Base + I2C_ENABLE_OFFSET, I2cEnableReg.Val32); >> >> - >> - I2C_REG_READ(Base + I2C_ENABLE_STATUS_OFFSET, I2cEnableStatusReg.Val32); >> - if (1 == I2cEnableStatusReg.bits.ic_en) >> + do >> { > > Move that brace up to the previous line. > >> - return EFI_SUCCESS; >> - } >> - else >> - { >> - return EFI_DEVICE_ERROR; >> - } >> + I2C_Delay(10000); > > Why 10000? > Do we need a MemoryFence ()? > The delay is need for I2C. This is a empirical value. MemoryFance is no need. I will add this as comment. >> + >> + ulTimeCnt--; >> + I2C_REG_READ(Base + I2C_ENABLE_STATUS_OFFSET, I2cEnableStatusReg.Val32); >> + if (0 == ulTimeCnt) >> + { > > Move that brace up to previous line. > >> + return EFI_DEVICE_ERROR; >> + } >> + }while (0 == I2cEnableStatusReg.bits.ic_en); > > Space after } > > / > Leif > >> + >> + return EFI_SUCCESS; >> } >> >> void I2C_SetTarget(UINT32 Socket,UINT8 Port,UINT32 I2cDeviceAddr) >> -- >> 2.17.0 >>