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 6B44520972826 for ; Sun, 17 Jun 2018 13:12:55 -0700 (PDT) Received: by mail-lf0-x243.google.com with SMTP id t2-v6so15162175lfd.6 for ; Sun, 17 Jun 2018 13:12:55 -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=sgBVFVTgcMww4+7geSEcoKcXvIc2Zsu8/N9GeyB7Ma8=; b=oQBXm97Cx8AJknkJTUf/hguy3OgDVi+gTKiwXQuU8CQ+0HDXAXj3jjzUseYNQHEPcB /0CQh6yJQKL1dp1LuYf3AKrfvucX+0GhWJGxfGXIa42IJhvZIv6IhGkqktPRx3iaQocv VeOjTqTfqblH9Af93wsL2C35nmJ3LNOfERBAGJXGjLdG8MPZsRC7exAmJLeRRBaFr6Yn a3uIeEGSwWOKU7u1XzuwSpr+pYmPEXmlKFVDh1Xee+S1wqr7+w7/vOLPov7IGaJdjUl9 8eT5pFVWhyKlyxLMJMd9TMygdfDurRIuz8ubSaBGsR9RR9JXgEBYDMlOpHaOp5s64385 MUYQ== 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=sgBVFVTgcMww4+7geSEcoKcXvIc2Zsu8/N9GeyB7Ma8=; b=BhrFlv7ZTMCNi5PIy1rrYeks4IZr0+2h5GlT1EuR/WCo5YyIXy1fs4XkFiEQGs/JOu Ek/WQ9QbalMq5i4fUdy76U6wEIdI32Yzj+mgbXTQZk2YdyjJx+6CDBdaca/fqzYbFXZF rYooRVgHuLg4u3ZmpyIDnFxyCWVlEyYeI59BNx+O13MSdTxOFRXkNsQpMtVmIIkyefO/ Hoz/+W20e3e5KBg3LoVuC+0kb8RVAzhI8LY82RI6iEqZZPsQVlIqD5PL+EZ6m/prK9i8 qU3N+Kf/V2ewYDoe9uC23zL+XVHrEt23ZTIEV7oeBfObtmIUXWFedr7YsMMsk20l4ILR tIJg== X-Gm-Message-State: APt69E0s8TO8jDHtNPP4RiJju1TH/YW2DJjauxU1z1sel5q1auaiY0us MCwePYqFeXShGpJsEyF/S05+zY4jT6E= X-Google-Smtp-Source: ADUXVKLr503AR9QZyPosAMf9iqLD4+bb+5g3y5ghKL35Dhsna18qSnTOkqf1cdrtjAPLD7xJzewtIw== X-Received: by 2002:a19:4b52:: with SMTP id y79-v6mr5549536lfa.49.1529266373470; Sun, 17 Jun 2018 13:12:53 -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 q75-v6sm387272lfq.47.2018.06.17.13.12.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 17 Jun 2018 13:12:52 -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: Sun, 17 Jun 2018 22:12:02 +0200 Message-Id: <1529266325-18371-23-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529266325-18371-1-git-send-email-mw@semihalf.com> References: <1529266325-18371-1-git-send-email-mw@semihalf.com> Subject: [platforms: PATCH v2 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: Sun, 17 Jun 2018 20:12:55 -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 --- 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 c864f94..b1219c4 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