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::241; helo=mail-lf0-x241.google.com; envelope-from=mw@semihalf.com; receiver=edk2-devel@lists.01.org Received: from mail-lf0-x241.google.com (mail-lf0-x241.google.com [IPv6:2a00:1450:4010:c07::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 EC83221123E26 for ; Fri, 8 Jun 2018 08:35:10 -0700 (PDT) Received: by mail-lf0-x241.google.com with SMTP id n15-v6so20685837lfn.10 for ; Fri, 08 Jun 2018 08:35:10 -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=KT5QRtbDgwbXtcwA3t39e0jGJBkylObyDkexSA3FiK0=; b=UYb7Zzj5onT3l+rlxTQY31S/iWZjQaZKLEFqlPJ8kn+q7LVW9lZ4jfbYeY/dxTYK2v 8TxeOGoJbkazjW1UxOPA5usCh8x7rsxt67N3VkyomqAA9oVt4IIDCYU2z5tJgFQFAqAK YIk2vU6fhwU9cfjsLXn1qx5w31kCeIv9f4wUu/r/+caVbWoW2JD82FMJo58glzv9NmU4 oC+jBj6DlsLGH8L9fwFOS3+F5h6848XvV/5YNn3fNYzPD5MqygYPKdOLa1jtMQQ8Rx9s LvcQXO3Ki9XVWLed0J8XB8aFF7D3/xf7kXH6i4Ub+jGD5JY/D0IBvHSplE8F0AHV7DHD 45dg== 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=KT5QRtbDgwbXtcwA3t39e0jGJBkylObyDkexSA3FiK0=; b=jQWc9c/FkbSnbwx/BIPxjUKXZYfU0uacgp3l2CjeF3u6u23upMYeJyGQw/VLnbjRqu UznsWTjQHcti0Kn5+cVeqtqa0l971F8wWLnJTPqMgcdLrswy8IHusr3HzLylBTHulJqC fFcTII/fzvGWqF9mkmwWK5He18FXzG9q1Likte/DVzc9560dsiWBtID/t6tjz2aK804D FsyDIRf7m87knL6bjgaP00Y2AWQW4TGf9a3AcNiwwsmBd+1iWcKs2MRQ9Gvl1hnoaEn0 0B9GWTxQCCp/kbb7UNw1OZ/qIX6bBjsmjHzZOcHMr0I8CIuVDAxdEnGluBFDXcEKXBmx UnGA== X-Gm-Message-State: APt69E1OHwEdkpDbg20dZVco6SzpNqb3ZAX3Z9cZC9pFnF2FM4RwBB6l DBulMl3Mo1FHQPGXZ7lgk2xUapStMwI= X-Google-Smtp-Source: ADUXVKJIieyQjzl8UBkUcEbjGdKwP1tcbToTk01UKcWjVwirq1oBwC7HHCSFwaVyGv9VN8glTUA41Q== X-Received: by 2002:a2e:f11:: with SMTP id 17-v6mr5090998ljp.47.1528472109034; Fri, 08 Jun 2018 08:35:09 -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 v79-v6sm7355396lfd.32.2018.06.08.08.35.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jun 2018 08:35:08 -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: Fri, 8 Jun 2018 17:34:20 +0200 Message-Id: <1528472063-1660-23-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1528472063-1660-1-git-send-email-mw@semihalf.com> References: <1528472063-1660-1-git-send-email-mw@semihalf.com> Subject: [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: Fri, 08 Jun 2018 15:35:11 -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: 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) + +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; + + 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; + + 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 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