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 <mw@semihalf.com>
> Reviewed-by: Hua Jing <jinghua@marvell.com>
> ---
> 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
>
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel