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:c0c::242; helo=mail-wr0-x242.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x242.google.com (mail-wr0-x242.google.com [IPv6:2a00:1450:400c:c0c::242]) (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 F1AAD212B7DB7 for ; Tue, 12 Jun 2018 15:26:48 -0700 (PDT) Received: by mail-wr0-x242.google.com with SMTP id f16-v6so656459wrm.3 for ; Tue, 12 Jun 2018 15:26:48 -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=FAhzCqdKBNXY79aQ0hn1ilZVCSEoJK4XhZRgx0In1Jw=; b=DR8DWXl03qt86z0So0jLO7z088GkcTPq8NAvInbS82qFf0CU9VKgSelnLTuJz//4LK wY3l5b4jYx2b/gfLfNonkAsycWd0BubsU41KElDmI0I3ShbnvhZZJOnRc2ON3aWjsX1f Wz0iJykgt7GqLMG9O4H+c5K++lfVkN7VPuZ2Q= 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=FAhzCqdKBNXY79aQ0hn1ilZVCSEoJK4XhZRgx0In1Jw=; b=fLkTS4V9tNVcR144n5osvADSynplWffcBZosV8BGqLR3pq0oXDog6twOa8+/rd4up9 YQj0GWgRe7nMogE+MXjFDfxPYqs4JZv++z1xCqea3txUxGxegU8V/Xl8UU3gwiGl8WhU a0i/2FFz+fsXQ3XjuhtLU6qL+GXhZFiqZYzKtUo6VR8QP09C28+Wby+uH+GhyhBaOkQn 1vqHf2YTVKuxY53/Ud80ew9OOUccLv0272npIg+EsCF+Mr3k/oUKZ7XxuC4czZZrc+BJ XbIMKFwKV1BecKRXTsbXWwZQlA4cGcz7iyUPrLTRvNVBhE0+wrtcMmEFGlRyMvhNzMri sgGw== X-Gm-Message-State: APt69E1gvSrdFxIsQuZZSQDyg1guEB0HKQb+5BG8dew5fsPFJ1+G0gmV VWGtvV1IptvEeha6tAvAHIbQBg== X-Google-Smtp-Source: ADUXVKJrOGOOTZ3KX8Pdva44nHOsy22DCsp9IH13FFu9X/Tz/leg+BNDJ4fkc8WIbBnxjMOeScstAw== X-Received: by 2002:adf:9a4c:: with SMTP id z70-v6mr2216313wrb.118.1528842407258; Tue, 12 Jun 2018 15:26:47 -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 s13-v6sm1517870wrq.48.2018.06.12.15.26.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Jun 2018 15:26:46 -0700 (PDT) Date: Tue, 12 Jun 2018 23:26:44 +0100 From: Leif Lindholm To: Marcin Wojtas Cc: edk2-devel@lists.01.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, jinghua@marvell.com, jsd@semihalf.com, jaz@semihalf.com Message-ID: <20180612222644.3hzymu2ekwt67gwg@bivouac.eciton.net> References: <1528472063-1660-1-git-send-email-mw@semihalf.com> <1528472063-1660-23-git-send-email-mw@semihalf.com> MIME-Version: 1.0 In-Reply-To: <1528472063-1660-23-git-send-email-mw@semihalf.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [platforms PATCH 22/25] Marvell/Armada7k8k: Extend ArmadaSoCDescLib with I2C information X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2018 22:26:49 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Jun 08, 2018 at 05:34:20PM +0200, Marcin Wojtas wrote: > This patch introduces new library callback (ArmadaSoCDescI2cGet ()), > which dynamically allocates and fills MV_SOC_I2C_DESC structure with > the SoC description of I2c controllers. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Marcin Wojtas > Reviewed-by: Hua Jing > --- > Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c | 38 ++++++++++++++++++++ > Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h | 15 ++++++++ > 2 files changed, 53 insertions(+) > > diff --git a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c > index 515ff03..36441c0 100644 > --- a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c > +++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c > @@ -72,6 +72,44 @@ ArmadaSoCDescComPhyGet ( > } > > // > +// Platform description of I2C controllers > +// > +#define MV_SOC_I2C_PER_CP_COUNT 2 > +#define MV_SOC_I2C_BASE(I2c) (0x701000 + (I2c) * 0x100) Please add explicit parentheses rather than relying on evaluation order. > + > +EFI_STATUS > +EFIAPI > +ArmadaSoCDescI2cGet ( > + IN OUT MV_SOC_I2C_DESC **I2cDesc, > + IN OUT UINT8 *DescCount > + ) > +{ > + MV_SOC_I2C_DESC *Desc; > + UINT8 CpCount = FixedPcdGet8 (PcdMaxCpCount); > + UINT8 Index, CpIndex, I2cIndex = 0; UINTN for count/index. No assignment on definition? > + > + Desc = AllocateZeroPool (CpCount * MV_SOC_I2C_PER_CP_COUNT * > + sizeof (MV_SOC_I2C_DESC)); > + if (Desc == NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + for (CpIndex = 0; CpIndex < CpCount; CpIndex++) { > + for (Index = 0; Index < MV_SOC_I2C_PER_CP_COUNT; Index++) { > + Desc[I2cIndex].I2cBaseAddress = > + MV_SOC_CP_BASE (CpIndex) + MV_SOC_I2C_BASE (Index); > + I2cIndex++; > + } > + } > + > + *I2cDesc = Desc; > + *DescCount = I2cIndex; Please reformat as for previous patches: Calculate number of descriptors first, allocate that, and increment the pointer (after copying the first one into I2cDesc. > + > + return EFI_SUCCESS; > +} > + > +// > // Platform description of MDIO controllers > // > #define MV_SOC_MDIO_BASE(Cp) MV_SOC_CP_BASE ((Cp)) + 0x12A200 > diff --git a/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h b/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h > index 41d9642..b608c8c 100644 > --- a/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h > +++ b/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h > @@ -37,6 +37,21 @@ ArmadaSoCDescComPhyGet ( > ); > > // > +// I2C > +// > +typedef struct { > + UINT8 I2cId; UINTN. / Leif > + UINTN I2cBaseAddress; > +} MV_SOC_I2C_DESC; > + > +EFI_STATUS > +EFIAPI > +ArmadaSoCDescI2cGet ( > + IN OUT MV_SOC_I2C_DESC **I2cDesc, > + IN OUT UINT8 *DescCount > + ); > + > +// > // MDIO > // > typedef struct { > -- > 2.7.4 >