Merge remote-tracking branch 'aosp/upstream-hikey-aosp' into opp am: 2e21932172 am: bfc3f8a315
am: cf7dd2dad5

Change-Id: I95ece28e9571fd93076774ea6c962bc3974bf719
diff --git a/Drivers/SdMmc/DwMmcHcDxe/DwMmcHci.c b/Drivers/SdMmc/DwMmcHcDxe/DwMmcHci.c
index cf34e30..533f911 100644
--- a/Drivers/SdMmc/DwMmcHcDxe/DwMmcHci.c
+++ b/Drivers/SdMmc/DwMmcHcDxe/DwMmcHci.c
@@ -35,7 +35,7 @@
   // Dump Capability Data

   //

   DEBUG ((DEBUG_INFO, " == Slot [%d] Capability is 0x%x ==\n", Slot, Capability));

-  DEBUG ((DEBUG_INFO, "   Base Clk Freq     %dMHz\n", Capability->BaseClkFreq));

+  DEBUG ((DEBUG_INFO, "   Base Clk Freq     %dKHz\n", Capability->BaseClkFreq));

   DEBUG ((DEBUG_INFO, "   BusWidth          %d\n", Capability->BusWidth));

   DEBUG ((DEBUG_INFO, "   HighSpeed Support %a\n", Capability->HighSpeed ? "TRUE" : "FALSE"));

   DEBUG ((DEBUG_INFO, "   Voltage 1.8       %a\n", Capability->Voltage18 ? "TRUE" : "FALSE"));

diff --git a/Drivers/SdMmc/DwMmcHcDxe/EmmcDevice.c b/Drivers/SdMmc/DwMmcHcDxe/EmmcDevice.c
index c84e7f7..deeaba9 100644
--- a/Drivers/SdMmc/DwMmcHcDxe/EmmcDevice.c
+++ b/Drivers/SdMmc/DwMmcHcDxe/EmmcDevice.c
@@ -967,7 +967,7 @@
     return Status;

   }

 

-  Timeout = 30;

+  Timeout = 100;

   do {

     Ocr = EMMC_CMD1_CAPACITY_GREATER_THAN_2GB;

     Status = EmmcGetOcr (PassThru, Slot, &Ocr);

diff --git a/Platforms/Hisilicon/HiKey/HiKey.dsc b/Platforms/Hisilicon/HiKey/HiKey.dsc
index 3b99cf5..28bc47d 100644
--- a/Platforms/Hisilicon/HiKey/HiKey.dsc
+++ b/Platforms/Hisilicon/HiKey/HiKey.dsc
@@ -131,7 +131,7 @@
 [LibraryClasses.common.SEC]

   PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf

   ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf

-  LzmaDecompressLib|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf

+  LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf

   MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf

   HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf

   PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf

@@ -455,7 +455,9 @@
   #

   EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf {

     <LibraryClasses>

+      AbootimgLib|EmbeddedPkg/Library/AbootimgLib/AbootimgLib.inf

       BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf

+      ZLib|EmbeddedPkg/Library/ZLib/ZLib.inf

   }

 

   #

@@ -463,7 +465,9 @@
   #

   EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.inf {

     <LibraryClasses>

+      AbootimgLib|EmbeddedPkg/Library/AbootimgLib/AbootimgLib.inf

       BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf

+      ZLib|EmbeddedPkg/Library/ZLib/ZLib.inf

   }

 

   #

diff --git a/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.c b/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.c
index 7e62ebb..a62c094 100644
--- a/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.c
+++ b/Platforms/Hisilicon/HiKey/HiKeyFastbootDxe/HiKeyFastbootDxe.c
@@ -133,7 +133,7 @@
       GptHeader->MyLBA != 1) {

     DEBUG ((EFI_D_ERROR,

       "Fastboot platform: No GPT on flash. "

-      "Fastboot on Versatile Express does not support MBR.\n"

+      "Fastboot on HiKey does not support MBR.\n"

       ));

     return EFI_DEVICE_ERROR;

   }

@@ -280,8 +280,12 @@
   EFI_STATUS               Status;

   EFI_DISK_IO_PROTOCOL    *DiskIo;

   UINT32                   MediaId;

+  VOID                    *Buffer;

+  UINT32                   EntrySize, EntryOffset;

+  UINTN                    BlockSize;

 

   MediaId = mFlashBlockIo->Media->MediaId;

+  BlockSize = mFlashBlockIo->Media->BlockSize;

   Status = gBS->OpenProtocol (

                   mFlashHandle,

                   &gEfiDiskIoProtocolGuid,

@@ -293,9 +297,33 @@
   if (EFI_ERROR (Status)) {

     return Status;

   }

-  Status = DiskIo->WriteDisk (DiskIo, MediaId, 0, Size, Image);

-  if (EFI_ERROR (Status)) {

-    return Status;

+  Buffer = Image;

+  if (AsciiStrnCmp (Buffer, "ENTRYHDR", 8) != 0) {

+    DEBUG ((EFI_D_ERROR, "It should be raw ptable image\n"));

+    Status = DiskIo->WriteDisk (DiskIo, MediaId, 0, Size, Image);

+    if (EFI_ERROR (Status)) {

+      return Status;

+    }

+  } else {

+    /* ptable with entry header */

+    Buffer += 8;

+    if (AsciiStrnCmp (Buffer, "primary", 7) != 0) {

+      DEBUG ((EFI_D_ERROR, "unknown ptable imag\n"));

+      return EFI_UNSUPPORTED;

+    }

+    Buffer += 8;

+    EntryOffset = *(UINT32 *)Buffer * BlockSize;

+    Buffer += 4;

+    EntrySize = *(UINT32 *)Buffer * BlockSize;

+    if ((EntrySize + BlockSize) > Size) {

+      DEBUG ((DEBUG_ERROR, "Entry size doesn't match\n"));

+      return EFI_UNSUPPORTED;

+    }

+    Buffer = Image + BlockSize;

+    Status = DiskIo->WriteDisk (DiskIo, MediaId, EntryOffset, EntrySize, Buffer);

+    if (EFI_ERROR (Status)) {

+      return Status;

+    }

   }

   FreePartitionList ();

   Status = LoadPtable ();

diff --git a/Platforms/Hisilicon/HiKey960/HiKey960.dsc b/Platforms/Hisilicon/HiKey960/HiKey960.dsc
index 4f40969..bf02a29 100644
--- a/Platforms/Hisilicon/HiKey960/HiKey960.dsc
+++ b/Platforms/Hisilicon/HiKey960/HiKey960.dsc
@@ -62,7 +62,6 @@
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf

   GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf

   PlatformBdsLib|OpenPlatformPkg/Chips/Hisilicon/Library/PlatformIntelBdsLib/PlatformIntelBdsLib.inf

-  AbootimgLib|EmbeddedPkg/Library/AbootimgLib/AbootimgLib.inf

   FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf

   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf

   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf

@@ -133,7 +132,6 @@
   PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf

   PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf

   ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf

-  LzmaDecompressLib|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf

   MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf

   HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf

   PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf

@@ -142,6 +140,7 @@
   MemoryInitPeiLib|ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.inf

   ArmGicArchLib|ArmPkg/Library/ArmGicArchSecLib/ArmGicArchSecLib.inf

   DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLibBase.inf

+  LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf

 

 [LibraryClasses.common.DXE_CORE]

   DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf

@@ -501,7 +500,9 @@
   #

   EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf {

     <LibraryClasses>

+      AbootimgLib|EmbeddedPkg/Library/AbootimgLib/AbootimgLib.inf

       BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf

+      ZLib|EmbeddedPkg/Library/ZLib/ZLib.inf

   }

 

   #

@@ -509,7 +510,9 @@
   #

   EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.inf {

     <LibraryClasses>

+      AbootimgLib|EmbeddedPkg/Library/AbootimgLib/AbootimgLib.inf

       BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf

+      ZLib|EmbeddedPkg/Library/ZLib/ZLib.inf

   }

 

   #