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::244; helo=mail-lf0-x244.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lf0-x244.google.com (mail-lf0-x244.google.com [IPv6:2a00:1450:4010:c07::244]) (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 78C0C2110A3DD for ; Mon, 18 Jun 2018 15:59:29 -0700 (PDT) Received: by mail-lf0-x244.google.com with SMTP id z207-v6so5787890lff.9 for ; Mon, 18 Jun 2018 15:59:29 -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=tBfLg+fYJ9Wla/ScJjgiPAvhxQ0/5XVYg8h0lggrEuQ=; b=j3YmiGcLUjxo781szOXesyNASXYSZs9NnM1mHmr/ii2u9Cd9DMIb0y6f1A7VrRHvIV 4LKJ/2kN0KEywiSGyWT9E1JEp29B/4cL2aMJKZW3Ylu57An6r6xz+HuzRllbzbUJ8zCv IIKWV720ckdNo2X7JZ9snZHsx2agjMSkExqjR2PD6XX/ha/Hc90KfZemPrrnXt7+OfUj QKzYxibVPAxwj39/+fQuWZcmzclXAsMkfd4Mk8Ao6gzizFMWvWgItnZuBDYZEhFRa6R2 I2/k1vTyt6vFA1lOTeIn1zvafFpZQ+oZTjmH7xgmuOFXlK1sJ+ZNgR2XCP19P4xQWGUU dKWw== 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=tBfLg+fYJ9Wla/ScJjgiPAvhxQ0/5XVYg8h0lggrEuQ=; b=ayrBuKGv3UjzjUiMK+X4zfY5+muedFe/6II4iBaE8IvrX2FLuvQgp95KINDOVOlb9F IulHPvVybr4YFbOyl2MXdSsFLye4/wGj75UZQfZC7ikIKRg7l1pRVMOGMG5sPKDoSWyH KoMNvWxvO5K8hySijF7pxVop+xQl2yCoHn7+zsU05dqjV3lkakJx8xlyuc+2Y3f8F+Eq SoFe3Lu6ccQi0HpibU/vAJDRT7dQ6mmLmpDeGyHpNBCFcRlw5KMCA8MC8XP0P0rTs0YS UxQc7CyvmiKvymDp1+wV1UoaAwNTwu5gD0LoXC0KZdoSr051HVM77PKlxT61tYCn0Zp3 EVLA== X-Gm-Message-State: APt69E2BIl/Z8qJN+nuLC8r1xIxwEPF9DwSxOHeSVyhmBCXjUpHg2sic 3GBxkcQDahplHtbbhziGxpPqEBLxa8o= X-Google-Smtp-Source: ADUXVKJ1ob5uwtiqsWKtaPzbHV8WQtiR6vzK8HuzlwOpx4eCr4gbsBUkYLJeIIAcFcqst62HgyZfKQ== X-Received: by 2002:a2e:2948:: with SMTP id u69-v6mr9230253lje.130.1529362767512; Mon, 18 Jun 2018 15:59:27 -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 h136-v6sm3020754lfe.23.2018.06.18.15.59.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Jun 2018 15:59:26 -0700 (PDT) From: Marcin Wojtas To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org, nadavh@marvell.com, jinghua@marvell.com, mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com Date: Tue, 19 Jun 2018 00:58:41 +0200 Message-Id: <1529362724-9244-23-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529362724-9244-1-git-send-email-mw@semihalf.com> References: <1529362724-9244-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH v3 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: Mon, 18 Jun 2018 22:59:30 -0000 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: Leif Lindholm --- Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h | 6 ++++ Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h | 15 ++++++++++ Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c | 31 ++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h index 87fc140..3072883 100644 --- a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h +++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h @@ -38,6 +38,12 @@ #define MV_SOC_COMPHY_MUX_BITS 4 // +// Platform description of I2C controllers +// +#define MV_SOC_I2C_PER_CP_COUNT 2 +#define MV_SOC_I2C_BASE(I2c) (0x701000 + ((I2c) * 0x100)) + +// // 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 304d068..d2bcf2a 100644 --- a/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h +++ b/Silicon/Marvell/Include/Library/ArmadaSoCDescLib.h @@ -37,6 +37,21 @@ ArmadaSoCDescComPhyGet ( ); // +// I2C +// +typedef struct { + UINTN I2cId; + UINTN I2cBaseAddress; +} MV_SOC_I2C_DESC; + +EFI_STATUS +EFIAPI +ArmadaSoCDescI2cGet ( + IN OUT MV_SOC_I2C_DESC **I2cDesc, + IN OUT UINTN *DescCount + ); + +// // MDIO // typedef struct { diff --git a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c index 652677f..6ce6bad 100644 --- a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c +++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c @@ -63,6 +63,37 @@ ArmadaSoCDescComPhyGet ( EFI_STATUS EFIAPI +ArmadaSoCDescI2cGet ( + IN OUT MV_SOC_I2C_DESC **I2cDesc, + IN OUT UINTN *DescCount + ) +{ + MV_SOC_I2C_DESC *Desc; + UINTN CpCount, CpIndex, Index; + + CpCount = FixedPcdGet8 (PcdMaxCpCount); + + *DescCount = CpCount * MV_SOC_I2C_PER_CP_COUNT; + Desc = AllocateZeroPool (*DescCount * sizeof (MV_SOC_I2C_DESC)); + if (Desc == NULL) { + DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + + *I2cDesc = Desc; + + for (CpIndex = 0; CpIndex < CpCount; CpIndex++) { + for (Index = 0; Index < MV_SOC_I2C_PER_CP_COUNT; Index++) { + Desc->I2cBaseAddress = MV_SOC_CP_BASE (CpIndex) + MV_SOC_I2C_BASE (Index); + Desc++; + } + } + + return EFI_SUCCESS; +} + +EFI_STATUS +EFIAPI ArmadaSoCDescMdioGet ( IN OUT MV_SOC_MDIO_DESC **MdioDesc, IN OUT UINTN *DescCount -- 2.7.4