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 2625F21CEB122 for ; Thu, 26 Oct 2017 18:10:48 -0700 (PDT) Received: by mail-lf0-x243.google.com with SMTP id a132so5674930lfa.7 for ; Thu, 26 Oct 2017 18:14:34 -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=TUMONFAKMpiQWShizYJCsesNltdW4p7QVVldO0pf3Wo=; b=0Sub8FhikZV7d9ivuWrzAqwpQgS0DHbxpr89p+SLCO73RRIa2crRHY6DdobwLza3UH p2MHRmLx7IqbXGV0XIoMBcJngEmZEF2IL7nEavXM9z0RLBsED3eefdQYVBwgeDVsLJ1O E+YUXrwAyFLoN0a9H5OV6OIp0Np5pymxnnPBSUo5Gd52mtTxJENE9dgfz+vE0NdfdYFx qFdrRuQNqflxN0AezebNYsdDfsc1PsFXLPV49ZHUCcS+6UXhQRxPA3vIW5NOfR+PUWIL fQZ3q2YXWNkXmPhdfRee9MnOnpEReqgJjcroWKli6AyXDDd3CneMZhnlWJ2r7mLC94Jl bjdQ== 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=TUMONFAKMpiQWShizYJCsesNltdW4p7QVVldO0pf3Wo=; b=Fn1Wp2wU5N84NgCtOzruYZZ6b3oLcZjxYLtG4I8evVo5/natWkcunC3Z8QlxkwipV1 mG2AE5PqVb0epZmeXjzcB44+iQ28RX6EHskRVN2Kz8bmMThCQa9Om2c8eoSVg1C4FBdr jCbylAeVKctH/0Lhl76Ne3NHwdD6/os9TP9mUw8fkFVS2zl5NvUPxZ1QzAAaK5AGsX8n +XZHTx5qG6TzZws5WRzoGkhMGk5p8aKK/btu8adl7NWm+Bo1nIk8N9Uq2tVoS2Sdl5lJ dWdm9ddftDcJBVQvtL+AhjFnQnZuy2CMvA3eXbYLYCISNTblMxra59tiFuTR8+g1eOPY 6oGA== X-Gm-Message-State: AMCzsaVDJz2iOU+8IAJwIFWVQBeEjigW8uggRM/g+9vOdQfkOEuekTG7 YYTCySvQe5vt/IXGlkvCEGZhiGDaQ9Y= X-Google-Smtp-Source: ABhQp+TOSJH4Lno8YR+Ge5WCfqmPZxRZMIZQMJ3d7BOyqhOvAcDmoNUko4AgGKYP5yXJJDSn+fYb5g== X-Received: by 10.46.99.203 with SMTP id s72mr9976727lje.7.1509066873043; Thu, 26 Oct 2017 18:14:33 -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 m9sm1675702ljb.61.2017.10.26.18.14.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Oct 2017 18:14:32 -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: Fri, 27 Oct 2017 03:13:46 +0200 Message-Id: <1509066832-5285-5-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509066832-5285-1-git-send-email-mw@semihalf.com> References: <1509066832-5285-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH v2 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: Fri, 27 Oct 2017 01:10:48 -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 Reviewed-by: Leif Lindholm --- 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