diff mbox series

[edk2,edk2-platforms,04/12] Hisilicon/Pci: Merge PciPlatform into PcieInit Driver

Message ID 1521594198-52523-5-git-send-email-heyi.guo@linaro.org
State New
Headers show
Series Hisilicon/D0x: Switch to generic PciHostBridge | expand

Commit Message

gary guo March 21, 2018, 1:03 a.m. UTC
This is to prepare for switching to generic PciHostBridge driver, so
we move all platform specific code to platform specific drivers, not
in PciHostBridge driver.

This patch is to prepare moving EnlargeAtuConfig0() out of
PciHostBridge. Since the function was originally called in
NotifyPhase() of phase EfiPciHostBridgeEndEnumeration, so we propose
to move it to EFI_PCI_PLATFORM_PROTOCOL->PlatformNotify(). To reduce
redundant ATU definitions, we merge PciPlatform into PcieInitDxe
driver since ATU initialization is done in PcieInitDxe.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
---
 Platform/Hisilicon/D03/D03.dsc                                                                              |  1 -
 Platform/Hisilicon/D05/D05.dsc                                                                              |  1 -
 Platform/Hisilicon/D03/D03.fdf                                                                              |  1 -
 Platform/Hisilicon/D05/D05.fdf                                                                              |  1 -
 Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.inf                                                  | 53 --------------------
 Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf                                               |  5 ++
 {Platform/Hisilicon/D03/Drivers/PciPlatform => Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610}/PciPlatform.h |  0
 Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.h                                                 |  6 +++
 {Platform/Hisilicon/D03/Drivers/PciPlatform => Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610}/PciPlatform.c | 12 +++++
 Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInit.c                                                    |  4 +-
 10 files changed, 24 insertions(+), 60 deletions(-)

-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox series

Patch

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index c4963063794b..0b2bd29cdf83 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -457,7 +457,6 @@  [Components.common]
     <LibraryClasses>
       NULL|Platform/Hisilicon/D03/Library/PlatformPciLib/PlatformPciLib.inf
   }
-  Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.inf
   Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridgeDxe.inf {
     <LibraryClasses>
       DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index 0792b0814ea1..2150a6f4c0e9 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -611,7 +611,6 @@  [Components.common]
     <LibraryClasses>
       NULL|Platform/Hisilicon/D05/Library/PlatformPciLib/PlatformPciLib.inf
   }
-  Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.inf
   Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridgeDxe.inf {
     <LibraryClasses>
       DmaLib|EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf
diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf
index 09613fb8f6ea..e430d5c08982 100644
--- a/Platform/Hisilicon/D03/D03.fdf
+++ b/Platform/Hisilicon/D03/D03.fdf
@@ -263,7 +263,6 @@  [FV.FvMain]
   # PCI Support
   #
   INF Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf
-  INF Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.inf
   INF Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridgeDxe.inf
   INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
 
diff --git a/Platform/Hisilicon/D05/D05.fdf b/Platform/Hisilicon/D05/D05.fdf
index 17a43d8edbd0..13a60837a607 100644
--- a/Platform/Hisilicon/D05/D05.fdf
+++ b/Platform/Hisilicon/D05/D05.fdf
@@ -285,7 +285,6 @@  [FV.FvMain]
   # PCI Support
   #
   INF Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf
-  INF Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.inf
   INF Silicon/Hisilicon/Drivers/PciHostBridgeDxe/PciHostBridgeDxe.inf
   INF MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
 
diff --git a/Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.inf b/Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.inf
deleted file mode 100644
index 8b170d265485..000000000000
--- a/Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.inf
+++ /dev/null
@@ -1,53 +0,0 @@ 
-#/** @file
-#
-#    Copyright (c) 2016, Hisilicon Limited. All rights reserved.
-#    Copyright (c) 2016, Linaro Limited. 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          = 0x00010005
-  BASE_NAME            = PciPlatform
-  FILE_GUID            = E2441B64-7EF4-41fe-B3A3-8CAA7F8D3017
-  MODULE_TYPE          = DXE_DRIVER
-  VERSION_STRING       = 1.0
-  ENTRY_POINT          = PciPlatformDriverEntry
-
-[sources.common]
-  PciPlatform.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  MdeModulePkg/MdeModulePkg.dec
-  ArmPkg/ArmPkg.dec
-  Silicon/Hisilicon/HisiPkg.dec
-
-[LibraryClasses]
-  UefiDriverEntryPoint
-  UefiLib
-  BaseLib
-  DebugLib
-  ArmLib
-  IoLib
-  MemoryAllocationLib
-
-[Protocols]
-  gEfiPciPlatformProtocolGuid
-  gEfiFirmwareVolume2ProtocolGuid
-  gEfiPciIoProtocolGuid
-
-[Pcd]
-
-[FixedPcd]
-
-[Depex]
-  TRUE
-
diff --git a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf
index cb0a63f9a84e..94d0fc8c028b 100644
--- a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf
+++ b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf
@@ -26,6 +26,7 @@  [Sources]
   PcieInit.c
   PcieInitLib.c
   PcieInitAtu.c
+  PciPlatform.c
 
 [Packages]
   MdePkg/MdePkg.dec
@@ -40,6 +41,7 @@  [LibraryClasses]
   BaseLib
   DebugLib
   ArmLib
+  MemoryAllocationLib
   TimerLib
   PcdLib
   IoLib
@@ -47,6 +49,9 @@  [LibraryClasses]
 
 [Protocols]
   #gEfiPcieRootBridgeProtocolGuid
+  gEfiFirmwareVolume2ProtocolGuid
+  gEfiPciIoProtocolGuid
+  gEfiPciPlatformProtocolGuid
 
 [Pcd]
   gHisiTokenSpaceGuid.PcdPcieRootBridgeMask
diff --git a/Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.h b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PciPlatform.h
similarity index 100%
rename from Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.h
rename to Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PciPlatform.h
diff --git a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.h b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.h
index 87700ae8b9aa..ab0c7ab8bfa7 100644
--- a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.h
+++ b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitLib.h
@@ -248,4 +248,10 @@  EFI_STATUS PcieSetDBICS2Enable(UINT32 HostBridgeNum, UINT32 Port, UINT32 Enable)
 
 VOID InitAtu (PCI_ROOT_BRIDGE_RESOURCE_APPETURE *Private);
 
+EFI_STATUS
+PciPlatformDriverEntry (
+  IN EFI_HANDLE                         ImageHandle,
+  IN EFI_SYSTEM_TABLE                   *SystemTable
+  );
+
 #endif
diff --git a/Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.c b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PciPlatform.c
similarity index 93%
rename from Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.c
rename to Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PciPlatform.c
index 8bfac2d99fc4..35faa9caf022 100644
--- a/Platform/Hisilicon/D03/Drivers/PciPlatform/PciPlatform.c
+++ b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PciPlatform.c
@@ -25,6 +25,7 @@ 
 #include <Library/BaseMemoryLib.h>
 #include <Library/UefiDriverEntryPoint.h>
 #include <Library/MemoryAllocationLib.h>
+#include "PcieInitLib.h"
 
 //
 // Global variables for Option ROMs
@@ -387,6 +388,17 @@  Returns:
 
 --*/
 {
+  switch (Phase) {
+  case EfiPciHostBridgeEndEnumeration:
+    // Only do once
+    if (ChipsetPhase == ChipsetEntry) {
+      DEBUG ((DEBUG_INFO, "PCI end enumeration platform hook\n"));
+      EnlargeAtuConfig0 (HostBridge);
+    }
+    break;
+  default:
+    break;
+  }
 
   return EFI_SUCCESS;
 }
diff --git a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInit.c b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInit.c
index de297e67e2e1..6ee0cf845dee 100644
--- a/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInit.c
+++ b/Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInit.c
@@ -160,9 +160,7 @@  PcieInitEntry (
         }
     }
 
-
-    return EFI_SUCCESS;
-
+    return PciPlatformDriverEntry (ImageHandle, SystemTable);
 }