public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Marcin Wojtas" <mw@semihalf.com>
To: devel@edk2.groups.io
Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org,
	mw@semihalf.com, jsd@semihalf.com, jaz@semihalf.com,
	kostap@marvell.com
Subject: [edk2-platforms: PATCH v4 4/9] Marvell/Library: ArmadaSoCDescLib/MppLib: Extend Xenon information
Date: Fri, 11 Oct 2019 17:20:26 +0200	[thread overview]
Message-ID: <1570807231-4155-5-git-send-email-mw@semihalf.com> (raw)
In-Reply-To: <1570807231-4155-1-git-send-email-mw@semihalf.com>

Hitherto SoC description and MppLib libraries code assumed
that there could be only two Xenon SdMmc controller
instances in the SoC. Remove those limitations, so that
to support CN913x SoCs, which may have up to 4 of such interfaces.

Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Acked-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h |  5 +--
 Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c | 34 +++++++++++++-------
 Silicon/Marvell/Library/MppLib/MppLib.c                                        |  4 +--
 3 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h
index 0296d43..265b4f4 100644
--- a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h
+++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.h
@@ -90,8 +90,9 @@
 //
 // Platform description of SDMMC controllers
 //
-#define MV_SOC_MAX_SDMMC_COUNT           2
-#define MV_SOC_SDMMC_BASE(Index)         ((Index) == 0 ? 0xF06E0000 : 0xF2780000)
+#define MV_SOC_SDMMC_PER_CP_COUNT        1
+#define MV_SOC_AP80X_SDMMC_BASE          0xF06E0000
+#define MV_SOC_CP_SDMMC_BASE(Cp)         (MV_SOC_CP_BASE (Cp) + 0x780000)
 
 //
 // Platform description of UTMI PHY's
diff --git a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c
index 5947601..3ffd57e 100644
--- a/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c
+++ b/Silicon/Marvell/Armada7k8k/Library/Armada7k8kSoCDescLib/Armada7k8kSoCDescLib.c
@@ -349,26 +349,36 @@ EFI_STATUS
 EFIAPI
 ArmadaSoCDescSdMmcGet (
   IN OUT MV_SOC_SDMMC_DESC  **SdMmcDesc,
-  IN OUT UINTN               *DescCount
+  IN OUT UINTN               *Count
   )
 {
-  MV_SOC_SDMMC_DESC *Desc;
-  UINTN Index;
+  MV_SOC_SDMMC_DESC *SdMmc;
+  UINTN CpCount, CpIndex;
 
-  Desc = AllocateZeroPool (MV_SOC_MAX_SDMMC_COUNT * sizeof (MV_SOC_SDMMC_DESC));
-  if (Desc == NULL) {
+  CpCount = FixedPcdGet8 (PcdMaxCpCount);
+
+  *Count = CpCount * MV_SOC_SDMMC_PER_CP_COUNT + MV_SOC_AP806_COUNT;
+  SdMmc = AllocateZeroPool (*Count * sizeof (MV_SOC_SDMMC_DESC));
+  if (SdMmc == NULL) {
     DEBUG ((DEBUG_ERROR, "%a: Cannot allocate memory\n", __FUNCTION__));
     return EFI_OUT_OF_RESOURCES;
   }
 
-  for (Index = 0; Index < MV_SOC_MAX_SDMMC_COUNT; Index++) {
-    Desc[Index].SdMmcBaseAddress = MV_SOC_SDMMC_BASE (Index);
-    Desc[Index].SdMmcMemSize = SIZE_1KB;
-    Desc[Index].SdMmcDmaType = NonDiscoverableDeviceDmaTypeCoherent;
-  }
+  *SdMmcDesc = SdMmc;
+
+  /* AP80x controller */
+  SdMmc->SdMmcBaseAddress = MV_SOC_AP80X_SDMMC_BASE;
+  SdMmc->SdMmcMemSize = SIZE_1KB;
+  SdMmc->SdMmcDmaType = NonDiscoverableDeviceDmaTypeCoherent;
+  SdMmc++;
 
-  *SdMmcDesc = Desc;
-  *DescCount = MV_SOC_MAX_SDMMC_COUNT;
+  /* CP11x controllers */
+  for (CpIndex = 0; CpIndex < CpCount; CpIndex++) {
+    SdMmc->SdMmcBaseAddress = MV_SOC_CP_SDMMC_BASE (CpIndex);
+    SdMmc->SdMmcMemSize = SIZE_1KB;
+    SdMmc->SdMmcDmaType = NonDiscoverableDeviceDmaTypeCoherent;
+    SdMmc++;
+  }
 
   return EFI_SUCCESS;
 }
diff --git a/Silicon/Marvell/Library/MppLib/MppLib.c b/Silicon/Marvell/Library/MppLib/MppLib.c
index 40d9077..f20668d 100644
--- a/Silicon/Marvell/Library/MppLib/MppLib.c
+++ b/Silicon/Marvell/Library/MppLib/MppLib.c
@@ -139,11 +139,9 @@ SetSdMmcPhyMpp (
   case 0:
     Offset = SD_MMC_PHY_AP_MPP_OFFSET;
     break;
-  case 1:
+  default:
     Offset = SD_MMC_PHY_CP0_MPP_OFFSET;
     break;
-  default:
-    return;
   }
 
   /*
-- 
2.7.4


  parent reply	other threads:[~2019-10-11 15:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 15:20 [edk2-platforms: PATCH v4 0/9] Marvell Octeon CN913X SoC family support Marcin Wojtas
2019-10-11 15:20 ` [edk2-platforms: PATCH v4 1/9] Marvell/Armada7k8k: Fix 32-bit compilation Marcin Wojtas
2019-10-11 15:20 ` [edk2-platforms: PATCH v4 2/9] Marvell/Cn9130Db: Add ACPI tables Marcin Wojtas
2019-10-11 15:20 ` [edk2-platforms: PATCH v4 3/9] Marvell/Cn9130Db: Introduce board support Marcin Wojtas
2019-10-11 15:20 ` Marcin Wojtas [this message]
2019-10-11 15:20 ` [edk2-platforms: PATCH v4 5/9] Marvell/Library: IcuLib: Fix debug information Marcin Wojtas
2019-10-11 15:20 ` [edk2-platforms: PATCH v4 6/9] Marvell/Cn9131Db: Introduce board support Marcin Wojtas
2019-10-11 15:20 ` [edk2-platforms: PATCH v4 7/9] Marvell/Cn9132Db: " Marcin Wojtas
2019-10-11 15:20 ` [edk2-platforms: PATCH v4 8/9] Marvell/Drivers: SmbiosPlatformDxe: Load SMBIOS strings from PCD Marcin Wojtas
2019-10-14  8:43   ` Leif Lindholm
2019-10-11 15:20 ` [edk2-platforms: PATCH v4 9/9] Marvell: Customize per-board SBMIOS strings Marcin Wojtas
2019-10-14  8:44   ` Leif Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1570807231-4155-5-git-send-email-mw@semihalf.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox