public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1 edk-platforms 0/3] enable eMMC/SD driver on HiKey
@ 2018-08-10  8:49 Haojian Zhuang
  2018-08-10  8:49 ` [PATCH v1 edk-platforms 1/3] Silicon/Hi3660: fix LDO9_VSET register definition Haojian Zhuang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Haojian Zhuang @ 2018-08-10  8:49 UTC (permalink / raw)
  To: edk2-devel

Changelog:
v1:
  * Enable eMMC/SD driver on HiKey.
  * Enable SD driver on HiKey960.

Haojian Zhuang (3):
  Silicon/Hi3660: fix LDO9_VSET register definition
  Platform/HiKey960: enable SD controller
  Platform/HiKey: enable SD/MMC controller on HiKey

 Platform/Hisilicon/HiKey/HiKey.dsc                            |  17 +--
 Platform/Hisilicon/HiKey960/HiKey960.dsc                      |   8 ++
 Platform/Hisilicon/HiKey/HiKey.fdf                            |  15 ++-
 Platform/Hisilicon/HiKey960/HiKey960.fdf                      |   8 ++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf                |   1 +
 Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf          |  45 +++++++
 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf       |   1 +
 Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf |  46 +++++++
 Silicon/Hisilicon/Hi3660/Include/Hi3660.h                     |   2 +-
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c                  |  26 ++++
 Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.c            | 139 ++++++++++++++++++++
 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c         |  15 +++
 Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c   | 125 ++++++++++++++++++
 13 files changed, 431 insertions(+), 17 deletions(-)
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf
 create mode 100644 Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.c
 create mode 100644 Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c

Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
-- 
2.7.4



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v1 edk-platforms 1/3] Silicon/Hi3660: fix LDO9_VSET register definition
  2018-08-10  8:49 [PATCH v1 edk-platforms 0/3] enable eMMC/SD driver on HiKey Haojian Zhuang
@ 2018-08-10  8:49 ` Haojian Zhuang
  2018-08-15 13:29   ` Leif Lindholm
  2018-08-10  8:49 ` [PATCH v1 edk-platforms 2/3] Platform/HiKey960: enable SD controller Haojian Zhuang
  2018-08-10  8:49 ` [PATCH v1 edk-platforms 3/3] Platform/HiKey: enable SD/MMC controller on HiKey Haojian Zhuang
  2 siblings, 1 reply; 6+ messages in thread
From: Haojian Zhuang @ 2018-08-10  8:49 UTC (permalink / raw)
  To: edk2-devel

Fix the LDO9_VSET register definition in PMIC.

Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 Silicon/Hisilicon/Hi3660/Include/Hi3660.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Silicon/Hisilicon/Hi3660/Include/Hi3660.h b/Silicon/Hisilicon/Hi3660/Include/Hi3660.h
index 5fbf32267657..6e0587f7783a 100644
--- a/Silicon/Hisilicon/Hi3660/Include/Hi3660.h
+++ b/Silicon/Hisilicon/Hi3660/Include/Hi3660.h
@@ -58,7 +58,7 @@
 #define USB3OTG_PHY_CR_CAP_ADDR                 (1 << 0)
 
 #define PMU_REG_BASE                            0xFFF34000
-#define PMIC_LDO9_VSET_REG                      (PMU_REG_BASE + (0x068 << 2))
+#define PMIC_LDO9_VSET_REG                      (PMU_REG_BASE + (0x06b << 2))
 #define LDO9_VSET_MASK                          (7 << 0)
 
 #define PMIC_LDO16_ONOFF_ECO_REG                (PMU_REG_BASE + (0x078 << 2))
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 edk-platforms 2/3] Platform/HiKey960: enable SD controller
  2018-08-10  8:49 [PATCH v1 edk-platforms 0/3] enable eMMC/SD driver on HiKey Haojian Zhuang
  2018-08-10  8:49 ` [PATCH v1 edk-platforms 1/3] Silicon/Hi3660: fix LDO9_VSET register definition Haojian Zhuang
@ 2018-08-10  8:49 ` Haojian Zhuang
  2018-08-10  8:49 ` [PATCH v1 edk-platforms 3/3] Platform/HiKey: enable SD/MMC controller on HiKey Haojian Zhuang
  2 siblings, 0 replies; 6+ messages in thread
From: Haojian Zhuang @ 2018-08-10  8:49 UTC (permalink / raw)
  To: edk2-devel

Enable DwMmcHcDxe driver on HiKey960 platform.

Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 Platform/Hisilicon/HiKey960/HiKey960.dsc                      |   8 ++
 Platform/Hisilicon/HiKey960/HiKey960.fdf                      |   8 ++
 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf       |   1 +
 Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf |  46 +++++++
 Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c         |  15 +++
 Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c   | 125 ++++++++++++++++++++
 6 files changed, 203 insertions(+)

diff --git a/Platform/Hisilicon/HiKey960/HiKey960.dsc b/Platform/Hisilicon/HiKey960/HiKey960.dsc
index be13714b9c19..1ce306da5b50 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platform/Hisilicon/HiKey960/HiKey960.dsc
@@ -193,6 +193,14 @@ [Components.common]
   #
   EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
 
+  #
+  # MMC/SD
+  #
+  Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf
+  EmbeddedPkg/Universal/NonDiscoverableDeviceDxe/NonDiscoverableDeviceDxe.inf
+  EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf
+  MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf
+
   Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960.fdf b/Platform/Hisilicon/HiKey960/HiKey960.fdf
index d65f77878575..d4fe4c46b818 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960.fdf
+++ b/Platform/Hisilicon/HiKey960/HiKey960.fdf
@@ -128,6 +128,14 @@ [FV.FvMain]
   #
   INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
 
+  #
+  # MMC/SD
+  #
+  INF Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf
+  INF EmbeddedPkg/Universal/NonDiscoverableDeviceDxe/NonDiscoverableDeviceDxe.inf
+  INF EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf
+  INF MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf
+
   INF Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
 
   #
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
index 54105bdb3c94..9d66c028832e 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.inf
@@ -33,6 +33,7 @@ [LibraryClasses]
   CacheMaintenanceLib
   DxeServicesTableLib
   IoLib
+  NonDiscoverableDeviceRegistrationLib
   PcdLib
   TimerLib
   UefiBootManagerLib
diff --git a/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf b/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf
new file mode 100644
index 000000000000..3e4bc807956e
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.inf
@@ -0,0 +1,46 @@
+#/** @file
+#
+#  Copyright (c) 2018, Linaro. All rights reserved.
+#
+#  This program and the accompanying materials are licensed and made available
+#  under the terms and conditions of the BSD License which accompanies this
+#  distribution. The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+#**/
+
+[Defines]
+  INF_VERSION                    = 0x00010019
+  BASE_NAME                      = HiKey960MmcDxe
+  FILE_GUID                      = e10d1dea-2f00-4eea-ac5d-9d6cfa7831a0
+  MODULE_TYPE                    = UEFI_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = HiKey960MmcEntryPoint
+
+[Sources.common]
+  HiKey960MmcDxe.c
+
+[LibraryClasses]
+  DebugLib
+  IoLib
+  TimerLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gEfiDriverBindingProtocolGuid
+  gEmbeddedGpioProtocolGuid
+  gPlatformDwMmcProtocolGuid
+
+[Packages]
+  EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  Silicon/Hisilicon/Hi3660/Hi3660.dec
+
+[Depex]
+  TRUE
diff --git a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
index 47ec879861bd..75627d5d6665 100644
--- a/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
+++ b/Platform/Hisilicon/HiKey960/HiKey960Dxe/HiKey960Dxe.c
@@ -23,6 +23,7 @@
 #include <Library/DevicePathLib.h>
 #include <Library/IoLib.h>
 #include <Library/MemoryAllocationLib.h>
+#include <Library/NonDiscoverableDeviceRegistrationLib.h>
 #include <Library/PrintLib.h>
 #include <Library/SerialPortLib.h>
 #include <Library/TimerLib.h>
@@ -33,6 +34,7 @@
 #include <Protocol/DevicePathFromText.h>
 #include <Protocol/EmbeddedGpio.h>
 #include <Protocol/LoadedImage.h>
+#include <Protocol/NonDiscoverableDevice.h>
 #include <Protocol/PlatformBootManager.h>
 #include <Protocol/PlatformVirtualKeyboard.h>
 
@@ -447,6 +449,19 @@ HiKey960EntryPoint (
     return Status;
   }
 
+  Status = RegisterNonDiscoverableMmioDevice (
+             NonDiscoverableDeviceTypeSdhci,
+             NonDiscoverableDeviceDmaTypeNonCoherent,
+             NULL,
+             NULL,
+             1,
+             0xFF37F000, // SD
+             SIZE_4KB
+             );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
   Status = gBS->InstallProtocolInterface (
                   &ImageHandle,
                   &gPlatformVirtualKeyboardProtocolGuid,
diff --git a/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c b/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c
new file mode 100644
index 000000000000..0a2b60edf352
--- /dev/null
+++ b/Platform/Hisilicon/HiKey960/HiKey960MmcDxe/HiKey960MmcDxe.c
@@ -0,0 +1,125 @@
+/** @file
+*
+*  Copyright (c) 2018, Linaro. All rights reserved.
+*
+*  This program and the accompanying materials are licensed and made available
+*  under the terms and conditions of the BSD License which accompanies this
+*  distribution.  The full text of the license may be found at
+*  http://opensource.org/licenses/bsd-license.php
+*
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+*
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/IoLib.h>
+#include <Library/TimerLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+
+#include <Protocol/EmbeddedGpio.h>
+#include <Protocol/PlatformDwMmc.h>
+
+#include <Hi3660.h>
+
+#define DETECT_SD_CARD           203     // GPIO 25_3
+
+DW_MMC_HC_SLOT_CAP
+DwMmcCapability[] = {
+  {
+    .HighSpeed   = 1,
+    .BusWidth    = 4,
+    .SlotType    = RemovableSlot,
+    .CardType    = SdCardType,
+    .Voltage30   = 1,
+    .BaseClkFreq = 3200
+  }
+};
+
+EFI_STATUS
+EFIAPI
+HiKey960GetCapability (
+  IN     EFI_HANDLE           Controller,
+  IN     UINT8                Slot,
+     OUT DW_MMC_HC_SLOT_CAP   *Capability
+  )
+{
+  if (Capability == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+  if (DwMmcCapability[0].Controller == 0) {
+    DwMmcCapability[0].Controller = Controller;
+    CopyMem (Capability, &DwMmcCapability[0], sizeof (DW_MMC_HC_SLOT_CAP));
+  } else if (DwMmcCapability[0].Controller == Controller) {
+    CopyMem (Capability, &DwMmcCapability[0], sizeof (DW_MMC_HC_SLOT_CAP));
+  } else {
+    return EFI_INVALID_PARAMETER;
+  }
+  return EFI_SUCCESS;
+}
+
+BOOLEAN
+EFIAPI
+HiKey960CardDetect (
+  IN EFI_HANDLE               Controller,
+  IN UINT8                    Slot
+  )
+{
+  EFI_STATUS            Status;
+  EMBEDDED_GPIO         *Gpio;
+  UINTN                 Value;
+
+  if (Slot == 0) {
+    Status = gBS->LocateProtocol (&gEmbeddedGpioProtocolGuid, NULL, (VOID **)&Gpio);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed to get GPIO protocol: %r\n", Status));
+      goto Exit;
+    }
+    Status = Gpio->Set (Gpio, DETECT_SD_CARD, GPIO_MODE_INPUT);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed to sed GPIO as input mode: %r\n", Status));
+      goto Exit;
+    }
+    Status = Gpio->Get (Gpio, DETECT_SD_CARD, &Value);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed to get GPIO value: %r\n", Status));
+      goto Exit;
+    }
+    if (Value == 0) {
+      return TRUE;
+    }
+  }
+Exit:
+  return FALSE;
+}
+
+PLATFORM_DW_MMC_PROTOCOL mDwMmcDevice = {
+  HiKey960GetCapability,
+  HiKey960CardDetect
+};
+
+EFI_STATUS
+EFIAPI
+HiKey960MmcEntryPoint (
+  IN EFI_HANDLE                            ImageHandle,
+  IN EFI_SYSTEM_TABLE                      *SystemTable
+  )
+{
+  EFI_STATUS        Status;
+
+  Status = gBS->InstallProtocolInterface (
+                  &ImageHandle,
+                  &gPlatformDwMmcProtocolGuid,
+                  EFI_NATIVE_INTERFACE,
+                  &mDwMmcDevice
+                  );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  return Status;
+}
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 edk-platforms 3/3] Platform/HiKey: enable SD/MMC controller on HiKey
  2018-08-10  8:49 [PATCH v1 edk-platforms 0/3] enable eMMC/SD driver on HiKey Haojian Zhuang
  2018-08-10  8:49 ` [PATCH v1 edk-platforms 1/3] Silicon/Hi3660: fix LDO9_VSET register definition Haojian Zhuang
  2018-08-10  8:49 ` [PATCH v1 edk-platforms 2/3] Platform/HiKey960: enable SD controller Haojian Zhuang
@ 2018-08-10  8:49 ` Haojian Zhuang
  2 siblings, 0 replies; 6+ messages in thread
From: Haojian Zhuang @ 2018-08-10  8:49 UTC (permalink / raw)
  To: edk2-devel

Replace DwEmmcDxe driver by DwMmcHcDxe driver on HiKey platform. Since
the new driver could work on both eMMC and SD controller.

Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 Platform/Hisilicon/HiKey/HiKey.dsc                   |  17 +--
 Platform/Hisilicon/HiKey/HiKey.fdf                   |  15 ++-
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf       |   1 +
 Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf |  45 +++++++
 Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c         |  26 ++++
 Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.c   | 139 ++++++++++++++++++++
 6 files changed, 227 insertions(+), 16 deletions(-)

diff --git a/Platform/Hisilicon/HiKey/HiKey.dsc b/Platform/Hisilicon/HiKey/HiKey.dsc
index 9c1fc2e1b40d..4b5b73c15afe 100644
--- a/Platform/Hisilicon/HiKey/HiKey.dsc
+++ b/Platform/Hisilicon/HiKey/HiKey.dsc
@@ -126,12 +126,6 @@ [PcdsFixedAtBuild.common]
   gEmbeddedTokenSpaceGuid.PcdMetronomeTickPeriod|1000
 
   #
-  # DW MMC/SD card controller
-  #
-  gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeBaseAddress|0xF723D000
-  gEmbeddedTokenSpaceGuid.PcdDwEmmcDxeClockFrequencyInHz|100000000
-
-  #
   #
   # Fastboot
   #
@@ -204,13 +198,16 @@ [Components.common]
   #
   EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
 
-  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
-
   #
   # MMC/SD
   #
-  EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
-  EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf
+  Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf
+  EmbeddedPkg/Universal/NonDiscoverableDeviceDxe/NonDiscoverableDeviceDxe.inf
+  EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf
+  MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf
+  MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf
+
+  Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 
   #
   # USB Host Support
diff --git a/Platform/Hisilicon/HiKey/HiKey.fdf b/Platform/Hisilicon/HiKey/HiKey.fdf
index 2bca7232b6e5..89d3e9280ff6 100644
--- a/Platform/Hisilicon/HiKey/HiKey.fdf
+++ b/Platform/Hisilicon/HiKey/HiKey.fdf
@@ -128,15 +128,18 @@ [FV.FvMain]
   #
   INF EmbeddedPkg/Drivers/VirtualKeyboardDxe/VirtualKeyboardDxe.inf
 
+  #
+  # MMC/SD
+  #
+  INF Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf
+  INF EmbeddedPkg/Universal/NonDiscoverableDeviceDxe/NonDiscoverableDeviceDxe.inf
+  INF EmbeddedPkg/Drivers/DwMmcHcDxe/DwMmcHcDxe.inf
+  INF MdeModulePkg/Bus/Sd/EmmcDxe/EmmcDxe.inf
+  INF MdeModulePkg/Bus/Sd/SdDxe/SdDxe.inf
+
   INF Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
 
   #
-  # Multimedia Card Interface
-  #
-  INF EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
-  INF EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.inf
-
-  #
   # USB Host Support
   #
   INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
index 4c4644a0fe51..3d2843fbc9f6 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.inf
@@ -32,6 +32,7 @@ [LibraryClasses]
   CacheMaintenanceLib
   DebugLib
   IoLib
+  NonDiscoverableDeviceRegistrationLib
   UefiBootManagerLib
   UefiLib
   UefiDriverEntryPoint
diff --git a/Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf b/Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf
new file mode 100644
index 000000000000..1b78d3228ccf
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.inf
@@ -0,0 +1,45 @@
+#/** @file
+#
+#  Copyright (c) 2017, Linaro. All rights reserved.
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution. The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+#**/
+
+[Defines]
+  INF_VERSION                    = 0x00010019
+  BASE_NAME                      = HiKeyMmcDxe
+  FILE_GUID                      = a4f9bfb1-b3f8-4d4d-8c04-9539173fc1f2
+  MODULE_TYPE                    = UEFI_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = HiKeyMmcEntryPoint
+
+[Sources.common]
+  HiKeyMmcDxe.c
+
+[LibraryClasses]
+  DebugLib
+  IoLib
+  TimerLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gEfiDriverBindingProtocolGuid
+  gEmbeddedGpioProtocolGuid
+  gPlatformDwMmcProtocolGuid
+
+[Packages]
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  OpenPlatformPkg/Drivers/SdMmc/DwMmcHcDxe/DwMmcHcDxe.dec
+
+[Depex]
+  TRUE
diff --git a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
index 2162b68529bd..cdec3f1dd0b0 100644
--- a/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
+++ b/Platform/Hisilicon/HiKey/HiKeyDxe/HiKeyDxe.c
@@ -17,6 +17,7 @@
 #include <Library/DevicePathLib.h>
 #include <Library/IoLib.h>
 #include <Library/MemoryAllocationLib.h>
+#include <Library/NonDiscoverableDeviceRegistrationLib.h>
 #include <Library/PcdLib.h>
 #include <Library/UefiBootManagerLib.h>
 #include <Library/UefiBootServicesTableLib.h>
@@ -351,6 +352,31 @@ HiKeyEntryPoint (
     return Status;
   }
 
+  Status = RegisterNonDiscoverableMmioDevice (
+             NonDiscoverableDeviceTypeSdhci,
+             NonDiscoverableDeviceDmaTypeNonCoherent,
+             NULL,
+             NULL,
+             1,
+             0xF723D000, // eMMC
+             SIZE_4KB
+             );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  Status = RegisterNonDiscoverableMmioDevice (
+             NonDiscoverableDeviceTypeSdhci,
+             NonDiscoverableDeviceDmaTypeNonCoherent,
+             NULL,
+             NULL,
+             1,
+             0xF723E000, // SD
+             SIZE_4KB
+             );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
   Status = gBS->InstallProtocolInterface (
                   &ImageHandle,
                   &gPlatformVirtualKeyboardProtocolGuid,
diff --git a/Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.c b/Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.c
new file mode 100644
index 000000000000..390c23018bc6
--- /dev/null
+++ b/Platform/Hisilicon/HiKey/HiKeyMmcDxe/HiKeyMmcDxe.c
@@ -0,0 +1,139 @@
+/** @file
+*
+*  Copyright (c) 2017, Linaro. All rights reserved.
+*
+*  This program and the accompanying materials
+*  are licensed and made available under the terms and conditions of the BSD License
+*  which accompanies this distribution.  The full text of the license may be found at
+*  http://opensource.org/licenses/bsd-license.php
+*
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+*
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DevicePathLib.h>
+#include <Library/IoLib.h>
+#include <Library/TimerLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+
+#include <Protocol/EmbeddedGpio.h>
+#include <Protocol/PlatformDwMmc.h>
+
+#include <Hi6220.h>
+
+#define DETECT_SD_CARD           8     // GPIO 1_0
+
+DW_MMC_HC_SLOT_CAP
+DwMmcCapability[2] = {
+  {
+    .Ddr50       = 1,
+    .HighSpeed   = 1,
+    .BusWidth    = 8,
+    .SlotType    = EmbeddedSlot,
+    .CardType    = EmmcCardType,
+    .BaseClkFreq = 100000
+  }, {
+    .HighSpeed   = 1,
+    .BusWidth    = 4,
+    .SlotType    = RemovableSlot,
+    .CardType    = SdCardType,
+    .Voltage30   = 1,
+    .BaseClkFreq = 100000
+  }
+};
+
+EFI_STATUS
+EFIAPI
+HiKeyGetCapability (
+  IN     EFI_HANDLE           Controller,
+  IN     UINT8                Slot,
+     OUT DW_MMC_HC_SLOT_CAP   *Capability
+  )
+{
+  if (Capability == NULL) {
+    return EFI_INVALID_PARAMETER;
+  }
+  if (DwMmcCapability[0].Controller == 0) {
+    DwMmcCapability[0].Controller = Controller;
+    CopyMem (Capability, &DwMmcCapability[0], sizeof (DW_MMC_HC_SLOT_CAP));
+  } else if (DwMmcCapability[0].Controller == Controller) {
+    CopyMem (Capability, &DwMmcCapability[0], sizeof (DW_MMC_HC_SLOT_CAP));
+  } else if (DwMmcCapability[1].Controller == 0) {
+    DwMmcCapability[1].Controller = Controller;
+    CopyMem (Capability, &DwMmcCapability[1], sizeof (DW_MMC_HC_SLOT_CAP));
+  } else if (DwMmcCapability[1].Controller == Controller) {
+    CopyMem (Capability, &DwMmcCapability[1], sizeof (DW_MMC_HC_SLOT_CAP));
+  } else {
+    return EFI_INVALID_PARAMETER;
+  }
+  return EFI_SUCCESS;
+}
+
+BOOLEAN
+EFIAPI
+HiKeyCardDetect (
+  IN EFI_HANDLE               Controller,
+  IN UINT8                    Slot
+  )
+{
+  EFI_STATUS            Status;
+  EMBEDDED_GPIO         *Gpio;
+  UINTN                 Value;
+
+  if (DwMmcCapability[0].Controller == Controller) {
+    return TRUE;
+  } else if (DwMmcCapability[1].Controller == Controller) {
+    Status = gBS->LocateProtocol (&gEmbeddedGpioProtocolGuid, NULL, (VOID **)&Gpio);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed to get GPIO protocol: %r\n", Status));
+      return FALSE;
+    }
+    Status = Gpio->Set (Gpio, DETECT_SD_CARD, GPIO_MODE_INPUT);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed to sed GPIO as input mode: %r\n", Status));
+      return FALSE;
+    }
+    Status = Gpio->Get (Gpio, DETECT_SD_CARD, &Value);
+    if (EFI_ERROR (Status)) {
+      DEBUG ((DEBUG_ERROR, "Failed to get GPIO value: %r\n", Status));
+      return FALSE;
+    }
+    if (Value == 0) {
+      return TRUE;
+    }
+    return FALSE;
+  }
+  return FALSE;
+}
+
+PLATFORM_DW_MMC_PROTOCOL mDwMmcDevice = {
+  HiKeyGetCapability,
+  HiKeyCardDetect
+};
+
+EFI_STATUS
+EFIAPI
+HiKeyMmcEntryPoint (
+  IN EFI_HANDLE                            ImageHandle,
+  IN EFI_SYSTEM_TABLE                      *SystemTable
+  )
+{
+  EFI_STATUS        Status;
+
+  Status = gBS->InstallProtocolInterface (
+                  &ImageHandle,
+                  &gPlatformDwMmcProtocolGuid,
+                  EFI_NATIVE_INTERFACE,
+                  &mDwMmcDevice
+                  );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  return Status;
+}
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 edk-platforms 1/3] Silicon/Hi3660: fix LDO9_VSET register definition
  2018-08-10  8:49 ` [PATCH v1 edk-platforms 1/3] Silicon/Hi3660: fix LDO9_VSET register definition Haojian Zhuang
@ 2018-08-15 13:29   ` Leif Lindholm
  2018-08-16  1:50     ` Haojian Zhuang
  0 siblings, 1 reply; 6+ messages in thread
From: Leif Lindholm @ 2018-08-15 13:29 UTC (permalink / raw)
  To: Haojian Zhuang; +Cc: edk2-devel, Ard Biesheuvel

Hi Haojian,

On Fri, Aug 10, 2018 at 04:49:33PM +0800, Haojian Zhuang wrote:
> Fix the LDO9_VSET register definition in PMIC.

Could you add some more detail to the commit message, please?:

What register was accidentally read/written before?
Does this change resolve a user-visible issue or just a hypothetical
one?

/
    Leif

> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
> ---
>  Silicon/Hisilicon/Hi3660/Include/Hi3660.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Silicon/Hisilicon/Hi3660/Include/Hi3660.h b/Silicon/Hisilicon/Hi3660/Include/Hi3660.h
> index 5fbf32267657..6e0587f7783a 100644
> --- a/Silicon/Hisilicon/Hi3660/Include/Hi3660.h
> +++ b/Silicon/Hisilicon/Hi3660/Include/Hi3660.h
> @@ -58,7 +58,7 @@
>  #define USB3OTG_PHY_CR_CAP_ADDR                 (1 << 0)
>  
>  #define PMU_REG_BASE                            0xFFF34000
> -#define PMIC_LDO9_VSET_REG                      (PMU_REG_BASE + (0x068 << 2))
> +#define PMIC_LDO9_VSET_REG                      (PMU_REG_BASE + (0x06b << 2))
>  #define LDO9_VSET_MASK                          (7 << 0)
>  
>  #define PMIC_LDO16_ONOFF_ECO_REG                (PMU_REG_BASE + (0x078 << 2))
> -- 
> 2.7.4
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 edk-platforms 1/3] Silicon/Hi3660: fix LDO9_VSET register definition
  2018-08-15 13:29   ` Leif Lindholm
@ 2018-08-16  1:50     ` Haojian Zhuang
  0 siblings, 0 replies; 6+ messages in thread
From: Haojian Zhuang @ 2018-08-16  1:50 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: edk2-devel@lists.01.org, Ard Biesheuvel

Fixed.



Best Regards

Haojian



________________________________
From: Leif Lindholm <leif.lindholm@linaro.org>
Sent: Wednesday, August 15, 2018 9:29:27 PM
To: Haojian Zhuang
Cc: edk2-devel@lists.01.org; Ard Biesheuvel
Subject: Re: [edk2][PATCH v1 edk-platforms 1/3] Silicon/Hi3660: fix LDO9_VSET register definition

Hi Haojian,

On Fri, Aug 10, 2018 at 04:49:33PM +0800, Haojian Zhuang wrote:
> Fix the LDO9_VSET register definition in PMIC.

Could you add some more detail to the commit message, please?:

What register was accidentally read/written before?
Does this change resolve a user-visible issue or just a hypothetical
one?

/
    Leif

> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
> ---
>  Silicon/Hisilicon/Hi3660/Include/Hi3660.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Silicon/Hisilicon/Hi3660/Include/Hi3660.h b/Silicon/Hisilicon/Hi3660/Include/Hi3660.h
> index 5fbf32267657..6e0587f7783a 100644
> --- a/Silicon/Hisilicon/Hi3660/Include/Hi3660.h
> +++ b/Silicon/Hisilicon/Hi3660/Include/Hi3660.h
> @@ -58,7 +58,7 @@
>  #define USB3OTG_PHY_CR_CAP_ADDR                 (1 << 0)
>
>  #define PMU_REG_BASE                            0xFFF34000
> -#define PMIC_LDO9_VSET_REG                      (PMU_REG_BASE + (0x068 << 2))
> +#define PMIC_LDO9_VSET_REG                      (PMU_REG_BASE + (0x06b << 2))
>  #define LDO9_VSET_MASK                          (7 << 0)
>
>  #define PMIC_LDO16_ONOFF_ECO_REG                (PMU_REG_BASE + (0x078 << 2))
> --
> 2.7.4
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-08-16  1:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-10  8:49 [PATCH v1 edk-platforms 0/3] enable eMMC/SD driver on HiKey Haojian Zhuang
2018-08-10  8:49 ` [PATCH v1 edk-platforms 1/3] Silicon/Hi3660: fix LDO9_VSET register definition Haojian Zhuang
2018-08-15 13:29   ` Leif Lindholm
2018-08-16  1:50     ` Haojian Zhuang
2018-08-10  8:49 ` [PATCH v1 edk-platforms 2/3] Platform/HiKey960: enable SD controller Haojian Zhuang
2018-08-10  8:49 ` [PATCH v1 edk-platforms 3/3] Platform/HiKey: enable SD/MMC controller on HiKey Haojian Zhuang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox