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@nuviainc.com, ardb+tianocore@kernel.org, mw@semihalf.com,
	jaz@semihalf.com, kostap@marvell.com, upstream@semihalf.com
Subject: [edk2-platforms PATCH 3/6] Marvell/Armada70x0Db: Update CP0 MMC settings
Date: Mon, 19 Apr 2021 10:48:58 +0200	[thread overview]
Message-ID: <20210419084901.380576-4-mw@semihalf.com> (raw)
In-Reply-To: <20210419084901.380576-1-mw@semihalf.com>

This patch enables switching to 1.8V power supply
on the VCCQ rail of the CP0 MMC interface,
which allows to operate at HS200 in EDK2 and when
booting with ACPI.

Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
 Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h     |  1 +
 Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c |  2 +-
 Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c     | 79 +++++++++++++++-----
 3 files changed, 61 insertions(+), 21 deletions(-)

diff --git a/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h
index 73a71ad3c4..85af61ec3f 100644
--- a/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h
+++ b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.h
@@ -13,5 +13,6 @@
 #define ARMADA_70x0_DB_VBUS0_LIMIT_PIN    4
 #define ARMADA_70x0_DB_VBUS1_PIN          1
 #define ARMADA_70x0_DB_VBUS1_LIMIT_PIN    5
+#define ARMADA_70x0_DB_SDMMC_CP0_VCCQ_PIN 15
 
 #endif
diff --git a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
index ae13e0a845..b0b6855bbb 100644
--- a/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
+++ b/Platform/Marvell/Armada70x0Db/Armada70x0DbBoardDescLib/Armada70x0DbBoardDescLib.c
@@ -104,7 +104,7 @@ MV_BOARD_SDMMC_DESC mSdMmcDescTemplate[] = {
   { /* SD/MMC 0xF2780000 */
     0,     /* SOC will be filled by MvBoardDescDxe */
     0,     /* SdMmcDevCount will be filled by MvBoardDescDxe */
-    FALSE, /* Xenon1v8Enabled */
+    TRUE,  /* Xenon1v8Enabled */
     FALSE, /* Xenon8BitBusEnabled */
     FALSE, /* XenonSlowModeEnabled */
     0x19,  /* XenonTuningStepDivisor */
diff --git a/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c
index 92a14bb4f0..4d790103a4 100644
--- a/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c
+++ b/Platform/Marvell/Armada70x0Db/NonDiscoverableInitLib/NonDiscoverableInitLib.c
@@ -21,6 +21,37 @@
 
 #include "NonDiscoverableInitLib.h"
 
+STATIC
+EFI_STATUS
+EFIAPI
+ConfigurePins (
+  IN  CONST MV_GPIO_PIN        *VbusPin,
+  IN  UINTN                     PinCount,
+  IN  MV_GPIO_DRIVER_TYPE       DriverType
+  )
+{
+  EMBEDDED_GPIO_MODE   Mode;
+  EMBEDDED_GPIO_PIN    Gpio;
+  EMBEDDED_GPIO       *GpioProtocol;
+  EFI_STATUS           Status;
+  UINTN                Index;
+
+  Status = MvGpioGetProtocol (DriverType, &GpioProtocol);
+  if (EFI_ERROR (Status)) {
+    DEBUG ((DEBUG_ERROR, "%a: Unable to find GPIO protocol\n", __FUNCTION__));
+    return Status;
+  }
+
+  for (Index = 0; Index < PinCount; Index++) {
+    Mode = VbusPin->ActiveHigh ? GPIO_MODE_OUTPUT_1 : GPIO_MODE_OUTPUT_0;
+    Gpio = GPIO (VbusPin->ControllerId, VbusPin->PinNumber);
+    GpioProtocol->Set (GpioProtocol, Gpio, Mode);
+    VbusPin++;
+  }
+
+  return EFI_SUCCESS;
+}
+
 STATIC CONST MV_GPIO_PIN mXhciVbusPins[] = {
   {
     MV_GPIO_DRIVER_TYPE_PCA95XX,
@@ -55,28 +86,30 @@ XhciInit (
   IN  NON_DISCOVERABLE_DEVICE  *This
   )
 {
-  CONST MV_GPIO_PIN   *VbusPin;
-  EMBEDDED_GPIO_MODE   Mode;
-  EMBEDDED_GPIO_PIN    Gpio;
-  EMBEDDED_GPIO       *GpioProtocol;
-  EFI_STATUS           Status;
-  UINTN                Index;
-
-  Status = MvGpioGetProtocol (MV_GPIO_DRIVER_TYPE_PCA95XX, &GpioProtocol);
-  if (EFI_ERROR (Status)) {
-    DEBUG ((DEBUG_ERROR, "%a: Unable to find GPIO protocol\n", __FUNCTION__));
-    return Status;
-  }
+  return ConfigurePins (mXhciVbusPins,
+           ARRAY_SIZE (mXhciVbusPins),
+           MV_GPIO_DRIVER_TYPE_PCA95XX);
+}
 
-  VbusPin = mXhciVbusPins;
-  for (Index = 0; Index < ARRAY_SIZE (mXhciVbusPins); Index++) {
-    Mode = VbusPin->ActiveHigh ? GPIO_MODE_OUTPUT_1 : GPIO_MODE_OUTPUT_0;
-    Gpio = GPIO (VbusPin->ControllerId, VbusPin->PinNumber);
-    GpioProtocol->Set (GpioProtocol, Gpio, Mode);
-    VbusPin++;
-  }
+STATIC CONST MV_GPIO_PIN mCp0SdMmcPins[] = {
+  {
+    MV_GPIO_DRIVER_TYPE_PCA95XX,
+    ARMADA_70x0_DB_IO_EXPANDER0,
+    ARMADA_70x0_DB_SDMMC_CP0_VCCQ_PIN,
+    TRUE,
+  },
+};
 
-  return EFI_SUCCESS;
+STATIC
+EFI_STATUS
+EFIAPI
+Cp0SdMmcInit (
+  IN  NON_DISCOVERABLE_DEVICE  *This
+  )
+{
+  return ConfigurePins (mCp0SdMmcPins,
+           ARRAY_SIZE (mCp0SdMmcPins),
+           MV_GPIO_DRIVER_TYPE_PCA95XX);
 }
 
 NON_DISCOVERABLE_DEVICE_INIT
@@ -90,5 +123,11 @@ NonDiscoverableDeviceInitializerGet (
         return XhciInit;
   }
 
+  if (Type == NonDiscoverableDeviceTypeSdhci) {
+    switch (Index) {
+    case 1:
+      return Cp0SdMmcInit;
+    }
+  }
   return NULL;
 }
-- 
2.29.0


  parent reply	other threads:[~2021-04-19  8:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19  8:48 [edk2-platforms PATCH 0/6] Marvell SD/MMC updates Marcin Wojtas
2021-04-19  8:48 ` [edk2-platforms PATCH 1/6] Marvell/Armada80x0Db: Update CP0 MMC settings Marcin Wojtas
2021-04-19  8:48 ` [edk2-platforms PATCH 2/6] Marvell/Armada80x0Db: Introduce SD/MMC ACPI description Marcin Wojtas
2021-04-19  8:48 ` Marcin Wojtas [this message]
2021-04-19  8:48 ` [edk2-platforms PATCH 4/6] Marvell/Armada70x0Db: " Marcin Wojtas
2021-04-19  8:49 ` [edk2-platforms PATCH 5/6] Marvell/Cn913xDb: Update AP807 MMC settings Marcin Wojtas
2021-04-19  8:49 ` [edk2-platforms PATCH 6/6] Marvell/Cn913xDb: Introduce SD/MMC ACPI description Marcin Wojtas
2021-04-19  8:52 ` [edk2-platforms PATCH 0/6] Marvell SD/MMC updates Marcin Wojtas
2021-04-30 18:04   ` Marcin Wojtas
2021-05-10 16:07     ` Ard Biesheuvel
2021-05-10 16:08       ` Marcin Wojtas

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=20210419084901.380576-4-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