From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=2a00:1450:4010:c07::243; helo=mail-lf0-x243.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lf0-x243.google.com (mail-lf0-x243.google.com [IPv6:2a00:1450:4010:c07::243]) (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 7B01A2034CF8C for ; Wed, 25 Oct 2017 18:16:18 -0700 (PDT) Received: by mail-lf0-x243.google.com with SMTP id p184so1905720lfe.12 for ; Wed, 25 Oct 2017 18:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2532Svcu8NwMIdeSTM4lYZ6egIbyQgwtAcJXuH2JBps=; b=A+PzelRSw1RH+RIGPp9kg+wQVOSp+Hb/RwdMvqAzzAEZqlJrjZymN4sW0q+fK+6Jyr z6tFS/Iw/eygf2mvzG5p74SUr3iQsQeAzEXmq0+t0jGrQ9PC/CSj4ARpsiheBFcsJBI7 CYe/3XDOMn3g5a0iyQFC6H7GT6CtosXPUdUTre/Kj9QeHO0tz4DYrJyvcor3O9o6wYO/ YCGXZ4YpV54syLYIrfsneShUPBBbQQvSXTePThMjWnkavzjmYeimwAV8g4f4jcFvmZ7Z 95qr3sSIl9ZhQVPDO7MId3IWWqQeUm8RxkmduNve5o9RfwxhUitpUFETtB1QrO1dnJHQ vPCA== 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=2532Svcu8NwMIdeSTM4lYZ6egIbyQgwtAcJXuH2JBps=; b=GYCOhvtxh+UZQL9OyMcEsIkMnl81jilXl65GiwoXJ4vkr0SDGv3lZPjIgmeigdCvUG KP2X5rdaM87EC8aMWOBuUS0topyzKsz1fMDQyDVoBiMhfRHT9/IOVFoujdU6jNgdeXaL AeL7HdOKxKUNPE8bpjCqJjiVSMStqV+PVv3ehOQr+z9TrzLbmafCXp50P7Dagd4krU2j xOCQl5RCFcrpW8tM64+ass201gSfqAx1oBwUUQ9qkWODvW1TmHYDOAzdDFqCXA1kKezC irIHCvVjDjI+I9xnwVTYG9dxZw0Jaahj9FGyf4jIflzNf7QTfhu6W2PIwygbjgbzWzSv 6ESA== X-Gm-Message-State: AMCzsaXr4wRbtPUt9O2dzLvZwb1cTmCF4ThVTbfx0ualn+FdfoWO84j7 2ZV68LWTFmc8xJRWR1IP+kIjCZkmIrA= X-Google-Smtp-Source: ABhQp+Re/He0y3GtbPukPahwz+yj2om/z+KcAWRxCmg4eXTlzdWKDoVUVnAMGe9JQuBO/uDAuXRLgA== X-Received: by 10.25.29.199 with SMTP id d190mr5299224lfd.47.1508980802302; Wed, 25 Oct 2017 18:20:02 -0700 (PDT) Received: from gilgamesh.semihalf.com (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id h26sm1053428lja.69.2017.10.25.18.20.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Oct 2017 18:20:01 -0700 (PDT) From: Marcin Wojtas To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, neta@marvell.com, kostap@marvell.com, jinghua@marvell.com, mw@semihalf.com, jsd@semihalf.com, Joe Zhou Date: Thu, 26 Oct 2017 03:19:31 +0200 Message-Id: <1508980777-29006-5-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508980777-29006-1-git-send-email-mw@semihalf.com> References: <1508980777-29006-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH 04/10] Marvell/Library: MppLib: Prevent overwriting PCD values X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Oct 2017 01:16:18 -0000 From: Joe Zhou After enabling dynamic PCDs, it is possible to reconfigure MPP during platform initialization. It occurred that due to a faulty way of passing temporary values, information obtained from PCDs was overwritten. This patch fixes the issue, which on the occasion simplifies PcdToMppRegs function. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Joe Zhou Signed-off-by: Marcin Wojtas --- Platform/Marvell/Library/MppLib/MppLib.c | 21 ++++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Platform/Marvell/Library/MppLib/MppLib.c b/Platform/Marvell/Library/MppLib/MppLib.c index c09acf9..383c820 100644 --- a/Platform/Marvell/Library/MppLib/MppLib.c +++ b/Platform/Marvell/Library/MppLib/MppLib.c @@ -74,7 +74,7 @@ STATIC VOID SetRegisterValue ( UINT8 RegCount, - UINT8 **MppRegPcd, + UINT8 MppRegPcd[][MPP_PINS_PER_REG], UINTN BaseAddr, BOOLEAN ReverseFlag ) @@ -99,10 +99,10 @@ STATIC UINT8 PcdToMppRegs ( UINTN PinCount, - UINT8 **MppRegPcd + UINT8 **MppRegPcd, + UINT8 MppRegPcdTmp[][MPP_PINS_PER_REG] ) { - UINT8 MppRegPcdTmp[MPP_MAX_REGS][MPP_PINS_PER_REG]; UINT8 PcdGroupCount, MppRegCount; UINTN i, j, k, l; @@ -125,14 +125,7 @@ PcdToMppRegs ( for (j = 0; j < PCD_PINS_PER_GROUP; j++) { k = (PCD_PINS_PER_GROUP * i + j) / MPP_PINS_PER_REG; l = (PCD_PINS_PER_GROUP * i + j) % MPP_PINS_PER_REG; - MppRegPcdTmp[k][l] = MppRegPcd[i][j]; - } - } - - /* Update input table */ - for (i = 0; i < MppRegCount; i++) { - for (j = 0; j < MPP_PINS_PER_REG; j++) { - MppRegPcd[i][j] = MppRegPcdTmp[i][j]; + MppRegPcdTmp[k][l] = (UINT8)MppRegPcd[i][j]; } } @@ -191,6 +184,7 @@ MppInitialize ( BOOLEAN ReverseFlag[MAX_CHIPS]; UINT8 *MppRegPcd[MAX_CHIPS][MPP_MAX_REGS]; UINT32 i, ChipCount; + UINT8 TmpMppValue[MPP_MAX_REGS][MPP_PINS_PER_REG]; ChipCount = PcdGet32 (PcdMppChipCount); @@ -203,8 +197,9 @@ MppInitialize ( for (i = 0; i < MAX_CHIPS; i++) { if (i == ChipCount) break; - RegCount = PcdToMppRegs (PinCount[i], MppRegPcd[i]); - SetRegisterValue (RegCount, MppRegPcd[i], BaseAddr[i], ReverseFlag[i]); + + RegCount = PcdToMppRegs (PinCount[i], MppRegPcd[i], TmpMppValue); + SetRegisterValue (RegCount, TmpMppValue, BaseAddr[i], ReverseFlag[i]); /* * eMMC PHY IP has its own MPP configuration. -- 2.7.4