From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::241; helo=mail-wm0-x241.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) (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 24729203525FD for ; Thu, 26 Oct 2017 06:26:26 -0700 (PDT) Received: by mail-wm0-x241.google.com with SMTP id r68so8354649wmr.3 for ; Thu, 26 Oct 2017 06:30:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=v1Odb3dXsR3hQCP2V8/GCjy6uN1xiAcWEgodvGmQJuc=; b=PkCgNTRDesCEaYytT5ApN3+aXy19ZbeHyrBO2Fwi9NmMmDE1xaMNUPlMbiVkAop+wi PvZAnINNcYKXyTRqv5LznPt5eG9pSj2NjYiyy/U7pJQjTeWnrLnLHpseJJwICXcdLfgL iCR6MjgYcEaDWUQx5hVlDSVCN6fzcCF8Wh6oY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=v1Odb3dXsR3hQCP2V8/GCjy6uN1xiAcWEgodvGmQJuc=; b=KRgPIapC+aQdPDqoYLfMvSBf6jVLM9uP3MPIqbNAQ36iG7sJDTzpbqMaWBkPKjqpSA pb7O5oeoWuk8n5z2CCyw1ZgB249+f/E/jpNCBEszOV/0EUxkY2lXchzmtvYc3+lcCsyc O9bdkocz9EsDBFXO0oRhQwGaBxfbeLLb7/p2FLqY2Y7DMsGyYYs4eRXx/Cps1JOxUub5 T5n7+uCJxgT+y9ScEHidNzfPpciM0XmrlB1vfmVWDN4W0PXEOkKp0q4cshd3CSDeTft4 Orndb3D0bH55QIbU9ElCQDA/Xr/LYvZj7FwPJZgk/xcOIZlxWX4t9I5Qw69DlaL+O7aU Pvlg== X-Gm-Message-State: AMCzsaWaLSVK5vuoZxhcmPQHf0H1INxDDTE/nVGJHkvJMKppOIk1Ypo8 yaHYwlhgyGx+qzKF7PbGct1/UQ== X-Google-Smtp-Source: ABhQp+TShKhF+8DX7uZnW6SzTg7JollwpbjWSBx40JMHz9HOkuMk6BHJXFZpcaQCgC+Gk8Jhc315pg== X-Received: by 10.28.36.212 with SMTP id k203mr1431413wmk.127.1509024610990; Thu, 26 Oct 2017 06:30:10 -0700 (PDT) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id f140sm1349604wmd.27.2017.10.26.06.30.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Oct 2017 06:30:09 -0700 (PDT) Date: Thu, 26 Oct 2017 14:30:08 +0100 From: Leif Lindholm To: Marcin Wojtas Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, neta@marvell.com, kostap@marvell.com, jinghua@marvell.com, jsd@semihalf.com Message-ID: <20171026133008.go7igsnfoupf3o3w@bivouac.eciton.net> References: <1508980777-29006-1-git-send-email-mw@semihalf.com> <1508980777-29006-7-git-send-email-mw@semihalf.com> MIME-Version: 1.0 In-Reply-To: <1508980777-29006-7-git-send-email-mw@semihalf.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [platforms: PATCH 06/10] Marvell/Library: MppLib: Take 0xFF placeholders into account 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 13:26:26 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Oct 26, 2017 at 03:19:33AM +0200, Marcin Wojtas wrote: > From: Ard Biesheuvel > > The MppSel definition PCDs contain 0xFF placeholders for values that > should be left untouched. MppLib needs to be taught how to take those > into account. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > Signed-off-by: Marcin Wojtas > --- > Platform/Marvell/Library/MppLib/MppLib.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/Platform/Marvell/Library/MppLib/MppLib.c b/Platform/Marvell/Library/MppLib/MppLib.c > index 383c820..9e42f08 100644 > --- a/Platform/Marvell/Library/MppLib/MppLib.c > +++ b/Platform/Marvell/Library/MppLib/MppLib.c > @@ -79,18 +79,22 @@ SetRegisterValue ( > BOOLEAN ReverseFlag > ) > { > - UINT32 i, j, CtrlVal; > + UINT32 i, j, CtrlVal, CtrlMask; > INTN Sign; > > Sign = ReverseFlag ? -1 : 1; > > for (i = 0; i < RegCount; i++) { > CtrlVal = 0; > + CtrlMask = 0; > for (j = 0; j < MPP_PINS_PER_REG; j++) { > - CtrlVal |= MPP_PIN_VAL(7 * (UINTN) ReverseFlag + j * Sign, > - MppRegPcd[i][7 * (UINTN) ReverseFlag + j * Sign]); > + if (MppRegPcd[i][7 * (UINTN) ReverseFlag + j * Sign] != 0xff) { This addition makes an already messy situation worse. Can we have a descriptively named temporary variable for "7 * (UINTN) ReverseFlag + j * Sign"? / Leif > + CtrlVal |= MPP_PIN_VAL(7 * (UINTN) ReverseFlag + j * Sign, > + MppRegPcd[i][7 * (UINTN) ReverseFlag + j * Sign]); > + CtrlMask |= MPP_PIN_VAL(7 * (UINTN) ReverseFlag + j * Sign, 0xf); > + } > } > - MmioWrite32 (BaseAddr + 4 * i * Sign, CtrlVal); > + MmioAndThenOr32 (BaseAddr + 4 * i * Sign, ~CtrlMask, CtrlVal); > } > } > > -- > 2.7.4 >